hashicorp/nomad · error

failed to write root partition cpuset: %w

Error message

failed to write root partition cpuset: %w

What it means

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.

Source

Thrown at client/lib/cgroupslib/init.go:158

			if err := writeCG(activation, subtreeFile); err != nil {
				return fmt.Errorf("failed to create nomad cgroup: %w", err)
			}
		}

		//
		// configuring nomad.slice
		//

		if err := mkCG(NomadCgroupParent); err != nil {
			return fmt.Errorf("failed to create nomad cgroup: %w", err)
		}

		if err := writeCG(activation, NomadCgroupParent, subtreeFile); err != nil {
			return fmt.Errorf("failed to set subtree control on nomad cgroup: %w", err)
		}

		if err := writeCG(cores, NomadCgroupParent, cpusetFile); err != nil {
			return fmt.Errorf("failed to write root partition cpuset: %w", err)
		}

		log.Debug("top level partition root nomad.slice cgroup initialized")

		//
		// configuring nomad.slice/share (member)
		//

		if err := mkCG(NomadCgroupParent, SharePartition()); err != nil {
			return fmt.Errorf("failed to create share cgroup: %w", err)
		}

		if err := writeCG(activation, NomadCgroupParent, SharePartition(), subtreeFile); err != nil {
			return fmt.Errorf("failed to set subtree control on cpuset share partition: %w", err)
		}

		log.Debug("partition member nomad.slice/share cgroup initialized")

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Verify the requested cores are a subset of /sys/fs/cgroup/cpuset.cpus.effective and correct the client's cores configuration.
  2. Run the agent with sufficient privileges (root / delegated cgroups) to write cpuset.cpus.
  3. Ensure cgroup.subtree_control on the parent actually contains cpuset (fix any earlier subtree_control failure first).
  4. If cores are offline, bring them online or remove them from the configured cores list.

Example fix

// before (client config)
cores = "0-65"  // includes isolated cores
// after
cores = "0-63"  // subset of cpuset.cpus.effective
Defensive patterns

Strategy: validation

Validate before calling

func coresAllowed(cores string) error {
  effective, err := os.ReadFile("/sys/fs/cgroup/cpuset.cpus.effective")
  if err != nil { return err }
  return validateSubset(cores, strings.TrimSpace(string(effective)))
}

Type guard

func validCoresValue(v string) bool {
  m, _ := regexp.MatchString(`^([0-9]+(-[0-9]+)?)(,[0-9]+(-[0-9]+)?)*$|^$`, v)
  return m
}

Try / catch

if err := cgroupslib.Init(logger, cores); err != nil {
  if strings.Contains(err.Error(), "root partition cpuset") {
    logger.Error("check configured cores vs /sys/fs/cgroup/cpuset.cpus.effective")
  }
  return err
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/e26a40d6a11bb37d. Report an issue: GitHub.