{"record":{"id":"ed1e64bdd340cd79","repo":"k3s-io/k3s","slug":"error-writing-to-s-v","errorCode":null,"errorMessage":"error writing to %s: %v","messagePattern":"error writing to (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/untar/untar.go","lineNumber":88,"sourceCode":"\t\t\t// beforehand. Thus, don't check for errors; the next\n\t\t\t// write will fail with the same error.\n\t\t\tdir := filepath.Dir(abs)\n\t\t\tif !madeDir[dir] {\n\t\t\t\tif err := os.MkdirAll(filepath.Dir(abs), 0755); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tmadeDir[dir] = true\n\t\t\t}\n\t\t\twf, err := os.OpenFile(abs, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode.Perm())\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tn, err := io.Copy(wf, tr)\n\t\t\tif closeErr := wf.Close(); closeErr != nil && err == nil {\n\t\t\t\terr = closeErr\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error writing to %s: %v\", abs, err)\n\t\t\t}\n\t\t\tif n != f.Size {\n\t\t\t\treturn fmt.Errorf(\"only wrote %d bytes to %s; expected %d\", n, abs, f.Size)\n\t\t\t}\n\t\t\tmodTime := f.ModTime\n\t\t\tif modTime.After(t0) {\n\t\t\t\t// Clamp modtimes at system time. See\n\t\t\t\t// golang.org/issue/19062 when clock on\n\t\t\t\t// buildlet was behind the gitmirror server\n\t\t\t\t// doing the git-archive.\n\t\t\t\tmodTime = t0\n\t\t\t}\n\t\t\tif !modTime.IsZero() {\n\t\t\t\tif err := os.Chtimes(abs, modTime, modTime); err != nil && !loggedChtimesError {\n\t\t\t\t\t// benign error. Gerrit doesn't even set the\n\t\t\t\t\t// modtime in these, and we don't end up relying\n\t\t\t\t\t// on it anywhere (the gomote push command relies\n\t\t\t\t\t// on digests only), so this is a little pointless","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/untar/untar.go#L70-L106","documentation":"Returned when writing an extracted regular file fails: the destination file was opened with O_RDWR|O_CREATE|O_TRUNC and either io.Copy(wf, tr) or a deferred wf.Close() returned an error (Close is promoted to the returned error if Copy succeeded). Typical errno causes are ENOSPC (disk or quota full), EACCES/EPERM (permissions, read-only mount), EDQUOT, or EIO on the underlying device.","triggerScenarios":"untar.Untar into a directory on a full filesystem or one with a quota; destination on a read-only mount; running as a uid without write permission on the target path; disk I/O errors during extraction.","commonSituations":"Airgap/import workflows extracting into a small /var/lib or tmpfs that filled up after downloading the tarball; containers with read-only volumes or fsGroup/uid mismatches; long-lived nodes whose disk filled from old images or logs.","solutions":["Check free space and inodes on the destination: df -h <dir> and df -i <dir>","Verify writability as the same user: touch <dir>/.wtest && rm <dir>/.wtest","Fix mount options or ownership if the volume is read-only or permission-denied","If ENOSPC, prune old data/images or enlarge the volume, then retry the extraction"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func CanExtractInto(dir string, needBytes int64) error {\n\tvar st syscall.Statfs_t\n\tif err := syscall.Statfs(dir, &st); err != nil {\n\t\treturn err\n\t}\n\tif int64(st.Bavail)*int64(st.Bsize) < needBytes {\n\t\treturn fmt.Errorf(\"insufficient space in %s: need %d bytes\", dir, needBytes)\n\t}\n\tf, err := os.CreateTemp(dir, \".probe-*\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"destination not writable: %w\", err)\n\t}\n\treturn os.Remove(f.Name())\n}","typeGuard":null,"tryCatchPattern":"if err := untar.Untar(r, dir); err != nil {\n\tvar errno syscall.Errno\n\tif errors.As(err, &errno) && (errno == syscall.ENOSPC || errno == syscall.EDQUOT) {\n\t\t// free space / raise quota, then restart extraction from a clean dir\n\t}\n\treturn err\n}","preventionTips":["Check df -h and df -i on the target filesystem before large extractions","Ensure the extracting uid owns or can write the destination directory","Avoid extracting into read-only mounts or size-capped tmpfs","Clean up partial extraction directories before retrying after a disk-full failure"],"tags":["go","tar","io","disk-full","filesystem"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}