{"record":{"id":"e26a40d6a11bb37d","repo":"hashicorp/nomad","slug":"failed-to-write-root-partition-cpuset-w","errorCode":null,"errorMessage":"failed to write root partition cpuset: %w","messagePattern":"failed to write root partition cpuset: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/lib/cgroupslib/init.go","lineNumber":158,"sourceCode":"\t\t\tif err := writeCG(activation, subtreeFile); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to create nomad cgroup: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\t//\n\t\t// configuring nomad.slice\n\t\t//\n\n\t\tif err := mkCG(NomadCgroupParent); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create nomad cgroup: %w\", err)\n\t\t}\n\n\t\tif err := writeCG(activation, NomadCgroupParent, subtreeFile); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set subtree control on nomad cgroup: %w\", err)\n\t\t}\n\n\t\tif err := writeCG(cores, NomadCgroupParent, cpusetFile); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write root partition cpuset: %w\", err)\n\t\t}\n\n\t\tlog.Debug(\"top level partition root nomad.slice cgroup initialized\")\n\n\t\t//\n\t\t// configuring nomad.slice/share (member)\n\t\t//\n\n\t\tif err := mkCG(NomadCgroupParent, SharePartition()); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create share cgroup: %w\", err)\n\t\t}\n\n\t\tif err := writeCG(activation, NomadCgroupParent, SharePartition(), subtreeFile); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set subtree control on cpuset share partition: %w\", err)\n\t\t}\n\n\t\tlog.Debug(\"partition member nomad.slice/share cgroup initialized\")\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/lib/cgroupslib/init.go#L140-L176","documentation":"After enabling subtree control on nomad.slice, Init() writes the cpuset.cpus file of the root nomad.slice cgroup with the set of cores Nomad is configured to use. Failure here means the root partition's CPU set could not be established, so per-task cpuset assignment cannot proceed.","triggerScenarios":"os.WriteFile of /sys/fs/cgroup/nomad.slice/cpuset.cpus fails — EACCES (no write permission), EINVAL (the cores value contains cores not allowed by the parent cpuset.cpus, e.g. isolated or offline cores), or ENOENT (cpuset controller not activated).","commonSituations":"A cores value in Nomad config includes cores excluded by the system's root cpuset.cpus (e.g. kernel-isolated cores via isolcpus, or cores offline); the cpuset controller was never enabled on nomad.slice; agent lacking cgroup write privileges.","solutions":["Verify the requested cores are a subset of /sys/fs/cgroup/cpuset.cpus.effective and correct the client's cores configuration.","Run the agent with sufficient privileges (root / delegated cgroups) to write cpuset.cpus.","Ensure cgroup.subtree_control on the parent actually contains cpuset (fix any earlier subtree_control failure first).","If cores are offline, bring them online or remove them from the configured cores list."],"exampleFix":"// before (client config)\ncores = \"0-65\"  // includes isolated cores\n// after\ncores = \"0-63\"  // subset of cpuset.cpus.effective","handlingStrategy":"validation","validationCode":"func coresAllowed(cores string) error {\n  effective, err := os.ReadFile(\"/sys/fs/cgroup/cpuset.cpus.effective\")\n  if err != nil { return err }\n  return validateSubset(cores, strings.TrimSpace(string(effective)))\n}","typeGuard":"func validCoresValue(v string) bool {\n  m, _ := regexp.MatchString(`^([0-9]+(-[0-9]+)?)(,[0-9]+(-[0-9]+)?)*$|^$`, v)\n  return m\n}","tryCatchPattern":"if err := cgroupslib.Init(logger, cores); err != nil {\n  if strings.Contains(err.Error(), \"root partition cpuset\") {\n    logger.Error(\"check configured cores vs /sys/fs/cgroup/cpuset.cpus.effective\")\n  }\n  return err\n}","preventionTips":["Configure cores strictly as a subset of /sys/fs/cgroup/cpuset.cpus.effective.","Exclude kernel-isolated (isolcpus) and offline cores from client config.","Ensure the cpuset controller is enabled on the parent before writing cpuset.cpus.","Run with privileges sufficient to write cgroup files."],"tags":["linux","cgroups","cgroupv2","cpuset"],"backgroundTag":"cgroup-cpuset-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"}