{"record":{"id":"700abf347aba1bfe","repo":"hashicorp/nomad","slug":"failed-to-set-cpuset-w","errorCode":null,"errorMessage":"failed to set cpuset: %w","messagePattern":"failed to set cpuset: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor_linux_cgo.go","lineNumber":834,"sourceCode":"}\n\nfunc (l *LibcontainerExecutor) configureCG1(cfg *runc.Config, command *ExecCommand, cgroup string) error {\n\n\tcpuShares := l.clampCpuShares(command.Resources.LinuxResources.CPUShares)\n\tcpusetPath := command.Resources.LinuxResources.CpusetCgroupPath\n\tcpuCores := command.Resources.LinuxResources.CpusetCpus\n\n\t// Set the v1 parent relative path (i.e. /nomad/<scope>) for the NON-cpuset cgroups\n\tscope := filepath.Base(cgroup)\n\tcfg.Cgroups.Path = filepath.Join(\"/\", cgroupslib.NomadCgroupParent, scope)\n\n\t// set cpu resources\n\tcfg.Cgroups.Resources.CpuShares = uint64(cpuShares)\n\n\t// we need to manually set the cpuset, because libcontainer will not set\n\t// it for our special cpuset cgroup\n\tif err := l.cpusetCG1(cpusetPath, cpuCores); err != nil {\n\t\treturn fmt.Errorf(\"failed to set cpuset: %w\", err)\n\t}\n\n\t// tell libcontainer to write the pid to our special cpuset cgroup\n\tl.configureCgroupHook(cfg, command)\n\n\treturn nil\n}\n\nfunc (l *LibcontainerExecutor) cpusetCG1(cpusetCgroupPath, cores string) error {\n\tif cores == \"\" {\n\t\treturn nil\n\t}\n\ted := cgroupslib.OpenPath(cpusetCgroupPath)\n\treturn ed.Write(\"cpuset.cpus\", cores)\n}\n\nfunc (l *LibcontainerExecutor) configureCG2(cfg *runc.Config, command *ExecCommand, cg string) error {\n\tcpuShares := l.clampCpuShares(command.Resources.LinuxResources.CPUShares)","sourceCodeStart":816,"sourceCodeEnd":852,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_linux_cgo.go#L816-L852","documentation":"This error wraps a failure from cpusetCG1, which writes the CPU set (allowed CPU cores) to the cpuset cgroup v1 controller for a Nomad task. Nomad sets cpuset manually because libcontainer will not write it for Nomad's special cpuset cgroup. The underlying error typically indicates the cpuset cgroup file could not be opened or written.","triggerScenarios":"configureCG1 runs during task launch when configureCgroups initializes cgroup v1 resources; it triggers when the cpuset.cpus file for the task's cgroup cannot be written, e.g. missing cgroup filesystem, no writable cpuset controller, or invalid CPU mask.","commonSituations":"Host without cpuset cgroup v1 controller mounted or delegated (common in containers/CI without privileged cgroup access); cgroup v2-only hosts; selinux/read-only /sys/fs/cgroup; running Nomad client in Docker without cgroup namespace privileges.","solutions":["Verify cpuset cgroup v1 controller is mounted and writable (check /sys/fs/cgroup/cpuset) on the host","Run the Nomad client with the required cgroup privileges (privileged container, cgroup mounts delegated)","Confirm the task's cpu.cores value produces a valid CPU mask that exists on the host","Consider cgroups v2 or a plugin driver if the host does not use cgroup v1"],"exampleFix":"// before (client in Docker without cgroup access)\ndocker run hashicorp/nomad agent -dev\n// after\ndocker run --privileged -v /sys/fs/cgroup:/sys/fs/cgroup hashicorp/nomad agent -dev","handlingStrategy":"validation","validationCode":"// before launching tasks on a client node:\nif _, err := os.Stat(\"/sys/fs/cgroup/cpuset\"); err != nil {\n    // node lacks cpuset cgroup v1; don't schedule cgroup tasks here\n}","typeGuard":null,"tryCatchPattern":"if err := executor.Launch(lctx, cmd); err != nil {\n    if strings.Contains(err.Error(), \"failed to set cpuset\") {\n        // mark node cgroup-v1 incompatible, reschedule elsewhere\n    }\n}","preventionTips":["Run Nomad clients with cgroup v1 controllers mounted and writable","In containerized clients use --privileged and mount /sys/fs/cgroup","Pin tasks to nodes with verified cgroup capabilities via constraints"],"tags":["cgroups","linux","executor"],"backgroundTag":"cgroup-write-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}