{"record":{"id":"f25f9f14009d151d","repo":"hashicorp/nomad","slug":"failed-to-create-stderr-logfile-for-q-v","errorCode":null,"errorMessage":"failed to create stderr logfile for %q: %v","messagePattern":"failed to create stderr logfile for %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/logmon/logmon.go","lineNumber":157,"sourceCode":"\n\tlogFileSize := int64(cfg.MaxFileSizeMB * 1024 * 1024)\n\tlro, err := logging.NewFileRotator(cfg.LogDir, cfg.StdoutLogFile,\n\t\tcfg.MaxFiles, logFileSize, logger)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create stdout logfile for %q: %v\", cfg.StdoutLogFile, err)\n\t}\n\n\twrapperOut, err := newLogRotatorWrapper(cfg.StdoutFifo, logger, lro)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttl.lro = wrapperOut\n\n\tlre, err := logging.NewFileRotator(cfg.LogDir, cfg.StderrLogFile,\n\t\tcfg.MaxFiles, logFileSize, logger)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create stderr logfile for %q: %v\", cfg.StderrLogFile, err)\n\t}\n\n\twrapperErr, err := newLogRotatorWrapper(cfg.StderrFifo, logger, lre)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttl.lre = wrapperErr\n\n\treturn tl, nil\n\n}\n\n// logRotatorWrapper wraps our log rotator and exposes a pipe that can feed the\n// log rotator data. The processOutWriter should be attached to the process and\n// data will be copied from the reader to the rotator.\ntype logRotatorWrapper struct {\n\tfifoPath          string","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/logmon/logmon.go#L139-L175","documentation":"Analogous to the stdout case, NewTaskLogger creates the stderr file rotator via logging.NewFileRotator; failure to create/open the stderr log file aborts task logger creation with this error naming the stderr log file. The task cannot start logging until both stdout and stderr rotators exist.","triggerScenarios":"NewFileRotator failing for the stderr log file: unwritable or missing LogDir, no disk space, permission errors, or invalid rotation parameters (MaxFiles <= 0, negative size).","commonSituations":"Same environment issues as stdout (read-only volume, quota, wrong ownership) but surfacing on stderr; partial setup where stdout succeeded and stderr failed — often indicates intermittent disk-full conditions.","solutions":["Free disk space / check quotas (ENOSPC is common after stdout already consumed space)","Ensure LogDir exists, is writable, and permits the process user to create the stderr file","Fix rotation config values (positive MaxFiles and MaxFileSizeMB)","Check the wrapped errno to target the exact filesystem problem","Verify SELinux/AppArmor allows file creation in the log dir"],"exampleFix":"// before\nlre, err := logging.NewFileRotator(cfg.LogDir, cfg.StderrLogFile, 0, size, logger) // invalid MaxFiles\n// after\ncfg.MaxFiles = 10 // valid rotation config\nlre, err := logging.NewFileRotator(cfg.LogDir, cfg.StderrLogFile, cfg.MaxFiles, size, logger)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to create stderr logfile for %q: %w\", cfg.StderrLogFile, err)\n}","handlingStrategy":"validation","validationCode":"func ensureLogDirUsable(dir string) error {\n    if err := os.MkdirAll(dir, 0o755); err != nil {\n        return fmt.Errorf(\"log dir not creatable: %w\", err)\n    }\n    probe := filepath.Join(dir, \".probe\")\n    if err := os.WriteFile(probe, []byte(\"x\"), 0o600); err != nil {\n        return fmt.Errorf(\"log dir not writable: %w\", err)\n    }\n    return os.Remove(probe)\n}","typeGuard":null,"tryCatchPattern":"tl, err := NewTaskLogger(cfg)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to create stderr logfile\") {\n        return fmt.Errorf(\"check log_dir permissions and free disk (stdout may have filled it): %w\", err)\n    }\n    return err\n}","preventionTips":["Reserve disk headroom so stderr creation never hits ENOSPC","Use positive MaxFiles/MaxFileSizeMB in logmon config","Run logmon as a user permitted to create files in log_dir","Pre-flight the log dir with a write probe before task start"],"tags":["logging","logmon","filesystem","configuration"],"backgroundTag":"log-file-creation-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"}