hashicorp/nomad · error
failed to create socket mount point: %w
Error message
failed to create socket mount point: %w
What it means
The same Prestart hook also creates h.socketMountPoint (0700) — the host directory where the CSI plugin's socket will be exposed and bind-mounted into the task via MountConfig.HostPath. Failure of os.MkdirAll (other than already-exists) aborts with 'failed to create socket mount point: %w', preventing plugin registration.
Source
Thrown at client/allocrunner/taskrunner/plugin_supervisor_hook.go:164
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,
PropagationMode: "bidirectional",
}
// devices from the host
devMount := &drivers.MountConfig{View on GitHub (pinned to 482b49bf1a)
Solutions
- Inspect and fix permissions on the socket mount path's parents so the nomad user can create directories
- Delete any non-directory file occupying the path and restart the allocation
- Check mount/SELinux status; ensure the filesystem is writable and security policy allows the nomad data dir
- Restart the nomad client agent to recreate clean alloc hook state if the path is managed internally
Example fix
# before $ file /var/lib/nomad/alloc/<id>/csi /var/lib/nomad/alloc/<id>/csi: ASCII text (stale file) # after $ sudo rm /var/lib/nomad/alloc/<id>/csi && nomad alloc stop <alloc>
Defensive patterns
Strategy: retry
Validate before calling
// host-side precheck for socket mount point sudo -u nomad test -w "$(dirname socketMountPoint)" && echo ok
Try / catch
// on failure, clean stale path and restart the allocation
if strings.Contains(err.Error(), "failed to create socket mount point") {
removeStalePath(); nomadAllocStopRestart()
} Prevention
- Clean up leftover alloc dirs after crashed runs
- Ensure consistent nomad agent user across upgrades
- Whitelist nomad data dir in SELinux/AppArmor policies
- Monitor disk writability on CSI-capable nodes
When it happens
Trigger: os.MkdirAll(h.socketMountPoint, 0700) fails non-IsExist — permission denied, read-only FS, path component is a regular file, container runtime/SELinux restrictions on the socket path
Common situations: Stale file at the socket mount path from a previous crashed run, nomad agent running as a different user than before, enforced security modules blocking mkdir under the alloc dir, full or read-only client disk
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- failed to create mount point: %w
- plugin not executable
- failed to snapshot %s: %w
- error creating task %q dir: %w
- Couldn't open src file %v: %w
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/edcc9739ac19d15f.
Report an issue: GitHub.