Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipfs: initialConfig option + fixes #43089

Closed
wants to merge 1 commit into from
Closed

ipfs: initialConfig option + fixes #43089

wants to merge 1 commit into from

Conversation

elitak
Copy link
Contributor

@elitak elitak commented Jul 5, 2018

added initialConfig option
fix: include wrapped binary in system PATH
fix: init service now attempts to umount mountpoints
fix: properly evaluate overridden extraConfig options.

Motivation for this change

fixes #42672

Addresses #82580 and ipfs/kubo#4214 (#29133 (comment))

initialConfig option is useful for fresh deployments via nixops etc.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@matthewbauer
Copy link
Member

@GrahamcOfBorg test ipfs

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: tests.ipfs

Partial log (click to expand)

Cannot nix-instantiate `tests.ipfs' because:
error: attribute 'ipfs' in selection path 'tests.ipfs' not found

@GrahamcOfBorg
Copy link

No attempt on x86_64-linux (full log)

The following builds were skipped because they don't evaluate on x86_64-linux: tests.ipfs

Partial log (click to expand)

Cannot nix-instantiate `tests.ipfs' because:
error: attribute 'ipfs' in selection path 'tests.ipfs' not found

@matthewbauer
Copy link
Member

/cc @seppeljordan

(path: value:
(mapAttrsRecursiveCond (value: ! value ? _type)
(path: value: let
value' = if value ? _type then value.content else value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this suddenly needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attrsets in configuration.nix evaluate to these kind of attrset wrappers (for purposes of handling mkOverride IIUC), rather than the attrsets literally provided. I had not sufficiently tested using attrsets as values, so I only recently found this change was necessary for proper marshalling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it, can you add a comment explaining this with an example of what wouldn't work without it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

services.ipfs.extraConfig.Swarm.AddrFilters = []; wouldn't work right now in master, because the attrset Swarm is not flattened into a simple attrset at the time the recursive map is evaluated. I can't explain why, because I don't understand it myself. I only know that the attrset I'm expecting is in .contents whenever .type is present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't reproduce, with or without this change, the mentioned setting works without problems.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update on this?

install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.ipfsMountDir}
install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.ipnsMountDir}
# XXX Sometimes, the daemon stops or crashes without unmounting.
umount -l "${cfg.ipfsMountDir}" || true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a lazy unmount?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If some process has an open handle in there, I don't want that to prevent a remount. This is a FUSE virtual FS, anyway, so I can't imagine how any harm could result from this.

@mmahut
Copy link
Member

mmahut commented Aug 7, 2019

Any updates on this pull request, please?

@elitak
Copy link
Contributor Author

elitak commented Apr 20, 2020

I've combined the original initialConfig featrue with a few other fixes. This is ready to be reviewed again.

umount -l "${cfg.ipnsMountDir}" || true
install -m 0755 -o "${cfg.user}" -g "${cfg.group}" -d "${cfg.ipfsMountDir}"
install -m 0755 -o "${cfg.user}" -g "${cfg.group}" -d "${cfg.ipnsMountDir}"
>>>>>>> 03a4ab9399b... ipfs: initialConfig option + fixes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge artifact

@mmahut
Copy link
Member

mmahut commented Jun 12, 2020

@elitak can we please have this rebase with the fix?

@Ericson2314
Copy link
Member

We want to land https://github.com/NixOS/nixpkgs/pull/90157/files, either with a fix, or a fix right after.

@elitak
Copy link
Contributor Author

elitak commented Jun 12, 2020

Huh? This doesn't fix anything crucial. I can rebase it later.

Not sure what the hangup was over this PR; I opened it almost 2 years ago...

fix: include wrapped binary in system PATH
fix: init service now attempts to umount mountpoints
fix: properly evaluate overridden extraConfig options.
@Ericson2314
Copy link
Member

Ericson2314 commented Jun 12, 2020

Oh, I meant that I wasn't gonna rebase this myself. But fine if you do, we can merge it or similar consider this PR.

@@ -192,6 +207,20 @@ in {
default = true;
};

initialConfig = mkOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is initialConfig needed when extraConfig is also available?

serviceConfig.User = cfg.user;
serviceConfig.Group = cfg.group;
};

baseService = recursiveUpdate commonEnv {
wants = [ "ipfs-init.service" ];
# NB: migration must be performed prior to pre-start, else we get the failure message!
preStart = optionalString cfg.autoMount ''
preStart = ''
install -m 0755 -o "${cfg.user}" -g "${cfg.group}" -d "${cfg.dataDir}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still needed in ipfs 0.5.1? ideally we would get some more diagnostics and report this as a bug

@Ericson2314
Copy link
Member

There is no wrapped binary, and I think the other 3 things would be better to configure separately. We have two bugs that cannot be reproduced, and initialConfig is a feature not a fix.

@stale
Copy link

stale bot commented Jun 9, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 9, 2021
@Ericson2314
Copy link
Member

I think we've taken everything we should from this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IPFS: cannot change owner and permissions of ‘/ipns’
7 participants