{"record":{"id":"c57f402e1ac14f48","repo":"hashicorp/nomad","slug":"cgroupslib-unable-to-update-reserve-cpuset-with","errorCode":null,"errorMessage":"cgroupslib: unable to update reserve cpuset with %q: %w","messagePattern":"cgroupslib: unable to update reserve cpuset with %q: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/lib/cgroupslib/partition_linux.go","lineNumber":117,"sourceCode":"\tp.lock.Lock()\n\tdefer p.lock.Unlock()\n\n\tp.reserve.RemoveSet(cores)\n\n\t// Use the intersection with the usable cores to avoid removing more cores than available.\n\tp.share.InsertSet(p.usableCores.Intersect(cores))\n\treturn p.write()\n}\n\nfunc (p *partition) write() error {\n\tshareStr := p.share.String()\n\tif err := os.WriteFile(p.sharePath, []byte(shareStr), 0644); err != nil {\n\t\treturn fmt.Errorf(\"cgroupslib: unable to update share cpuset with %q: %w\", shareStr, err)\n\t}\n\n\treserveStr := p.reserve.String()\n\tif err := os.WriteFile(p.reservePath, []byte(reserveStr), 0644); err != nil {\n\t\treturn fmt.Errorf(\"cgroupslib: unable to update reserve cpuset with %q: %w\", reserveStr, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":99,"sourceCodeEnd":121,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/lib/cgroupslib/partition_linux.go#L99-L121","documentation":"partition.write() also persists the reserved cores into nomad.slice/reserve/cpuset.cpus after updating the share set. This error wraps an os.WriteFile failure on the reserve cpuset file, so kernel state no longer matches Nomad's in-memory core partition (possible drift between share and reserve writes).","triggerScenarios":"os.WriteFile(p.reservePath, ...) fails during Reserve() or Release() — EACCES, ENOENT (reserve cgroup missing, e.g. Init not run or tree deleted), or EINVAL (core values invalid for the parent cpuset; an empty reserve string may also be rejected by some kernels).","commonSituations":"Client started without successful cgroup Init; operator manually removed nomad.slice/reserve; cgroup privileges lost (container runtime restrictions); reservation of cores whose ids are not present on the machine.","solutions":["Re-initialize the cgroup tree (cgroupslib Init) so nomad.slice/reserve and its cpuset.cpus exist.","Ensure write access to /sys/fs/cgroup/nomad.slice/reserve/cpuset.cpus (root or delegated cgroups).","Confirm the reserved cores are within the parent's cpuset.cpus.effective and offline cores are excluded.","Restart the Nomad client to rebuild partition state if share/reserve writes are out of sync."],"exampleFix":"// before: operator deleted the cgroup\n$ sudo rm -rf /sys/fs/cgroup/nomad.slice/reserve\n// after: restart nomad client so Init recreates the tree\n$ sudo systemctl restart nomad","handlingStrategy":"retry","validationCode":"func reservePathOK(p string) error {\n  if _, err := os.Stat(p); err != nil { return err }\n  return syscall.Access(p, syscall.W_OK)\n}","typeGuard":"func reserveCoresUsable(reserve *idset.Set[hw.CoreID], usable *idset.Set[hw.CoreID]) bool {\n  return usable.ContainsSet(reserve)\n}","tryCatchPattern":"if err := partition.Release(cores); err != nil {\n  if strings.Contains(err.Error(), \"reserve cpuset\") {\n    // rebuild kernel state from in-memory partition\n    if err := cgroupslib.Init(logger, coresStr); err != nil { return err }\n    return partition.Release(cores)\n  }\n  return err\n}","preventionTips":["Re-run Init after host reboots or cgroup tree wipes before Reserve/Release.","Validate reserved cores are within cpuset.cpus.effective (no offline/isolated cores).","Keep the agent privileged enough to write cgroup files.","Restart the client if reserve/share writes ever become inconsistent."],"tags":["linux","cgroups","cpuset","filesystem-permissions"],"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"}