{"record":{"id":"8629c786ee2de5f1","repo":"hashicorp/nomad","slug":"cgroupslib-unable-to-update-share-cpuset-with-q","errorCode":null,"errorMessage":"cgroupslib: unable to update share cpuset with %q: %w","messagePattern":"cgroupslib: unable to update share cpuset with %q: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/lib/cgroupslib/partition_linux.go","lineNumber":112,"sourceCode":"\treturn p.write()\n}\n\nfunc (p *partition) Release(cores *idset.Set[hw.CoreID]) error {\n\n\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":94,"sourceCodeEnd":121,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/lib/cgroupslib/partition_linux.go#L94-L121","documentation":"partition.write() persists the dynamic share cpuset by writing the current set of shared cores to nomad.slice/share/cpuset.cpus (cgroups v2) when cores are reserved or released. This error wraps an os.WriteFile failure on that cpuset file, meaning the core partition state could not be synced to the kernel.","triggerScenarios":"os.WriteFile(p.sharePath, ...) fails during Reserve() or Release() — EACCES (lost cgroup write privileges), ENOENT (share cgroup directory removed or Init never ran), or EINVAL when the value is empty or contains cores outside the allowed parent cpuset.","commonSituations":"Releasing/reserving cores on a client whose cgroups were wiped (e.g. host rebooted and nomad.slice removed); Nomad process dropped privileges after startup; writing an empty core list after reserving all cores; manual deletion of share cgroup by an operator.","solutions":["Re-run cgroupslib Init to recreate the cgroup tree, then retry the Reserve/Release operation.","Ensure the agent still has write access to /sys/fs/cgroup/nomad.slice/share/cpuset.cpus (root / delegation intact).","Verify the share cpuset value is non-empty and within cpuset.cpus.effective; never reserve all cores, leaving share empty.","If the error is EINVAL, check for kernel-isolated/offline cores excluded from the usable set."],"exampleFix":"// before: reserving all cores empties share cpuset\nerr := partition.Reserve(allCores)\n// after: keep at least one core in the share set\nshare := allCores.Diff(lastCore)\nerr := partition.Reserve(lastCore) // share keeps remaining cores","handlingStrategy":"retry","validationCode":"func sharePathOK(p string) error {\n  if _, err := os.Stat(p); err != nil { return err }\n  return syscall.Access(p, syscall.W_OK)\n}","typeGuard":"func shareCpusetValid(share *idset.Set[hw.CoreID], usable *idset.Set[hw.CoreID]) bool {\n  return share != nil && !share.Intersect(usable).Empty()\n}","tryCatchPattern":"if err := partition.Reserve(cores); err != nil {\n  var perr *fs.PathError\n  if errors.As(err, &perr) {\n    // cgroup tree missing: re-init once, then retry\n    if err := cgroupslib.Init(logger, coresStr); err != nil { return err }\n    return partition.Reserve(cores)\n  }\n  return err\n}","preventionTips":["Never reserve every usable core; keep the share cpuset non-empty.","Ensure client Init ran after any host reboot before reserving cores.","Verify the agent retains cgroup write privileges (root/delegation).","Don't manually delete nomad.slice/share while the client is running."],"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"}