{"record":{"id":"144fb1dc1d85afc9","repo":"hashicorp/nomad","slug":"configurecgroups-w","errorCode":null,"errorMessage":"configureCgroups: %w","messagePattern":"configureCgroups: %w","errorType":"exception","errorClass":"ErrCgroupMustBeSet","httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor_linux_cgo.go","lineNumber":782,"sourceCode":"\t}\n\n\tif len(command.Mounts) > 0 {\n\t\tcfg.Mounts = append(cfg.Mounts, cmdMounts(command.Mounts)...)\n\t}\n\n\treturn nil\n}\n\nfunc (l *LibcontainerExecutor) configureCgroups(cfg *runc.Config, command *ExecCommand) error {\n\t// note: an alloc TR hook pre-creates the cgroup(s) in both v1 and v2\n\n\tif !command.ResourceLimits {\n\t\treturn nil\n\t}\n\n\tcg := command.StatsCgroup()\n\tif cg == \"\" {\n\t\treturn fmt.Errorf(\"configureCgroups: %w\", ErrCgroupMustBeSet)\n\t}\n\n\t// // set the libcontainer hook for writing the PID to cgroup.procs file\n\t// TODO: this can be cg1 only, right?\n\t// l.configureCgroupHook(cfg, command)\n\n\t// set the libcontainer memory limits\n\tl.configureCgroupMemory(cfg, command)\n\n\t// set cgroup v1/v2 specific attributes (cpu, path)\n\tswitch cgroupslib.GetMode() {\n\tcase cgroupslib.CG1:\n\t\treturn l.configureCG1(cfg, command, cg)\n\tdefault:\n\t\treturn l.configureCG2(cfg, command, cg)\n\t}\n}\n","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_linux_cgo.go#L764-L800","documentation":"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.","triggerScenarios":"command.ResourceLimits is true but command.StopsCgroup()/StatsCgroup() returns \"\" — the driver never called SetStatsCgroup / the cgroup was not allocated for the task before Launch.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if cmd.ResourceLimits && cmd.StatsCgroup() == \"\" {\n    return fmt.Errorf(\"stats cgroup must be set before Launch when ResourceLimits is enabled\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := executor.Launch(cmd); err != nil && strings.Contains(err.Error(), \"configureCgroups\") && errors.Is(err, executor.ErrCgroupMustBeSet) {\n    log.Printf(\"stats cgroup missing: %v — set cgroup before Launch\", err)\n}","preventionTips":["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"],"tags":["cgroups","configuration","executor","libcontainer"],"backgroundTag":"cgroup-must-be-set","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}