{"record":{"id":"529fbffc33bdda12","repo":"hashicorp/nomad","slug":"unable-to-write-to-custom-cgroup-v","errorCode":null,"errorMessage":"unable to write to custom cgroup: %v","messagePattern":"unable to write to custom cgroup: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/shared/executor/executor_universal_linux.go","lineNumber":197,"sourceCode":"}\n\nfunc (e *UniversalExecutor) configureCG1(cgroup string, command *ExecCommand) error {\n\t// some drivers like qemu entirely own resource management\n\tif command.Resources == nil || command.Resources.LinuxResources == nil {\n\t\treturn nil\n\t}\n\n\t// if custom cgroups are set join those instead of configuring the /nomad\n\t// cgroups we are not going to use\n\tif len(e.command.OverrideCgroupV1) > 0 {\n\t\tpid := unix.Getpid()\n\t\tfor controller, path := range e.command.OverrideCgroupV1 {\n\t\t\tabsPath := cgroupslib.CustomPathCG1(controller, path)\n\t\t\ted := cgroupslib.OpenPath(absPath)\n\t\t\terr := ed.Write(\"cgroup.procs\", strconv.Itoa(pid))\n\t\t\tif err != nil {\n\t\t\t\te.logger.Error(\"unable to write to custom cgroup\", \"error\", err)\n\t\t\t\treturn fmt.Errorf(\"unable to write to custom cgroup: %v\", err)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\t// write memory limits\n\tmemHard, memReserved := memoryLimits(command.Resources.NomadResources.Memory)\n\ted := cgroupslib.OpenFromFreezerCG1(cgroup, \"memory\")\n\t_ = ed.Write(\"memory.limit_in_bytes\", strconv.FormatInt(memHard, 10))\n\tif memReserved > 0 {\n\t\t_ = ed.Write(\"memory.soft_limit_in_bytes\", strconv.FormatInt(memReserved, 10))\n\t}\n\n\t// write memory swappiness\n\tswappiness := cgroupslib.MaybeDisableMemorySwappiness()\n\tif swappiness != nil {\n\t\tvalue := int64(*swappiness)\n\t\t_ = ed.Write(\"memory.swappiness\", strconv.FormatInt(value, 10))","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/shared/executor/executor_universal_linux.go#L179-L215","documentation":"configureCG1 writes the executor process PID into each cgroup v1 controller path the command overrides via OverrideCgroupV1. If writing cgroup.procs fails for any custom path, the error is logged and returned wrapped. It means a user-specified custom cgroup could not accept the process.","triggerScenarios":"Task/driver config sets OverrideCgroupV1 with controller->path pairs; configureResourceContainer -> configureCG1 then tries to echo the PID into <abs>/cgroup.procs and the write fails (path missing, permissions, controller not mounted).","commonSituations":"Operator typo in custom cgroup path; cgroup path created by an external system not yet present at task start; permissions/delegation missing for the Nomad user; controller (e.g. hugetlb) not mounted on the node.","solutions":["Verify each OverrideCgroupV1 path exists on the node and the controller is mounted (cgroupslib.CustomPathCG1 layout)","Grant the Nomad client user write access (ownership/permissions) to the custom cgroup directories","Create the custom cgroup before the task starts (systemd slice/cgcreate) and fix the config typo","Remove the override if the controller is unavailable on this host"],"exampleFix":"// before\nOverrideCgroupV1 = {\"hugetlb\": \"nomad/custom\"}  # hugetlb not mounted\n// after\n# cgcreate -g hugetlb:/nomad/custom  (or drop the override)\nOverrideCgroupV1 = {\"memory\": \"nomad/custom\"}","handlingStrategy":"validation","validationCode":"for _, path := range overrideCgroups {\n    abs := cgroupslib.CustomPathCG1(controller, path)\n    if _, err := os.Stat(filepath.Join(abs, \"cgroup.procs\")); err != nil {\n        return fmt.Errorf(\"custom cgroup %s unavailable\", abs)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"unable to write to custom cgroup\") {\n    // path is in client logs; create/fix the cgroup then reschedule\n    return fmt.Errorf(\"fix OverrideCgroupV1 config: %w\", err)\n}","preventionTips":["Pre-create custom cgroups (cgcreate/systemd) before tasks run","Grant the Nomad user write access to override cgroup dirs","Only override controllers actually mounted on the node"],"tags":["cgroups","cgroup-v1","configuration"],"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"}