hashicorp/nomad · error
failed to parse storage.bytestotal size in kilobytes
Error message
failed to parse storage.bytestotal size in kilobytes
What it means
After extracting columns, diskInfo parses field[1] (size in 1K blocks) with strconv.ParseUint. If the column is not a plain unsigned decimal, parsing fails and this error is returned before converting to bytes.
Source
Thrown at client/fingerprint/storage_unix.go:54
return "", 0, fmt.Errorf("failed to determine mount point for %s", absPath)
}
// Output looks something like:
// Filesystem 1024-blocks Used Available Capacity iused ifree %iused Mounted on
// /dev/disk1 487385240 423722532 63406708 87% 105994631 15851677 87% /
// [0] volume [1] capacity [2] SKIP [3] free
lines := strings.Split(string(mountOutput), "\n")
if len(lines) < 2 {
return "", 0, fmt.Errorf("failed to parse `df` output; expected at least 2 lines")
}
fields := strings.Fields(lines[1])
if len(fields) < 4 {
return "", 0, fmt.Errorf("failed to parse `df` output; expected at least 4 columns")
}
volume = fields[0]
total, err = strconv.ParseUint(fields[1], 10, 64)
if err != nil {
return "", 0, fmt.Errorf("failed to parse storage.bytestotal size in kilobytes")
}
// convert to bytes
total *= 1024
return volume, total, nil
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Inspect raw `df -k <path>` output and confirm the second column is a plain integer.
- Remove any df wrapper script or ensure it emits standard output.
- Set LC_ALL=C to avoid locale separators in numbers.
- Configure DiskTotalMB to bypass df-based detection entirely.
Example fix
// before
df() { /bin/df -h "$@"; } # -h prints '1.5T' style sizes
// after
# remove wrapper; code calls `df -k` expecting raw kilobyte integers Defensive patterns
Strategy: validation
Validate before calling
out, _ := exec.Command("df", "-kP", path).Output()
lines := strings.Split(string(out), "\n")
if len(lines) < 2 { return fmt.Errorf("no df data row") }
fields := strings.Fields(lines[1])
if len(fields) < 4 { return fmt.Errorf("df columns missing") }
if _, err := strconv.ParseUint(fields[1], 10, 64); err != nil {
return fmt.Errorf("df size column %q not an integer; remove df wrappers or set DiskTotalMB", fields[1])
} Try / catch
if err := fp.Fingerprint(req); err != nil {
if strings.Contains(err.Error(), "failed to parse storage.bytestotal") {
log.Printf("df size column unparseable: %v", err)
return nil
}
return err
} Prevention
- Remove df wrapper scripts that emit human-readable sizes (-h).
- Set LC_ALL=C to prevent locale formatting of numbers.
- Verify df's 1024-blocks column is a plain integer on target hosts.
- Use DiskTotalMB config override to bypass parsing.
When it happens
Trigger: df data row's 1024-blocks column contains non-numeric text — corrupt/truncated df output, a df replacement printing units (e.g. '1.5T') or placeholder values ('-').
Common situations: Wrapper scripts around df; filesystems reporting '-' for size; output mangled by locale thousands separators.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse `df` output; expected at least 2 lines
- failed to parse `df` output; expected at least 4 columns
- failed to determine mount point for %s
- unable to get CWD from filesystem: %s
- failed to determine disk space for %s: %v
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/146a34cdff7341e6.
Report an issue: GitHub.