hashicorp/nomad · error

failed to create mount point: %w

Error message

failed to create mount point: %w

What it means

In the CSI plugin supervisor Prestart hook, Nomad creates the host mount point directory (0700) that the plugin container will access; if os.MkdirAll fails with any error other than already-exists, Prestart aborts with 'failed to create mount point: %w'. This directory is required before the plugin task's mounts are wired, so failing it prevents the CSI plugin task from starting.

Source

Thrown at client/allocrunner/taskrunner/plugin_supervisor_hook.go:160

	return hook
}

func (*csiPluginSupervisorHook) Name() string {
	return "csi_plugin_supervisor"
}

// Prestart is called before the task is started including after every
// restart. This requires that the mount paths for a plugin be
// idempotent, despite us not knowing the name of the plugin ahead of
// time.  Because of this, we use the allocid_taskname as the unique
// identifier for a plugin on the filesystem.
func (h *csiPluginSupervisorHook) Prestart(ctx context.Context,
	req *interfaces.TaskPrestartRequest, resp *interfaces.TaskPrestartResponse) error {

	// Create the mount directory that the container will access if it doesn't
	// already exist. Default to only nomad user access.
	if err := os.MkdirAll(h.mountPoint, 0700); err != nil && !os.IsExist(err) {
		return fmt.Errorf("failed to create mount point: %w", err)
	}

	if err := os.MkdirAll(h.socketMountPoint, 0700); err != nil && !os.IsExist(err) {
		return fmt.Errorf("failed to create socket mount point: %w", err)
	}

	// where the socket will be mounted
	configMount := &drivers.MountConfig{
		TaskPath:        h.task.CSIPluginConfig.MountDir,
		HostPath:        h.socketMountPoint,
		Readonly:        false,
		PropagationMode: "bidirectional",
	}
	// where the staging and per-alloc directories will be mounted
	volumeStagingMounts := &drivers.MountConfig{
		TaskPath:        h.task.CSIPluginConfig.StagePublishBaseDir,
		HostPath:        h.mountPoint,
		Readonly:        false,

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Check ownership/permissions of the client's data/alloc directories and ensure the nomad agent user can create dirs there
  2. Verify the host filesystem is not read-only (dmesg/mount output) and has free space
  3. Remove any non-directory file occupying the mount point path
  4. If SELinux/AppArmor is enforcing, add appropriate rules or set the correct context for the nomad data dir

Example fix

# before
$ ls -ld /opt/nomad
 dr-xr-xr-x root root /opt/nomad
# after
$ sudo chown nomad:nomad /opt/nomad && sudo chmod u+w /opt/nomad
Defensive patterns

Strategy: retry

Validate before calling

// host-side precheck before starting nomad client
sudo -u nomad mkdir -p /path/to/mountPoint || echo "mkdir failed; fix perms"

Try / catch

// client hook: retry Prestart after repairing host dir
if strings.Contains(err.Error(), "failed to create mount point") {
    fixHostDirOwnership(); retryAlloc()
}

Prevention

When it happens

Trigger: os.MkdirAll(h.mountPoint, 0700) returns a non-IsExist error — permission denied on the host path, read-only filesystem, parent path is a file, or disk/SELinux restrictions

Common situations: Host data dir owned by another user after upgrading/running nomad as different user, /var permissions or SELinux/AppArmor blocking mkdir, node disk mounted read-only, or a stale file existing where the directory should be

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


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