Skip to content

added support for rootless mode (userns + systemd cgroupsv2 delegation)#345

Open
m0mosenpai wants to merge 18 commits intoopen-lambda:mainfrom
m0mosenpai:cgroups
Open

added support for rootless mode (userns + systemd cgroupsv2 delegation)#345
m0mosenpai wants to merge 18 commits intoopen-lambda:mainfrom
m0mosenpai:cgroups

Conversation

@m0mosenpai
Copy link
Contributor

@m0mosenpai m0mosenpai commented Oct 8, 2025

Testing:

  1. Test normal functionality with root (till fakeroot changes are merged)
  2. Test normal functionality without root (after fakeroot changes are merged)
  3. Test cleanup - cgroup files are being properly cleaned in normal shutdown, force shutdown and force-kill scenarios

Copy link
Member

@tylerharter tylerharter left a comment

Choose a reason for hiding this comment

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

Good work!

Copy link
Member

@tylerharter tylerharter left a comment

Choose a reason for hiding this comment

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

Great work!

return fmt.Errorf("failed to chmod base dir: %v", err)
}

// For rootless mode: if run with sudo, give olPath and worker dir to actual user
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little confused, why would somebody want rootless and then use sudo? Why is that a scenario we have to support instead of just doing the simplest thing possible (e.g., returning an error)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tylerharter I fixed the permissions above (reverted them back to 700s so the files are not visible to everyone else). But the base directory is created with 700 permission and since we sudo ./ol worker init, ./ol worker up doesn't work without root.

This changes was meant to give the ownership to the real user so ./ol worker up can work without issues. I'm not sure if there's a better way to get around this.

},
}
if rootless {
attr.Sys = &syscall.SysProcAttr{
Copy link
Member

Choose a reason for hiding this comment

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

This code is the crux of what you're doing. I think it needs some more commenting. E.g., will it be obvious to people that "0" is the ID for root? Also need to explain what a user namespace is, and why that lets us run rootless.

return "/sys/fs/cgroup"
}

panic(fmt.Errorf("systemd user cgroup delegation not available - cannot run rootless"))
Copy link
Member

Choose a reason for hiding this comment

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

I think instead of trying to integrate with systemd directly, I think it is more flexible if we let users configure the root cgroup to use. We can provide instructions for users to run "systemctl show --user --property=ControlGroup" and find this location and configure their OL accordingly.

@m0mosenpai m0mosenpai changed the title added systemd user cgroup delegation support for rootless mode added support for rootless mode (userns + systemd cgroupsv2 delegation) Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants