kubernetes/kops · error
error reading fstab: %w
Error message
error reading fstab: %w
What it means
After filtering swap lines, disableSwap calls scanner.Err() on the bufio.Scanner reading /etc/fstab; any scan failure (e.g. a line exceeding bufio.MaxScanTokenSize) is wrapped in this error. It indicates fstab could not be fully parsed, so nodeup refuses to rewrite it.
Source
Thrown at nodeup/pkg/model/linode.go:78
fstabBytes, err := os.ReadFile(fstabPath)
if err != nil {
return fmt.Errorf("failed to read %s: %w", fstabPath, err)
}
// Filter out swap entries
var filteredLines []string
scanner := bufio.NewScanner(bytes.NewReader(fstabBytes))
for scanner.Scan() {
line := scanner.Text()
// Keep lines that don't contain " swap " or "\tswap\t"
if !strings.Contains(line, " swap ") && !strings.Contains(line, "\tswap\t") {
filteredLines = append(filteredLines, line)
} else {
klog.V(2).Infof("Removing swap entry from fstab: %s", line)
}
}
if err := scanner.Err(); err != nil {
return fmt.Errorf("error reading fstab: %w", err)
}
// Write filtered fstab back
filteredContent := strings.Join(filteredLines, "\n") + "\n"
c.AddTask(&nodetasks.File{
Path: fstabPath,
Contents: fi.NewStringResource(filteredContent),
Type: nodetasks.FileType_File,
Mode: s("0644"),
// Execute swapoff after updating fstab
OnChangeExecute: [][]string{{"swapoff", "-a"}},
})
return nil
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Inspect /etc/fstab for malformed or extremely long lines and fix or remove them
- Check dmesg for root-disk I/O errors and repair/replace the volume
- Note the scan error is rare — most real failures surface earlier as error 711 (failed to read /etc/fstab)
Defensive patterns
Strategy: try-catch
Validate before calling
if f, err := os.Open("/etc/fstab"); err == nil {
sc := bufio.NewScanner(f)
for sc.Scan() {
if len(sc.Bytes()) > bufio.MaxScanTokenSize/2 {
return fmt.Errorf("fstab line suspiciously long; fix file before nodeup")
}
}
if err := sc.Err(); err != nil {
return fmt.Errorf("fstab not scannable: %w", err)
}
} Try / catch
scanner := bufio.NewScanner(bytes.NewReader(fstabBytes))
if err := scanner.Err(); err != nil {
if errors.Is(err, bufio.ErrTooLong) {
return fmt.Errorf("fstab line exceeds scanner buffer: %w", err)
}
return fmt.Errorf("error reading fstab: %w", err)
} Prevention
- Keep /etc/fstab small and human-generated
- Check dmesg for disk I/O errors on nodes with recurring fstab issues
When it happens
Trigger: bufio.Scanner hits a read/token error while iterating /etc/fstab — practically, an fstab line longer than the default 64KB scanner buffer, or an underlying I/O error mid-read.
Common situations: Corrupted or machine-generated fstab with a pathological very long line; disk I/O errors on a failing root volume.
Related errors
- failed to read %s: %w
- error disabling swap: %v
- error building linode node identifier: %w
- building nodeConfig for instanceGroup: %w
- marshalling nodeupConfig: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/8e6dd997e1d4bdcb.
Report an issue: GitHub.