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

podman: add required argv0 to wrapper. #188108

Closed
wants to merge 1 commit into from

Conversation

KenMacD
Copy link
Contributor

@KenMacD KenMacD commented Aug 24, 2022

Description of changes

In cases where podman uses conmon it passes its own path
as a command line argument in --exit-command. This exit
command is used for container cleanup. For it to work the path
must be the wrapper instead of the unwrapped executable.

Without this change rootless podman runs can hang for 20 seconds
before killing the container itself. The debug logs will show:

Exceeded conmon timeout waiting for container ___ to exit
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 22.11 Release Notes (or backporting 22.05 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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

In cases where podman uses conmon it passes its own path
as a command line argument in `--exit-command`. This exit
command is used for container cleanup. For it to work the path
must be the wrapper instead of the unwrapped executable.

Without this change rootless podman runs can hang for 20 seconds
before killing the container itself. The debug logs will show:

    Exceeded conmon timeout waiting for container ___ to exit
@@ -74,6 +74,7 @@ in runCommand podman.name {
ln -s ${podman-unwrapped}/lib $out/lib
ln -s ${podman-unwrapped}/share $out/share
makeWrapper ${podman-unwrapped}/bin/podman $out/bin/podman \
--argv0 $out/bin/podman \
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this work?

Suggested change
--argv0 $out/bin/podman \
--inherit-argv0 \

@b12f
Copy link
Contributor

b12f commented Aug 24, 2022

Result of nixpkgs-review pr 188108 run on x86_64-linux 1

1 package built:
  • podman

@KenMacD
Copy link
Contributor Author

KenMacD commented Aug 24, 2022

With more testing it seems this isn't generally working in Linux cases where /proc/self/exe can be read. I'll close this PR and see if I can come up with something better.

@KenMacD KenMacD closed this Aug 24, 2022
@dawidd6
Copy link
Contributor

dawidd6 commented Oct 1, 2022

@KenMacD did you find a better way to fix that? This issue is still present.

@dawidd6
Copy link
Contributor

dawidd6 commented Oct 3, 2022

Setting conmon_env_vars in containers.conf with PATH=<nix-profile-bin>:/bin:/sbin might help. Dunno why but it solved the issue on my end.

@KenMacD
Copy link
Contributor Author

KenMacD commented Oct 5, 2022

Sorry @dawidd6, I should have added another comment here. I ended up getting this PR applied upstream. As it's not released yet I've been using a local overlay for it (the filename changed upstream, so I didn't bother with fetchpatch):

self: super:
{
  podman-unwrapped = super.podman-unwrapped.overrideAttrs (old: {
    patches = (old.patches or []) ++ [
      ./add-path.patch
    ];
  });
}

With that patch simply being:

diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go
index cb76de72c..261068082 100644
--- a/libpod/oci_conmon_linux.go
+++ b/libpod/oci_conmon_linux.go
@@ -1297,6 +1297,7 @@ func (r *ConmonOCIRuntime) configureConmonEnv(runtimeDir string) []string {
 	if ok {
 		env = append(env, fmt.Sprintf("CONTAINERS_CONF=%s", conf))
 	}
+	env = append(env, fmt.Sprintf("PATH=%s", os.Getenv("PATH")))
 	env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", runtimeDir))
 	env = append(env, fmt.Sprintf("_CONTAINERS_USERNS_CONFIGURED=%s", os.Getenv("_CONTAINERS_USERNS_CONFIGURED")))
 	env = append(env, fmt.Sprintf("_CONTAINERS_ROOTLESS_UID=%s", os.Getenv("_CONTAINERS_ROOTLESS_UID")))

@KenMacD KenMacD deleted the podman-argv0 branch October 5, 2022 16:07
@dawidd6
Copy link
Contributor

dawidd6 commented Oct 5, 2022

Thanks for the patch @KenMacD!

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.

4 participants