hashicorp/nomad · critical

failed to create share cpuset partition: %w

Error message

failed to create share cpuset partition: %w

What it means

During cgroupslib.Init in CG1 mode, creating the share cpuset partition directory (/sys/fs/cgroup/cpuset/<nomad-parent>/share) via os.MkdirAll failed. This directory holds the cgroup in which all tasks using shared (non-reserved) cores are placed. Common causes are permission errors or the parent cpuset controller not being mounted/available.

Source

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

		if err := writeCG(noClone, "cpuset", NomadCgroupParent, cloneFile); err != nil {
			return fmt.Errorf("failed to set clone_children on nomad cpuset cgroup: %w", err)
		}

		if err := writeCG(memsSet, "cpuset", NomadCgroupParent, memsFile); err != nil {
			return fmt.Errorf("failed to set cpuset.mems on nomad cpuset cgroup: %w", err)
		}

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

		//
		// share partition
		//

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

		if err := writeCG(noClone, "cpuset", NomadCgroupParent, SharePartition(), cloneFile); err != nil {
			return fmt.Errorf("failed to set clone_children on nomad cpuset cgroup: %w", err)
		}

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

		//
		// reserve partition
		//

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

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Run the Nomad client as root or with capabilities to create cgroup directories.
  2. Confirm /sys/fs/cgroup/cpuset/<parent> exists and is writable (ls -la, try mkdir manually).
  3. Remount cgroup filesystem rw in containers (or use cgroupns=host / privileged mode).
  4. Remove any stale file blocking the share directory path.
Defensive patterns

Strategy: validation

Validate before calling

test -d /sys/fs/cgroup/cpuset || echo "cgroup v1 cpuset controller missing on this host"
test -w /sys/fs/cgroup/cpuset/nomad || echo "nomad cpuset parent not writable"
mkdir -p /sys/fs/cgroup/cpuset/nomad/share 2>&1 # dry-run check as the same user

Try / catch

if err := cgroupslib.Init(logger, cores); err != nil {
    if strings.Contains(err.Error(), "share cpuset partition") {
        return fmt.Errorf("cannot create cgroup dirs; run as root on cgroup v1 host: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: mkCG("cpuset", NomadCgroupParent, SharePartition()) fails during Init CG1, after the parent cpuset cgroup's clone_children/mems/cpus were configured.

Common situations: Agent running without root; cgroupfs mounted read-only; cgroup v2 host where /sys/fs/cgroup/cpuset does not exist; hit by mkdir EEXIST edge cases with a stale non-directory file at the path.

Related errors


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