{"record":{"id":"22888dfab4d8f1ee","repo":"GoogleContainerTools/skaffold","slug":"unable-to-create-log-file-for-statuscheck-step-w","errorCode":null,"errorMessage":"unable to create log file for statuscheck step: %w","messagePattern":"unable to create log file for statuscheck step: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/kubernetes/status/resource/logfile.go","lineNumber":34,"sourceCode":"\npackage resource\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/logfile\"\n)\n\n// withLogFile returns a multiwriter that writes both to a file and a buffer, with the buffer being written to the provided output buffer in case of error\nfunc withLogFile(container string, out io.Writer, l []string, muted bool) (io.Writer, func([]string), error) {\n\tif !muted || len(l) <= maxLogLines {\n\t\treturn out, func([]string) {}, nil\n\t}\n\tfile, err := logfile.Create(\"statuscheck\", container+\".log\")\n\tif err != nil {\n\t\treturn out, func([]string) {}, fmt.Errorf(\"unable to create log file for statuscheck step: %w\", err)\n\t}\n\n\t// Print logs to a memory buffer and to a file.\n\tvar buf bytes.Buffer\n\tw := io.MultiWriter(file, &buf)\n\n\t// After the status check updates finishes, close the log file.\n\treturn w, func(lines []string) {\n\t\tfile.Close()\n\t\t// Write last few lines to out\n\t\tfor _, l := range lines {\n\t\t\tout.Write([]byte(l))\n\t\t}\n\t\tfmt.Fprintf(out, \"%s %s Full logs at %s\\n\", tab, tab, file.Name())\n\t}, err\n}\n","sourceCodeStart":16,"sourceCodeEnd":51,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/kubernetes/status/resource/logfile.go#L16-L51","documentation":"withLogFile mutes verbose container logs by redirecting them to a file when log lines exceed maxLogLines. If logfile.Create(\"statuscheck\", container+\".log\") fails, the error is wrapped as \"unable to create log file for statuscheck step\". The status check continues printing to the original writer only; full logs are lost from the file.","triggerScenarios":"logfile.Create fails while ReportSinceLastUpdated handles a container with more than maxLogLines log lines and output not muted — caused by an unwritable log directory, disk full, or permission errors.","commonSituations":"Read-only filesystem or HOME not set so the log dir resolves badly; disk quota exceeded in CI; sandboxed environments denying file creation; container names with characters problematic for filenames.","solutions":["Check disk space (df -h) and free space / raise quota","Verify the skaffold log directory is writable (permissions, not read-only mount)","Ensure HOME/TMPDIR env vars are set correctly in CI containers","Manually create the expected log directory path used by the logfile package"],"exampleFix":"// before (CI container)\n# skaffold dev  # fails: unable to create log file for statuscheck step\n// after\nENV HOME=/home/skaffold TMPDIR=/tmp\nRUN mkdir -p /home/skaffold/.skaffold && chmod u+w /home/skaffold/.skaffold","handlingStrategy":"fallback","validationCode":"logDir := os.Getenv(\"HOME\") + \"/.skaffold\"\nif info, err := os.Stat(logDir); err != nil || !info.IsDir() {\n    os.MkdirAll(logDir, 0o755)\n}\nif f, err := os.CreateTemp(logDir, \"probe\"); err != nil {\n    return fmt.Errorf(\"log dir not writable: %w\", err)\n} else {\n    f.Close(); os.Remove(f.Name())\n}","typeGuard":null,"tryCatchPattern":"file, err := logfile.Create(\"statuscheck\", container+\".log\")\nif err != nil {\n    log.Warnf(\"falling back to in-memory logs only: %v\", err)\n    return out, func([]string) {}, nil // degrade gracefully instead of failing\n}","preventionTips":["Ensure HOME/TMPDIR are set and writable in CI","Monitor disk space; truncation of old logs avoids ENOSPC","Keep container names filesystem-safe when they become filenames"],"tags":["filesystem","logging","status-check"],"backgroundTag":"log-file-creation-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}