{"record":{"id":"277c840ba843aa7e","repo":"kubernetes/kops","slug":"error-creating-temp-dir-v-277c84","errorCode":null,"errorMessage":"error creating temp dir: %v","messagePattern":"error creating temp dir: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/nodeup/nodetasks/aptsource.go","lineNumber":64,"sourceCode":"\nfunc (f *AptSource) String() string {\n\treturn f.Name\n}\n\nfunc (f *AptSource) Run(c *fi.NodeupContext) error {\n\treturn fi.NodeupDefaultDeltaRunMethod(f, c)\n}\n\nfunc (*AptSource) CheckChanges(a, e, changes *AptSource) error {\n\treturn nil\n}\n\nfunc (f *AptSource) RenderLocal(t *local.LocalTarget, a, e, changes *AptSource) error {\n\t// Not adding ctx to signature as RenderLocal seems to be part of a common interface\n\tctx := context.TODO()\n\ttmpDir, err := os.MkdirTemp(\"\", \"aptsource\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error creating temp dir: %v\", err)\n\t}\n\tdefer func() {\n\t\tif err := os.RemoveAll(tmpDir); err != nil {\n\t\t\tklog.Warningf(\"error deleting temp dir %q: %v\", tmpDir, err)\n\t\t}\n\t}()\n\tfilename := path.Join(tmpDir, f.Name+\".gpg\")\n\n\tif _, err := fi.DownloadURL(ctx, f.Keyring, filename, nil); err != nil {\n\t\treturn err\n\t}\n\n\targs := []string{\"apt-key\", \"add\", filename}\n\n\tklog.Infof(\"running command %s\", args)\n\tcmd := exec.Command(args[0], args[1:]...)\n\toutput, err := cmd.CombinedOutput()\n\tif exitCode := cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus(); err != nil && exitCode != 100 {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/nodeup/nodetasks/aptsource.go#L46-L82","documentation":"AptSource.RenderLocal creates a temporary directory with os.MkdirTemp to stage the apt key file before running apt-key add. If directory creation fails (filesystem/permission problems), it returns this wrapped error. Without the temp dir, the apt repository key cannot be installed.","triggerScenarios":"os.MkdirTemp(\"\", \"aptsource\") fails — typically ENOSPC (disk full), read-only /tmp, or permission errors on TMPDIR.","commonSituations":"Node disk full during bootstrap; /tmp mounted noexec/readonly or with restrictive permissions; TMPDIR pointing at a nonexistent path in containers.","solutions":["Free disk space on the node (`df -h`) — ENOSPC is the most common cause","Verify /tmp exists, is writable, and is not mounted read-only","Check TMPDIR env is valid or unset it so /tmp is used","Re-run nodeup after fixing the filesystem"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if st, err := os.Stat(\"/tmp\"); err != nil || !st.IsDir() {\n  return errors.New(\"/tmp missing or not a directory\")\n}\nif err := os.MkdirTemp(\"\", \"aptsource-check\"); err != nil {\n  return fmt.Errorf(\"cannot create temp dirs: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := nodeup.Run(ctx); err != nil {\n  if strings.Contains(err.Error(), \"error creating temp dir\") {\n    // check df -h and /tmp mount flags before retry\n  }\n}","preventionTips":["Monitor node disk usage; free space before bootstrap","Keep /tmp writable and not mounted read-only/noexec for temp staging","Avoid setting TMPDIR to custom paths in nodeup's environment","Set up disk alerts on node / filesystem"],"tags":["filesystem","apt","nodeup"],"backgroundTag":"temp-dir-creation-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}