From 28949db47e56fa276bcc8f25fd9482a8c4eb155e Mon Sep 17 00:00:00 2001 From: Karmanyaah Malhotra Date: Sun, 5 Feb 2023 18:31:04 -0600 Subject: [PATCH 1/4] nixos/kubo: reenable FUSE test with workaround Update comment notice on broken fuse Co-authored-by: Luflosi --- nixos/tests/kubo.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nixos/tests/kubo.nix b/nixos/tests/kubo.nix index 94aa24a9204f..9fba5e2d1f3c 100644 --- a/nixos/tests/kubo.nix +++ b/nixos/tests/kubo.nix @@ -50,12 +50,13 @@ import ./make-test-python.nix ({ pkgs, ...} : { machine.succeed("test ! -e /var/lib/ipfs/") # Test FUSE mountpoint + # The FUSE mount functionality is broken as of v0.13.0 and v0.17.0. + # See https://github.com/ipfs/kubo/issues/9044. + # Workaround: using CID Version 1 avoids that. ipfs_hash = fuse.succeed( - "echo fnord3 | ipfs --api /ip4/127.0.0.1/tcp/2324 add --quieter" + "echo fnord3 | ipfs --api /ip4/127.0.0.1/tcp/2324 add --quieter --cid-version=1" ) - # The FUSE mount functionality is broken as of v0.13.0. - # See https://github.com/ipfs/kubo/issues/9044. - # fuse.succeed(f"cat /ipfs/{ipfs_hash.strip()} | grep fnord3") + fuse.succeed(f"cat /ipfs/{ipfs_hash.strip()} | grep fnord3") ''; }) From 4bd622cd9d17d3fe2dedbc2adcb1eb45ecbff805 Mon Sep 17 00:00:00 2001 From: Karmanyaah Malhotra Date: Tue, 31 Jan 2023 11:32:20 -0500 Subject: [PATCH 2/4] nixos/kubo: unmount on service stop When kubo is force killed with `pkill -KILL ipfs` or by systemd-oomd, it doesn't unmount /ipfs and /ipns. That prevents it from starting up the next time. So, unmount on postStop. --- nixos/doc/manual/release-notes/rl-2305.section.md | 2 ++ nixos/modules/services/network-filesystems/kubo.nix | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index 8c8a81519659..ffdb61091591 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -332,6 +332,8 @@ In addition to numerous new and upgraded packages, this release has the followin [headscale's example configuration](https://github.com/juanfont/headscale/blob/main/config-example.yaml) can be directly written as attribute-set in Nix within this option. +- `services.kubo` unmounts `ipfsMountDir` and `ipnsMountDir` even if it is killed uncleanly, when 'autoMount` is enabled. + - `nixos/lib/make-disk-image.nix` can now mutate EFI variables, run user-provided EFI firmware or variable templates. This is now extensively documented in the NixOS manual. - `services.grafana` listens only on localhost by default again. This was changed to upstreams default of `0.0.0.0` by accident in the freeform setting conversion. diff --git a/nixos/modules/services/network-filesystems/kubo.nix b/nixos/modules/services/network-filesystems/kubo.nix index 0cb0e126d4c5..e2cc477b23f9 100644 --- a/nixos/modules/services/network-filesystems/kubo.nix +++ b/nixos/modules/services/network-filesystems/kubo.nix @@ -319,6 +319,10 @@ in # change when the changes are applied. Whyyyyyy..... ipfs --offline config replace - ''; + postStop = mkIf cfg.autoMount '' + # After an unclean shutdown the fuse mounts at ${cfg.ipnsMountDir} and ${cfg.ipfsMountDir} are locked + umount --quiet '${cfg.ipnsMountDir}' '${cfg.ipfsMountDir}' || true + ''; serviceConfig = { ExecStart = [ "" "${cfg.package}/bin/ipfs daemon ${kuboFlags}" ]; User = cfg.user; From 5fb09c9e3a88dd9c291ea6aeab3b63923d325d6a Mon Sep 17 00:00:00 2001 From: Karmanyaah Malhotra Date: Sun, 5 Feb 2023 18:35:29 -0600 Subject: [PATCH 3/4] nixos/kubo: Test Kubo restart after a crash Move strip() to definition Co-authored-by: Luflosi --- nixos/tests/kubo.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nixos/tests/kubo.nix b/nixos/tests/kubo.nix index 9fba5e2d1f3c..3ea7c894ab3a 100644 --- a/nixos/tests/kubo.nix +++ b/nixos/tests/kubo.nix @@ -55,8 +55,15 @@ import ./make-test-python.nix ({ pkgs, ...} : { # Workaround: using CID Version 1 avoids that. ipfs_hash = fuse.succeed( "echo fnord3 | ipfs --api /ip4/127.0.0.1/tcp/2324 add --quieter --cid-version=1" - ) + ).strip() - fuse.succeed(f"cat /ipfs/{ipfs_hash.strip()} | grep fnord3") + fuse.succeed(f"cat /ipfs/{ipfs_hash} | grep fnord3") + + # Force Kubo to crash and wait for it to restart + # Tests the unmounting of /ipns and /ipfs + fuse.systemctl("kill --signal=SIGKILL ipfs.service") + fuse.wait_for_unit("ipfs.service", timeout = 30) + + fuse.succeed(f"cat /ipfs/{ipfs_hash} | grep fnord3") ''; }) From 6086d85777372ceae7f41501802d1884e9e024ef Mon Sep 17 00:00:00 2001 From: Karmanyaah Malhotra Date: Tue, 4 Apr 2023 13:21:17 -0400 Subject: [PATCH 4/4] nixos/kubo: documentation suggestions Co-authored-by: Sandro --- nixos/doc/manual/release-notes/rl-2305.section.md | 2 +- nixos/modules/services/network-filesystems/kubo.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2305.section.md b/nixos/doc/manual/release-notes/rl-2305.section.md index ffdb61091591..f572fa9652a5 100644 --- a/nixos/doc/manual/release-notes/rl-2305.section.md +++ b/nixos/doc/manual/release-notes/rl-2305.section.md @@ -332,7 +332,7 @@ In addition to numerous new and upgraded packages, this release has the followin [headscale's example configuration](https://github.com/juanfont/headscale/blob/main/config-example.yaml) can be directly written as attribute-set in Nix within this option. -- `services.kubo` unmounts `ipfsMountDir` and `ipnsMountDir` even if it is killed uncleanly, when 'autoMount` is enabled. +- `services.kubo` now unmounts `ipfsMountDir` and `ipnsMountDir` even if it is killed unexpectedly when 'autoMount` is enabled. - `nixos/lib/make-disk-image.nix` can now mutate EFI variables, run user-provided EFI firmware or variable templates. This is now extensively documented in the NixOS manual. diff --git a/nixos/modules/services/network-filesystems/kubo.nix b/nixos/modules/services/network-filesystems/kubo.nix index e2cc477b23f9..468e47d749b7 100644 --- a/nixos/modules/services/network-filesystems/kubo.nix +++ b/nixos/modules/services/network-filesystems/kubo.nix @@ -320,7 +320,7 @@ in ipfs --offline config replace - ''; postStop = mkIf cfg.autoMount '' - # After an unclean shutdown the fuse mounts at ${cfg.ipnsMountDir} and ${cfg.ipfsMountDir} are locked + # After an unclean shutdown the fuse mounts at cfg.ipnsMountDir and cfg.ipfsMountDir are locked umount --quiet '${cfg.ipnsMountDir}' '${cfg.ipfsMountDir}' || true ''; serviceConfig = {