Skip to content

Commit

Permalink
drivers: provide empty implementations of cgroup helpers for non-root…
Browse files Browse the repository at this point in the history
… nomad (#24392)
  • Loading branch information
shoenig authored Nov 7, 2024
1 parent a036b75 commit a0ff073
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/shared/executor/executor_universal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ func (e *UniversalExecutor) configureResourceContainer(
// v1: remove the executor process from the task's cgroups
// v2: let go of the file descriptor of the task's cgroup
var (
deleteCgroup cleanupFunc
moveProcess runningFunc
deleteCgroup = func() {}
moveProcess = func() error { return nil }
)

// manually configure cgroup for cpu / memory constraints
switch cgroupslib.GetMode() {
case cgroupslib.CG1:
if err := e.configureCG1(cgroup, command); err != nil {
return nil, nil, err
return moveProcess, deleteCgroup, err
}
moveProcess, deleteCgroup = e.enterCG1(cgroup, command.CpusetCgroup())
default:
Expand All @@ -162,12 +162,11 @@ func (e *UniversalExecutor) configureResourceContainer(
// get file descriptor of the cgroup made for this task
fd, cleanup, err := e.statCG(cgroup)
if err != nil {
return nil, nil, err
return moveProcess, deleteCgroup, err
}
e.childCmd.SysProcAttr.UseCgroupFD = true
e.childCmd.SysProcAttr.CgroupFD = fd
deleteCgroup = cleanup
moveProcess = func() error { return nil }
}

e.logger.Info("configured cgroup for executor", "pid", pid)
Expand Down

0 comments on commit a0ff073

Please sign in to comment.