rootlessnetns: handle empty pid file gracefully#759
Open
kairosci wants to merge 1 commit intocontainers:mainfrom
Open
rootlessnetns: handle empty pid file gracefully#759kairosci wants to merge 1 commit intocontainers:mainfrom
kairosci wants to merge 1 commit intocontainers:mainfrom
Conversation
mheon
reviewed
Apr 11, 2026
mheon
reviewed
Apr 11, 2026
eaaa78b to
fc0f975
Compare
|
Packit jobs failed. @containers/packit-build please check. |
fc0f975 to
a922767
Compare
762e651 to
44244c3
Compare
Luap99
requested changes
Apr 13, 2026
Member
Luap99
left a comment
There was a problem hiding this comment.
If look at the issue I do not think this fundamentally solves the root cause.
The main issue is that the code from podman unshare --rootless-netns, i.e. Run() always overwrites the setup error with the one from cleanup. At the least it would make sense to return both there, right now we ignore inErr on that branch so the real error is never visible to end users.
Comment on lines
+323
to
+335
| // if the pid file is empty, pasta failed to start so there is nothing to clean up | ||
| if errors.Is(err, ErrEmptyPIDFile) { | ||
| logrus.Debugf("Rootless netns conn pid file is empty, nothing to clean up") | ||
| return nil | ||
| } | ||
| if err != nil { | ||
| logrus.Warnf("Rootless netns conn pid file is invalid: %v", err) | ||
| return nil | ||
| } | ||
| // kill the slirp/pasta process so we do not leak it | ||
| err = unix.Kill(pid, unix.SIGTERM) | ||
| if err == unix.ESRCH { | ||
| err = nil |
Member
There was a problem hiding this comment.
IMO we must still return the any other pid file parsing error, so we should keep the logic as is just with the extra ErrEmptyPIDFile branch
ac396fc to
f9bf066
Compare
When pasta fails to start, it can leave an empty PID file which causes a crash in readPidFile. This fix handles empty PID files gracefully by returning a specific error and ignoring it during cleanup. Fixes: containers/podman#28441 Signed-off-by: Alessio Attilio <attilio.alessio@protonmail.com>
f9bf066 to
2b1ba0a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes containers/podman#28441
When pasta fails to start (e.g., due to invalid gateway config), it creates an empty PID file. The readPidFile() function then crashes when trying to parse the empty string with strconv.Atoi().
This fix: