From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludovic.courtes@inria.fr (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] guix-daemon: Add option to disable garbage collection. Date: Thu, 19 Apr 2018 16:47:15 +0200 Message-ID: <87tvs7jlsc.fsf@inria.fr> References: <87a7uklht1.fsf@gnu.org> <87po3g9znv.fsf@gnu.org> <87vad8o0av.fsf@gnu.org> <874lkijhts.fsf@gnu.org> <87sh7rmuot.fsf@inria.fr> <871sfbcs5t.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f9AqH-00076R-Ny for guix-devel@gnu.org; Thu, 19 Apr 2018 10:47:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f9AqE-00020e-LM for guix-devel@gnu.org; Thu, 19 Apr 2018 10:47:21 -0400 In-Reply-To: <871sfbcs5t.fsf@gnu.org> (Roel Janssen's message of "Thu, 19 Apr 2018 14:12:02 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Roel Janssen Cc: guix-devel Roel Janssen skribis: > Ludovic Court=C3=A8s writes: [...] >>> diff --git a/nix/nix-daemon/nix-daemon.cc b/nix/nix-daemon/nix-daemon.cc >>> index deb7003d7..65770ba95 100644 >>> --- a/nix/nix-daemon/nix-daemon.cc >>> +++ b/nix/nix-daemon/nix-daemon.cc >>> @@ -529,6 +529,11 @@ static void performOp(bool trusted, unsigned int c= lientVersion, >>> } >>>=20=20 >>> case wopCollectGarbage: { >>> + if (settings.isRemoteConnection) { >>> + throw Error("Garbage collection is disabled for remote hos= ts."); >>> + break; >>> + } >>> GCOptions options; >>> options.action =3D (GCOptions::GCAction) readInt(from); >>> options.pathsToDelete =3D readStorePaths(from); >> >> I was wondering if we would like to allow some of the =E2=80=98GCAction= =E2=80=99 values, >> but maybe it=E2=80=99s better to disallow them altogether like this code= does. > > Could we please start with a =E2=80=9Cdisable any GC=E2=80=9D and start a= llowing cases > on a case-by-case basis? Sure, that=E2=80=99s what I was suggesting. :-) >> Last thing: could you add a couple of tests? tests/guix-daemon.sh >> already has tests for =E2=80=98--listen=E2=80=99, so you could take insp= iration from >> those. > > I included a test, but I don't know how I can properly run this test. > Could you elaborate on how I can test the test(s)? Run: make check TESTS=3Dtests/guix-daemon.sh See . > From b29d3a90e1487ebda5ac5b6bc146f8c95218eab6 Mon Sep 17 00:00:00 2001 > From: Roel Janssen > Date: Thu, 19 Apr 2018 14:01:49 +0200 > Subject: [PATCH] guix-daemon: Disable garbage collection for remote hosts. > > * nix/nix-daemon/nix-daemon.cc (performOp): Display appropriate error mes= sage; > (acceptConnection): Set isRemoteConnection when connection is over TCP. Rather: * nix/nix-daemon/nix-daemon.cc (isRemoteConnection): New variable. (performOp): For wopCollectGarbage, throw an error when isRemoteConnection is set. (acceptConnection): Set isRemoteConnection when connection is not AF_UNIX. > +output=3D`GUIX_DAEMON_SOCKET=3D"$socket" guix gc` > +if [[ "$output" !=3D *"GUIX_DAEMON_SOCKET=3D$socket" ]]; > +then > + exit 1 > +fi Perhaps simply check the exit code of =E2=80=98guix gc=E2=80=99 and fail if= it succeeds? Like: if guix gc; then false; else true; fi Also please try to avoid Bash-specific constructs like [[ this ]]. Could you send an updated patch? Thank you, Ludo=E2=80=99.