{"record":{"id":"fd0d99519eaaf07b","repo":"hashicorp/nomad","slug":"failed-to-create-mount-point-w","errorCode":null,"errorMessage":"failed to create mount point: %w","messagePattern":"failed to create mount point: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocrunner/taskrunner/plugin_supervisor_hook.go","lineNumber":160,"sourceCode":"\treturn hook\n}\n\nfunc (*csiPluginSupervisorHook) Name() string {\n\treturn \"csi_plugin_supervisor\"\n}\n\n// Prestart is called before the task is started including after every\n// restart. This requires that the mount paths for a plugin be\n// idempotent, despite us not knowing the name of the plugin ahead of\n// time.  Because of this, we use the allocid_taskname as the unique\n// identifier for a plugin on the filesystem.\nfunc (h *csiPluginSupervisorHook) Prestart(ctx context.Context,\n\treq *interfaces.TaskPrestartRequest, resp *interfaces.TaskPrestartResponse) error {\n\n\t// Create the mount directory that the container will access if it doesn't\n\t// already exist. Default to only nomad user access.\n\tif err := os.MkdirAll(h.mountPoint, 0700); err != nil && !os.IsExist(err) {\n\t\treturn fmt.Errorf(\"failed to create mount point: %w\", err)\n\t}\n\n\tif err := os.MkdirAll(h.socketMountPoint, 0700); err != nil && !os.IsExist(err) {\n\t\treturn fmt.Errorf(\"failed to create socket mount point: %w\", err)\n\t}\n\n\t// where the socket will be mounted\n\tconfigMount := &drivers.MountConfig{\n\t\tTaskPath:        h.task.CSIPluginConfig.MountDir,\n\t\tHostPath:        h.socketMountPoint,\n\t\tReadonly:        false,\n\t\tPropagationMode: \"bidirectional\",\n\t}\n\t// where the staging and per-alloc directories will be mounted\n\tvolumeStagingMounts := &drivers.MountConfig{\n\t\tTaskPath:        h.task.CSIPluginConfig.StagePublishBaseDir,\n\t\tHostPath:        h.mountPoint,\n\t\tReadonly:        false,","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocrunner/taskrunner/plugin_supervisor_hook.go#L142-L178","documentation":"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.","triggerScenarios":"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","commonSituations":"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","solutions":["Check ownership/permissions of the client's data/alloc directories and ensure the nomad agent user can create dirs there","Verify the host filesystem is not read-only (dmesg/mount output) and has free space","Remove any non-directory file occupying the mount point path","If SELinux/AppArmor is enforcing, add appropriate rules or set the correct context for the nomad data dir"],"exampleFix":"# before\n$ ls -ld /opt/nomad\n dr-xr-xr-x root root /opt/nomad\n# after\n$ sudo chown nomad:nomad /opt/nomad && sudo chmod u+w /opt/nomad","handlingStrategy":"retry","validationCode":"// host-side precheck before starting nomad client\nsudo -u nomad mkdir -p /path/to/mountPoint || echo \"mkdir failed; fix perms\"","typeGuard":null,"tryCatchPattern":"// client hook: retry Prestart after repairing host dir\nif strings.Contains(err.Error(), \"failed to create mount point\") {\n    fixHostDirOwnership(); retryAlloc()\n}","preventionTips":["Keep client data/alloc dirs owned by the nomad agent user","Monitor for read-only or full filesystems on clients","Do not place files where plugin mount dirs are created","Test SELinux/AppArmor policy changes against nomad dirs"],"tags":["filesystem","csi","permissions"],"backgroundTag":"mkdir-permission-denied","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"}