hashicorp/nomad · error · ErrCgroupMustBeSet
configureCgroups: %w
Error message
configureCgroups: %w
What it means
configureCgroups (called from newLibcontainerConfig) returns early if ResourceLimits is off; otherwise it requires a stats cgroup name from command.StatsCgroup(). When the cgroup is empty it wraps the sentinel ErrCgroupMustBeSet with this "configureCgroups: " prefix. It means the executor cannot place the task into a cgroup because none was assigned by the driver/client.
Source
Thrown at drivers/shared/executor/executor_linux_cgo.go:782
}
if len(command.Mounts) > 0 {
cfg.Mounts = append(cfg.Mounts, cmdMounts(command.Mounts)...)
}
return nil
}
func (l *LibcontainerExecutor) configureCgroups(cfg *runc.Config, command *ExecCommand) error {
// note: an alloc TR hook pre-creates the cgroup(s) in both v1 and v2
if !command.ResourceLimits {
return nil
}
cg := command.StatsCgroup()
if cg == "" {
return fmt.Errorf("configureCgroups: %w", ErrCgroupMustBeSet)
}
// // set the libcontainer hook for writing the PID to cgroup.procs file
// TODO: this can be cg1 only, right?
// l.configureCgroupHook(cfg, command)
// set the libcontainer memory limits
l.configureCgroupMemory(cfg, command)
// set cgroup v1/v2 specific attributes (cpu, path)
switch cgroupslib.GetMode() {
case cgroupslib.CG1:
return l.configureCG1(cfg, command, cg)
default:
return l.configureCG2(cfg, command, cg)
}
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Ensure the driver allocates and sets the stats cgroup (SetStatsCgroup) before enabling ResourceLimits and calling Launch
- Check client cgroup configuration (cgroups v1/v2 setup, nomad cgroup parent) so cgroup allocation succeeds
- If cgroups are not wanted, disable ResourceLimits in the ExecCommand instead of leaving the cgroup unset
- Report/fix driver ordering: the cgroup must exist before newLibcontainerConfig runs
Defensive patterns
Strategy: validation
Validate before calling
if cmd.ResourceLimits && cmd.StatsCgroup() == "" {
return fmt.Errorf("stats cgroup must be set before Launch when ResourceLimits is enabled")
} Try / catch
if _, err := executor.Launch(cmd); err != nil && strings.Contains(err.Error(), "configureCgroups") && errors.Is(err, executor.ErrCgroupMustBeSet) {
log.Printf("stats cgroup missing: %v — set cgroup before Launch", err)
} Prevention
- Always call SetStatsCgroup (driver side) before enabling ResourceLimits
- Validate client cgroup allocation succeeded before task launch
- Disable ResourceLimits explicitly when cgroup isolation is not desired
- Guard custom executor harnesses to fail fast on empty StatsCgroup
When it happens
Trigger: command.ResourceLimits is true but command.StopsCgroup()/StatsCgroup() returns "" — the driver never called SetStatsCgroup / the cgroup was not allocated for the task before Launch.
Common situations: Driver invoked the executor with ResourceLimits enabled but forgot to assign the stats cgroup (driver bug or ordering issue); cgroup allocation failed silently upstream (cgroups v1/v2 misconfiguration on the client); custom code constructing ExecCommand manually without StatsCgroup.
Related errors
- failed to configure container(%s): %v
- error setting up exec subcommand: %w
- ErrCgroupMustBeSet
- unable to get orphaned task PIDs: %v
- unable to send signal to process %d: %v
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/144fb1dc1d85afc9.
Report an issue: GitHub.