-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
don't panic when /sys/fs/cgroup is missing for rootless #2634
Conversation
libcontainer/cgroups/utils.go
Outdated
@@ -34,7 +34,9 @@ func IsCgroup2UnifiedMode() bool { | |||
isUnifiedOnce.Do(func() { | |||
var st unix.Statfs_t | |||
if err := unix.Statfs(unifiedMountpoint, &st); err != nil { | |||
panic("cannot statfs cgroup root") | |||
logrus.WithError(err).Debug("cannot statfs cgroup root") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It should be
Info
notDebug
I think as it's pretty major. - Amend the message to say "assuming cgroup v1".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Maybe add a TODO item to change the default to cgroupv2 somewhere in 2024 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, this is partially why I am leaning towards changing the signature to return an error
, otherwise users will get this message 100% of the time exec'ing to a container via buildkit with rootless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does something like this seem more reasonable to you?
err := unix.Statfs(unifiedMountpoint, &st)
if err != nil && os.IsNotExist(err) {
// /sys/fs/cgroup not found, likely rootless
logrus.WithError(err).Debugf("%s missing, assuming cgroup v1", unifiedMountpoint)
isUnified = false
return
} else if err != nil {
panic(fmt.Sprintf("cannot statfs cgroup root: %s", err))
}
This would preserve the panic behavior for all error scenarios except where the /sys/fs/cgroup
path simply does not exist (which is a normal situation under rootless)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also better to panic when os.IsNotExist && !system.RunningInUserNS()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the check to only ignore (w/ debug msg) errors for NotExists while RunningInUserNS
@AkihiroSuda PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
92a85a0
to
4a75408
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple of nits
The test failure (timeout) seems unrelated to my change, and Travis is not allowing me to retry the build. |
Signed-off-by: Cory Bennett <[email protected]>
I squashed and forced push, tests passed after the push this time. I think I have addressed all the feedback, so hopefully we can get this merged in. |
ping @kolyshkin @cyphar @mrunalp |
@kolyshkin @cyphar @mrunalp PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Fixes issue #2573
Downgrade the panic to a debug message when /sys/fs/cgroup is missing. This issue is preventing runc exec from working within buildkit when running rootless (where /sys is not mounted at all).
Steps to reproduce:
now in separate shell:
A potentially better solution is to change the signature from:
to:
so that we can manage the error more directly in rootless mode, but the diff for this change would be much larger, since the function is used quite a lot. I can update is this direction is preferred.