From 5bc38fc0893e6d04d09ccb3722cdd5edb3bd57ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Thu, 7 Sep 2017 10:35:00 +0200 Subject: [PATCH 1/4] glusterfs service: Ensure dirs needed by `glusterfind` exist --- .../modules/services/network-filesystems/glusterfs.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/network-filesystems/glusterfs.nix b/nixos/modules/services/network-filesystems/glusterfs.nix index f7fed793066..7454eeef803 100644 --- a/nixos/modules/services/network-filesystems/glusterfs.nix +++ b/nixos/modules/services/network-filesystems/glusterfs.nix @@ -50,11 +50,19 @@ in after = [ "rpcbind.service" "network.target" "local-fs.target" ]; before = [ "network-online.target" ]; - # The copying of hooks is due to upstream bug https://bugzilla.redhat.com/show_bug.cgi?id=1452761 preStart = '' install -m 0755 -d /var/log/glusterfs + '' + # The copying of hooks is due to upstream bug https://bugzilla.redhat.com/show_bug.cgi?id=1452761 + + '' mkdir -p /var/lib/glusterd/hooks/ ${rsync}/bin/rsync -a ${glusterfs}/var/lib/glusterd/hooks/ /var/lib/glusterd/hooks/ + '' + # `glusterfind` needs dirs that upstream installs at `make install` phase + # https://github.com/gluster/glusterfs/blob/v3.10.2/tools/glusterfind/Makefile.am#L16-L17 + + '' + mkdir -p /var/lib/glusterd/glusterfind/.keys + mkdir -p /var/lib/glusterd/hooks/1/delete/post/ ''; serviceConfig = { From 8e329da496f8e7f3c5b95c721b7a95317f5854c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Fri, 8 Sep 2017 03:46:59 +0200 Subject: [PATCH 2/4] glusterfs: Fix wrong xattr package: xattr -> pyxattr. Fixes error File "/nix/store/lxpsl84km87xpk59nai6a33ihgpfs7qr-glusterfs-3.10.2/libexec/glusterfs/glusterfind/changelog.py", line 105, in populate_pgfid_and_inodegfid file_xattrs = xattr.list(p) AttributeError: 'module' object has no attribute 'list' when using `glusterfind pre`. --- pkgs/tools/filesystems/glusterfs/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/filesystems/glusterfs/default.nix b/pkgs/tools/filesystems/glusterfs/default.nix index af76e429d31..2cba75860fe 100644 --- a/pkgs/tools/filesystems/glusterfs/default.nix +++ b/pkgs/tools/filesystems/glusterfs/default.nix @@ -28,7 +28,7 @@ let pkgs.flask pkgs.prettytable pkgs.requests - pkgs.xattr + pkgs.pyxattr ])) # NOTE: `python2` has to be *AFTER* the above `python2.withPackages`, # to ensure that the packages are available but the `toPythonPath` From e7325f82a32cea8d7e6cfafff9e61e4468fd19dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Fri, 8 Sep 2017 03:49:33 +0200 Subject: [PATCH 3/4] glusterfs: Patch upstream bug preventing glusterfind from running. See: https://bugzilla.redhat.com/show_bug.cgi?id=1489610 Also add patch to correctly log stderr from remote nodes when glusterfind fails. This, too, should be removed when fixed upstream. --- pkgs/tools/filesystems/glusterfs/default.nix | 3 ++ ...10-glusterfind-var-data-under-prefix.patch | 27 ++++++++++ ...lusterfind-log-remote-node_cmd-error.patch | 49 +++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 pkgs/tools/filesystems/glusterfs/glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch create mode 100644 pkgs/tools/filesystems/glusterfs/glusterfs-glusterfind-log-remote-node_cmd-error.patch diff --git a/pkgs/tools/filesystems/glusterfs/default.nix b/pkgs/tools/filesystems/glusterfs/default.nix index 2cba75860fe..6d9cd33f86e 100644 --- a/pkgs/tools/filesystems/glusterfs/default.nix +++ b/pkgs/tools/filesystems/glusterfs/default.nix @@ -73,6 +73,9 @@ rec { ./glusterfs-use-PATH-instead-of-hardcodes.patch ./glusterfs-fix-unsubstituted-autoconf-macros.patch ./glusterfs-python-remove-find_library.patch + # Remove when https://bugzilla.redhat.com/show_bug.cgi?id=1489610 is fixed + ./glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch + ./glusterfs-glusterfind-log-remote-node_cmd-error.patch ]; # Note that the VERSION file is something that is present in release tarballs diff --git a/pkgs/tools/filesystems/glusterfs/glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch b/pkgs/tools/filesystems/glusterfs/glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch new file mode 100644 index 00000000000..8a3da0d6db7 --- /dev/null +++ b/pkgs/tools/filesystems/glusterfs/glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch @@ -0,0 +1,27 @@ +From 965eb1e08e10ff82bb91d485dc24672acc7c72cf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= +Date: Fri, 8 Sep 2017 00:51:53 +0200 +Subject: [PATCH] Fix "glusterfind saves var data under $prefix instead of + localstatedir". Fixes #1489610 + +Change-Id: I6d71297fb7a5a9d12cc3726b4a4ad94efcd644f9 +--- + configure.ac | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 0c3a38689..d508fda71 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1057,7 +1057,7 @@ if test "x$prefix" = xNONE; then + prefix=$ac_default_prefix + fi + GLUSTERFS_LIBEXECDIR="$(eval echo $prefix)/libexec/glusterfs" +-GLUSTERFSD_MISCDIR="$(eval echo $prefix)/var/lib/misc/glusterfsd" ++GLUSTERFSD_MISCDIR="$(eval echo $localstatedir)/var/lib/misc/glusterfsd" + prefix=$old_prefix + + ### Dirty hacky stuff to make LOCALSTATEDIR work +-- +2.12.0 + diff --git a/pkgs/tools/filesystems/glusterfs/glusterfs-glusterfind-log-remote-node_cmd-error.patch b/pkgs/tools/filesystems/glusterfs/glusterfs-glusterfind-log-remote-node_cmd-error.patch new file mode 100644 index 00000000000..8bc00fdbf75 --- /dev/null +++ b/pkgs/tools/filesystems/glusterfs/glusterfs-glusterfind-log-remote-node_cmd-error.patch @@ -0,0 +1,49 @@ +From 92a6b84a37e7e2e0ec0655ca45cedb64ab72080e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= +Date: Fri, 8 Sep 2017 02:40:01 +0200 +Subject: [PATCH] glusterfind: Log remote stderr on `node_cmd` error. + +The problem of lost stderr was introduced in +commit feea851fad4f89b48bfe89fe3b75250cc7bd6501. + +Change-Id: Ic98f9bc9682ae3bd9c3ebea3855667fc8ba2843d +--- + tools/glusterfind/src/main.py | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py +index c125f970a..6fffce4b3 100644 +--- a/tools/glusterfind/src/main.py ++++ b/tools/glusterfind/src/main.py +@@ -75,12 +75,27 @@ def node_cmd(host, host_uuid, task, cmd, args, opts): + cmd = ["ssh", + "-oNumberOfPasswordPrompts=0", + "-oStrictHostKeyChecking=no", ++ # We force TTY allocation (-t -t) so that Ctrl+C is handed ++ # through; see: ++ # https://bugzilla.redhat.com/show_bug.cgi?id=1382236 ++ # Note that this turns stderr of the remote `cmd` ++ # into stdout locally. + "-t", + "-t", + "-i", pem_key_path, + "root@%s" % host] + cmd + +- execute(cmd, exit_msg="%s - %s failed" % (host, task), logger=logger) ++ (returncode, err, out) = execute(cmd, logger=logger) ++ if returncode != 0: ++ # Because the `-t -t` above turns the remote stderr into ++ # local stdout, we need to log both stderr and stdout ++ # here to print all error messages. ++ fail("%s - %s failed; stdout (including remote stderr):\n" ++ "%s\n" ++ "stderr:\n" ++ "%s" % (host, task, out, err), ++ returncode, ++ logger=logger) + + if opts.get("copy_outfile", False) and not localdir: + cmd_copy = ["scp", +-- +2.12.0 + From abc96aae47d5651f0f1d0b5da7bfcf163a3e7c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Fri, 8 Sep 2017 04:19:59 +0200 Subject: [PATCH 4/4] glusterfs: Fix glusterfind's crawlers dlopen() error. This fixes: Traceback (most recent call last): File "/nix/store/7f9arl3f9xyj8sm05mkanh2mlp217192-glusterfs-3.10.2/libexec/glusterfs/glusterfind/changelog.py", line 22, in import libgfchangelog File "/nix/store/7f9arl3f9xyj8sm05mkanh2mlp217192-glusterfs-3.10.2/libexec/glusterfs/glusterfind/libgfchangelog.py", line 21, in libgfc = CDLL("libgfchangelog.so", use_errno=True, mode=RTLD_GLOBAL) File "/nix/store/nlyr5ankhi7yvva8zndi718zj37js270-python-2.7.13-env/lib/python2.7/ctypes/__init__.py", line 362, in __init__ self._handle = _dlopen(self._name, mode) OSError: libgfchangelog.so: cannot open shared object file: No such file or directory Connection to 10.0.0.2 closed. when running `glusterfind pre`. Done by setting PYTHONPATH/LD_LIBRARY_PATH as for the other Python scripts. --- pkgs/tools/filesystems/glusterfs/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/tools/filesystems/glusterfs/default.nix b/pkgs/tools/filesystems/glusterfs/default.nix index 6d9cd33f86e..0bdb7413f22 100644 --- a/pkgs/tools/filesystems/glusterfs/default.nix +++ b/pkgs/tools/filesystems/glusterfs/default.nix @@ -139,8 +139,14 @@ rec { # Luckily, `libexec` scripts are never supposed to be invoked straight from PATH, # instead they are invoked directly from `gluster` or `glusterd`, which is why it is # sufficient to set PYTHONPATH for those executables. + # + # Exceptions to these rules are the `glusterfind` `brickfind.py` and `changelog.py` + # crawlers, which are directly invoked on other gluster nodes using a remote SSH command + # issues by `glusterfind`. wrapProgram $out/share/glusterfs/scripts/eventsdash.py --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" + wrapProgram $out/libexec/glusterfs/glusterfind/brickfind.py --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" + wrapProgram $out/libexec/glusterfs/glusterfind/changelog.py --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH" ''; doInstallCheck = true;