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

apptainer, singularity: precede system-level bin paths in defaultPath and fix singularity image running #306730

Merged
merged 4 commits into from
Jul 3, 2024

Conversation

ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Apr 25, 2024

Description of changes

apptainer and singularity now prioritize PATH from the system over those constructed from dependent packages, when it comes to the substitution of defaultPath values (the PATH hard-coded inside Apptainer/Singularity library for them to find third-party utilities). It is now constructed by the following sources, ordered by their precedence:

  • systemBinPaths, a new argument introduced to specify the /**/bin paths from the system, especially those with their SUID bit set.
  • The original defaultPath value, making it work out of the box in FHS systems.
  • defaultPathInputs, a list of packages to form the fall-back PATH.

This change is required to enable Sylabs SingularityCE (singularity) to run images, as it requires a fusermount3 commant with SUID bit set.

The arguments newuidmapPath and newgidmapPath is deprecated in favour of systemBinPaths. Their support will be removed in future releases.

New option programs.singularity.systemBinPaths is introduced to specify the systemBinPaths argument of the overridden package. It includes "/run/wrappers/bin" even if specified empty.

The option programs.singularity.enableFakeroot is deprecated and has no effect. --fakeroot support is now always enabled as long as programs.singularity.systemBinPaths is not forcefully overridden.

This PR depends on #306656 and #306716, and currently contains their commits. The size of this PR will reduce once the dependent PRs are merged.

Together with #306716, this PR fixes #295809 and prevents the broken singularity from going into the stable release. If this fails to merge before the branch-off, I would like to have the changes backported without the deprecation warnings.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: changelog 8.has: module (update) This PR changes an existing module in `nixos/` labels Apr 25, 2024
@ShamrockLee ShamrockLee force-pushed the apptainer-default-path branch from a1e1fc8 to 5ffacad Compare April 25, 2024 08:04
@ofborg ofborg bot requested a review from jbedo April 25, 2024 08:38
@ofborg ofborg bot added 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Apr 25, 2024
@Mic92
Copy link
Member

Mic92 commented Apr 26, 2024

There is no branch of yet. So if you get your pull request finished up soon, just merging it, will also make it available in the upcoming release. If not, we can still backport it, if the current approach is unusable without this change anyway.

@ShamrockLee ShamrockLee changed the title apptainer, singularity: prioritize system defaultPath and fix singularity image running apptainer, singularity: precede system bin paths to defaultPath and fix singularity image running May 1, 2024
@ShamrockLee ShamrockLee changed the title apptainer, singularity: precede system bin paths to defaultPath and fix singularity image running apptainer, singularity: precede system-level bin paths in defaultPath and fix singularity image running May 1, 2024
@ShamrockLee ShamrockLee force-pushed the apptainer-default-path branch from 59d1cb1 to 52330bc Compare May 17, 2024 01:43
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label May 17, 2024
Prefix the upstream-given defalutPath value over the one constructed by
defaultPathInputs.

Make SUID'ed binaries searchable out-of-the-box non-NixOS platforms.
@ShamrockLee ShamrockLee force-pushed the apptainer-default-path branch from 52330bc to 33a00ae Compare June 2, 2024 23:46
@ShamrockLee ShamrockLee marked this pull request as ready for review June 2, 2024 23:46
Use systemBinPaths as the new way to specify system bin paths,
especifally for SUID'ed binaries.

Deprecate arguments setuidmapPath and setgidmapPath in favour of
systemBinPaths.

Add NixOS configuration option programs.singularity.systemBinPath, with
"/run/wrappers/bin" included by default.
Add a Nixpkgs 24.05 release note entry explaining the introduction of
`systemBinPaths` argument, the prioritization of the original (FHS)
`defaultPath` values, and the deprecation of arguments `newuidmapPath`,
`newgidmapPath` and NixOS configuration option
`programs.singularity.enableFakeroot`.
Warn when arguments newuidmapPath and newgidmapPath is used.
@ShamrockLee ShamrockLee force-pushed the apptainer-default-path branch from 33a00ae to c3026ac Compare June 2, 2024 23:54
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 3, 2024
@ShamrockLee
Copy link
Contributor Author

I rebased this PR on top of master, and both apptainer and singularity seems working well.

I don't know how to test those GPG-related functionality. @SomeoneSerge @FynnFreyer, could you help test if the GPU works with these changes applied?

BTW, should we rename pkgs.{apptainer,singularity}-overriden-nixos to pkgs.{apptainer,singularity}-overridden-nixos in this PR? The renaming should not break any workflow we maintain, and we have explicitly stated that the two variant packages are for binary caching only.

@ShamrockLee
Copy link
Contributor Author

@SomeoneSerge, could you help look at this PR? This will fix the issues regarding third-party utility access for Apptainer and SingularityCE.

@SomeoneSerge
Copy link
Contributor

I am terribly, terribly sorry about losing touch on this one. I remember I had tried building the gpu tests just via the flake reference and I couldn't because the cuda image blew up in size. I'll give it another try

@SomeoneSerge
Copy link
Contributor

Ok, with #323056 in I can finally run the test without modifying the diskSize arguments:

❯ (nix build --impure .#apptainer.gpuChecks.image-saxpy --print-out-paths ; echo saxpy) | xargs apptainer exec --nv
trace: warning: cudaPackages.autoAddDriverRunpath is deprecated, use pkgs.autoAddDriverRunpath instead
warning: 'http://nixpkgs-cuda.cs-338.someonex.net:38180/nixpkgs-cuda' does not appear to be a binary cache
INFO:    gocryptfs not found, will not be able to use gocryptfs
WARNING: passwd file doesn't exist in container, not updating
WARNING: group file doesn't exist in container, not updating
Start
Runtime version: 12020
Driver version: 12050
Host memory initialized, copying to the device
Scheduled a cudaMemcpy, calling the kernel
Scheduled a kernel call
Max error: 0.000000

@SomeoneSerge
Copy link
Contributor

I think this is backport-able, but I'll look into this some more

@SomeoneSerge SomeoneSerge merged commit 7cdac9f into NixOS:master Jul 3, 2024
26 checks passed
Copy link
Contributor

github-actions bot commented Jul 3, 2024

Backport failed for release-24.05, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-24.05
git worktree add -d .worktree/backport-306730-to-release-24.05 origin/release-24.05
cd .worktree/backport-306730-to-release-24.05
git switch --create backport-306730-to-release-24.05
git cherry-pick -x 409cbbe61a551410d109b739a5cb0959a2c8db16 f6d9b4b6fc7f376e5f5ecacace951f57c155045c dbcf7cf697c601fc92da45453290b81587b87ef5 c3026ac986b6b21409a0240dcad4a411dad0d419

@SomeoneSerge
Copy link
Contributor

Thank you again @ShamrockLee

@ShamrockLee
Copy link
Contributor Author

Backport failed for release-24.05, because it was unable to cherry-pick the commit(s).

#306716 needs to be backported first so that we could backport this one.

Copy link
Contributor

github-actions bot commented Jul 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

singularity fails to run images
3 participants