-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
possible solution for podman pause process that keeps running after user logout #11560
Comments
Actually I tested this podman-pause.service unit file:
Not sure if
Podman seems to work normally, and then when I log out, systemd is able to clean up the pause process as part of normal systemd session termination, instead of podman preventing the session termination from happening! It would be nice if this could be the standard behaviour of podman. |
@giuseppe PTAL |
podman moves the pause process to a scope, but (I am not sure why) we disable the DefaultDependencies. Would something like this be enough for your case? Could you try it out and see if it solves the problem you've seen? diff --git a/utils/utils_supported.go b/utils/utils_supported.go
index ebc870d26..f3507b7d1 100644
--- a/utils/utils_supported.go
+++ b/utils/utils_supported.go
@@ -40,7 +40,7 @@ func RunUnderSystemdScope(pid int, slice string, unitName string) error {
properties = append(properties, systemdDbus.PropSlice(slice))
properties = append(properties, newProp("PIDs", []uint32{uint32(pid)}))
properties = append(properties, newProp("Delegate", true))
- properties = append(properties, newProp("DefaultDependencies", false))
+ properties = append(properties, newProp("DefaultDependencies", true))
ch := make(chan string)
_, err = conn.StartTransientUnit(unitName, "replace", properties, ch)
if err != nil { |
@giuseppe I tried that compiling from the v3.3.1-rhel branch on EL8.
Did
P.S. I thought your name seemed familiar - we both gave presentations at https://indico.cern.ch/event/757415/ and went on a tour of the CMS detector. :) |
systemd has a delay to stop the user session after a logout. Even without the podman pause process running, I see that the user session is still kept around for 10 seconds. How long have you waited after the logout to see what processes were still running? If you want to terminate the user session immediately after the last logout you may need to tweak |
@giuseppe The default value of UserStopDelaySec seems to be ~ 5-10 seconds, but the problem persists indefinitely, e.g. even after waiting 20 minutes the systemd session is still kept alive by the podman pause process. |
thanks for confirming it. I've tested on RHEL 8 and I see a different behavior since This behavior helped to find an error on our side: #11606 Would it be possible for you to check that PR? I am not able to reproduce anymore the issue on RHEL with that applied. |
make sure the pause process is moved to its own scope as well as what we do when we join an existing user+mount namespace. Closes: containers#11560 [NO TESTS NEEDED] Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe thanks for making the patch!
Then I ran podman as before; although the PPID of the pause process is still 1, it gets properly terminated when I log out and the systemd session is able to finish successfully. Thanks! |
Do you think this might get backported to v3.3 or v3.4 ? |
make sure the pause process is moved to its own scope as well as what we do when we join an existing user+mount namespace. Closes: containers#11560 [NO TESTS NEEDED] Signed-off-by: Giuseppe Scrivano <[email protected]> (cherry picked from commit a2c8b5d)
Sure, the backport for 3.4 is here: #11624 |
Review of related issues
A number of issues and workarounds have been raised related to the podman pause process when a user runs rootless podman containers, which remains running even after a user logs out.
#7180
cockpit-project/cockpit-podman#473
#7192
#7133
#10640
systemd
systemd/systemd#16332
systemd/systemd#16318 this is the only one which remains open, which is about ways of storing file descriptors.
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
The specific problem I am encountering is that I have made a systemd user service to set up SSH agents for users.
In /etc/systemd/user/
Then
sudo systemctl --global enable ssh-agent.service
to enable it as a user-level service for all users. This works perfectly on EL8 to run at most one SSH agent for each user logged in (no matter how many login sessions they have), and automatically stop it when every session for a user has ended. But having gone to some length to do this "the right (systemd) way" as opposed to bash scripting, the problem is that if users use podman, their systemd sessions never end when they log out, because podman pause is left running indefinitely, so their SSH agents are left running forever which is a security concern.Steps to reproduce the issue:
Run a container with podman , e.g.
podman run --rm -it registry.hub.docker.com/library/fedora:34
Exit the container
Log out
Describe the results you received:
The user's systemd session is still running:
The podman pause process has to be manually killed in order to allow the session to be cleaned up properly.
Describe the results you expected:
The user's systemd session is able to finish normally because no process is left running.
Idea for a possible solution
As I understand the podman pause process always needs to be running for a user to keep a handle on some namespaces, so that rootless pods can use the same user namespace. But instead of being started when podman is first invoked by a user, could the pause process be a systemd user service, just like the SSH agent example? That way it would be automatically started when a user logs in (if there isn't one already running), and automatically stopped when the user logs out by systemd, allowing normal termination of the session. It could be an optional opt-in for admins, by doing
sudo systemctl --global enable podman-pause.service
and individual users could manage it themselves viasystemctl --user stop podman-pause.service
or opt out withsystemctl --user mask podman-pause.service
.This way systemd could do the work for you and avoid a race condition with starting the pause process, and podman would play nicely with other systemd-managed user services.
Also IIUC I think it would only require a way to start the podman pause process with a command (for ExecStart, maybe podman unshare something ??), but probably not require any other changes in podman code.
Output of
podman version
:Package info (e.g. output of
rpm -q podman
orapt list podman
):**Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?
Yes
The text was updated successfully, but these errors were encountered: