{"record":{"id":"0a514fa4b97b353b","repo":"hashicorp/nomad","slug":"error-creating-fifo-v-w","errorCode":null,"errorMessage":"error creating fifo %v: %w","messagePattern":"error creating fifo (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/lib/fifo/fifo_unix.go","lineNumber":24,"sourceCode":"package fifo\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n)\n\n// CreateAndRead creates a fifo at the given path, and returns an open function\n// for reading. For compatibility with windows, the fifo must not exist\n// already.\n//\n// It returns a reader open function that may block until a writer opens\n// so it's advised to run it in a goroutine different from reader goroutine\nfunc CreateAndRead(path string) (func() (io.ReadCloser, error), error) {\n\t// create first\n\tif err := mkfifo(path, 0600); err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating fifo %v: %w\", path, err)\n\t}\n\n\treturn func() (io.ReadCloser, error) {\n\t\treturn OpenReader(path)\n\t}, nil\n}\n\nfunc OpenReader(path string) (io.ReadCloser, error) {\n\tdir := filepath.Dir(path)\n\tbase := filepath.Base(path)\n\n\troot, err := os.OpenRoot(dir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error opening fifo parent directory %q: %w\", dir, err)\n\t}\n\tdefer root.Close()\n\n\t// also uses O_NOFOLLOW under the hood","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/lib/fifo/fifo_unix.go#L6-L42","documentation":"fifo.CreateAndRead creates a named pipe (FIFO) at the given path via mkfifo and returns a reader-opening function. This error wraps a mkfifo failure, so the log-monitoring FIFO for a task's stdout/stderr could not be created and log streaming cannot be set up.","triggerScenarios":"mkfifo(path, 0600) returns EEXIST (file already exists at path from a prior run), EACCES (cannot create in the directory), ENOENT (parent directory missing), or ENAMETOOLONG.","commonSituations":"Stale FIFO left behind after an unclean Nomad client shutdown; alloc directory permissions changed or partially deleted; task working directory on a filesystem that does not support FIFOs (some NFS/overlay configurations); path too long from deep alloc IDs.","solutions":["Remove the stale file at the path and retry (EEXIST); restart the Nomad client so the alloc dir is rebuilt.","Ensure the parent alloc directory exists and is writable by the Nomad agent user.","If the filesystem does not support FIFOs, move the data/alloc directories to a local filesystem (e.g. ext4/xfs) via client data_dir config.","Shorten the path if ENAMETOOLONG (adjust data_dir depth)."],"exampleFix":"// before: stale fifo causes EEXIST\n$ ls /var/lib/nomad/alloc/.../alloc/logs/task.stdout.fifo\n// after: clean stale fifo and restart\n$ sudo rm /var/lib/nomad/alloc/.../alloc/logs/task.stdout.fifo\n$ sudo systemctl restart nomad","handlingStrategy":"try-catch","validationCode":"func fifoCreatable(path string) error {\n  dir := filepath.Dir(path)\n  if st, err := os.Stat(dir); err != nil || !st.IsDir() { return fmt.Errorf(\"dir missing: %s\", dir) }\n  if err := syscall.Access(dir, os.W_OK); err != nil { return err }\n  if _, err := os.Stat(path); err == nil { return fmt.Errorf(\"stale file exists: %s\", path) }\n  return nil\n}","typeGuard":"func fifoSupported(path string) bool {\n  return syscall.Mkfifo(path, 0600) == nil || syscall.Errno(syscall.EEXIST) != syscall.Errno(0)\n}","tryCatchPattern":"openFn, err := fifo.CreateAndRead(path)\nif err != nil {\n  var se syscall.Errno\n  if errors.As(err, &se) && (errors.Is(err, syscall.EEXIST) || errors.Is(err, syscall.ENOENT)) {\n    os.Remove(path) // clear stale fifo\n    os.MkdirAll(filepath.Dir(path), 0755)\n    openFn, err = fifo.CreateAndRead(path)\n  }\n  if err != nil { return err }\n}","preventionTips":["Clean stale FIFOs after unclean client shutdowns (handle EEXIST).","Place data_dir/alloc dirs on a local filesystem that supports FIFOs (ext4/xfs), not restrictive NFS.","Ensure alloc directories exist and are writable by the agent user.","Keep alloc path depth short to avoid ENAMETOOLONG."],"tags":["linux","fifo","filesystem","logging"],"backgroundTag":"fifo-create-failed","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"}