k3s-io/k3s · critical
tar error: %v
Error message
tar error: %v
What it means
After the zstd stream is opened, untar iterates tar entries; any error from tar.Reader.Next other than io.EOF (corrupt tar structure, truncated archive mid-entry, checksum mismatch in the stream) is logged as 'tar reading error' and returned wrapped as 'tar error'. Like the zstd error above, this occurs while extracting the embedded data-dir payload during first boot or upgrade.
Source
Thrown at pkg/untar/untar.go:56
if err != nil {
logrus.Printf("error extracting tarball into %s after %d files, %d dirs, %v: %v", dir, nFiles, len(madeDir), td, err)
}
}()
zr, err := zstd.NewReader(r, zstd.WithDecoderMaxMemory(tarfile.MaxDecoderMemory))
if err != nil {
return fmt.Errorf("error extracting zstd-compressed body: %v", err)
}
defer zr.Close()
tr := tar.NewReader(zr)
loggedChtimesError := false
for {
f, err := tr.Next()
if err == io.EOF {
break
}
if err != nil {
logrus.Printf("tar reading error: %v", err)
return fmt.Errorf("tar error: %v", err)
}
if !validRelPath(f.Name) {
return fmt.Errorf("tar contained invalid name error %q", f.Name)
}
rel := filepath.FromSlash(f.Name)
abs := filepath.Join(dir, rel)
fi := f.FileInfo()
mode := fi.Mode()
switch {
case mode.IsRegular():
// Make the directory. This is redundant because it should
// already be made by a directory entry in the tar
// beforehand. Thus, don't check for errors; the next
// write will fail with the same error.
dir := filepath.Dir(abs)
if !madeDir[dir] {
if err := os.MkdirAll(filepath.Dir(abs), 0755); err != nil {View on GitHub (pinned to 6ba341e396)
Solutions
- Re-download the k3s binary and verify its sha256 checksum against the official checksums file.
- Check free disk space and dmesg for filesystem errors on the data-dir volume; free space and retry.
- Remove leftover '<dir>-tmp' extraction directories (they are auto-removed, but verify) and restart k3s to re-extract cleanly.
- If self-built, rebuild ensuring the embedded tarball asset is generated and embedded intact.
Example fix
# before: truncated binary ls -l k3s # size smaller than published ./k3s server # tar error: unexpected EOF # after sha256sum -c sha256sums.txt && ./k3s server
Defensive patterns
Strategy: validation
Validate before calling
// Same pre-flight as 198: binary checksum plus free-space check on data dir
if !checksumMatches("k3s", wantSHA) { log.Fatal("redownload k3s") }
if free, _ := diskFree(dataDir); free < minSpace { log.Fatal("insufficient disk for extraction") } Prevention
- Verify sha256 of downloaded binaries before deployment
- Monitor disk space on the data-dir volume
- Treat any 'tar error' at startup as corruption - replace the binary rather than retrying in place
When it happens
Trigger: untar's tr.Next() fails mid-iteration: the embedded tarball is truncated (binary cut short), an entry header is corrupt, or the underlying reader errors partway. The deferred log line reports how many files/directories were extracted before the failure, localizing the truncation point.
Common situations: Partially downloaded or corrupted k3s binaries (most common); disk filling up while writing extracted files can surface as reader/writer errors here; binaries repacked or stripped in ways that damaged the embedded blob.
Related errors
- error extracting zstd-compressed body: %v
- failed to verify directory %s
- no entries found in %s
- failed %d hash verifications
- failed %d link verifications
AI-assisted analysis of k3s-io/k3s@6ba341e396 (2026-08-15).
Data as JSON: /api/errors/59b606524018cf38.
Report an issue: GitHub.