Systemd controller does not work in user space with Delegate=yes services
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- go, linux
- Domain
- operating-systems
Research direction
Start by reproducing the failure with the provided Delegate=yes unit and inspect the cgroups.Load(cgroups.Systemd, cgroups.PidPath(os.Getpid())) and unitGroup.New entry points. Done means a non-root user service with Delegate=yes can create its sub-cgroup without triggering interactive authentication.
Written by the indexing model from the issue text.
Description
According to the documentation for Systemd units, User= units should be able to control subhierarchies under its own control group path as long as they are Delegate=. I have been unable to get this functionality to work with this package.
Consider the following unit mattdaemon.service (remember to substitute $USER with a regular non-root user):
[Unit]
Description=User space delegate test
[Service]
Type=simple
Delegate=yes
User=$USER
ExecStart=/path/to/binary/failor
Assume /path/to/binary contains a binary built with go build from the following source code:
package main
import (
"log"
"os"
"github.com/containerd/cgroups"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
func main() {
// load the cgroup for "this" process -- since we assume we run in a Delegate=yes user unit,
// we can only control subhierarchies beneath this control group
unitGroup, err := cgroups.Load(cgroups.Systemd, cgroups.PidPath(os.Getpid()))
if err != nil {
log.Panicln("Load:", err)
}
// create a subgroup based on cgroup.Cgroups interface
control, err := unitGroup.New("subway", &specs.LinuxResources{})
if err != nil {
// Interactive authentication required
log.Panicln("New:", err)
}
/* if this were a unit test, we would continue by creating a process and adding it to our sub group */
log.Println("Success!") // Only gets printed if Unit is run by root
_ = control // rest of code stubbed
}
Reproduce the bug by starting the unit:
$ sudo systemctl daemon-reload
$ sudo systemctl start mattdaemon.service
$ journalctl -xafe --unit=mattdaemon.service
Journal Output
Nov 03 11:58:55 devthrostur01 failor[23042]: 2017/11/03 11:58:55 New: Interactive authentication required.
Nov 03 11:58:55 devthrostur01 systemd[1]: mattdaemon.service: main process exited, code=exited, status=2/INVALIDARGUMENT
...
We can enable the functionality by removing the User= line from the systemd unit, but this should not be necessary as per the docs (man 5 systemd.resource-control) since we have enabled Delegate=yes.
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 255
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from containerd/cgroups
-
cgroup v1 blkio parser aborts on "(unknown)" device rows, causing all container stats to failPossibly taken @ShravanthReddy claimed this 94 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 72/100
containerd/cgroups#393 ·
-
Add inspection for cgroup v2 CPU quota and periodPossibly taken @linrl3 claimed this 41 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
containerd/cgroups#377 ·
-
support filter subsystem on `cgroup.Stat()` functionPossibly taken @linrl3 claimed this 41 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
containerd/cgroups#370 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
containerd/cgroups#364 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
containerd/cgroups#328 · 1 comment ·
All issues in containerd/cgroups
Similar issues
-
P3 tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
kind/feature needs-triage priority/unprioritized
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NVIDIA/k8s-test-infra#1504 ·
Maintainers usually reply within 1 day
-
Area/Infrastructure Aspect/Infra Resources Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wso2/agent-manager#2717 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
open-policy-agent/opa#9685 · 1 comment ·
Maintainers usually reply within 1 day