{"record":{"id":"8e6dd997e1d4bdcb","repo":"kubernetes/kops","slug":"error-reading-fstab-w","errorCode":null,"errorMessage":"error reading fstab: %w","messagePattern":"error reading fstab: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodeup/pkg/model/linode.go","lineNumber":78,"sourceCode":"\tfstabBytes, err := os.ReadFile(fstabPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read %s: %w\", fstabPath, err)\n\t}\n\n\t// Filter out swap entries\n\tvar filteredLines []string\n\tscanner := bufio.NewScanner(bytes.NewReader(fstabBytes))\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\t// Keep lines that don't contain \" swap \" or \"\\tswap\\t\"\n\t\tif !strings.Contains(line, \" swap \") && !strings.Contains(line, \"\\tswap\\t\") {\n\t\t\tfilteredLines = append(filteredLines, line)\n\t\t} else {\n\t\t\tklog.V(2).Infof(\"Removing swap entry from fstab: %s\", line)\n\t\t}\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn fmt.Errorf(\"error reading fstab: %w\", err)\n\t}\n\n\t// Write filtered fstab back\n\tfilteredContent := strings.Join(filteredLines, \"\\n\") + \"\\n\"\n\tc.AddTask(&nodetasks.File{\n\t\tPath:     fstabPath,\n\t\tContents: fi.NewStringResource(filteredContent),\n\t\tType:     nodetasks.FileType_File,\n\t\tMode:     s(\"0644\"),\n\t\t// Execute swapoff after updating fstab\n\t\tOnChangeExecute: [][]string{{\"swapoff\", \"-a\"}},\n\t})\n\n\treturn nil\n}\n","sourceCodeStart":60,"sourceCodeEnd":94,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/nodeup/pkg/model/linode.go#L60-L94","documentation":"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.","triggerScenarios":"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.","commonSituations":"Corrupted or machine-generated fstab with a pathological very long line; disk I/O errors on a failing root volume.","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)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if f, err := os.Open(\"/etc/fstab\"); err == nil {\n    sc := bufio.NewScanner(f)\n    for sc.Scan() {\n        if len(sc.Bytes()) > bufio.MaxScanTokenSize/2 {\n            return fmt.Errorf(\"fstab line suspiciously long; fix file before nodeup\")\n        }\n    }\n    if err := sc.Err(); err != nil {\n        return fmt.Errorf(\"fstab not scannable: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"scanner := bufio.NewScanner(bytes.NewReader(fstabBytes))\nif err := scanner.Err(); err != nil {\n    if errors.Is(err, bufio.ErrTooLong) {\n        return fmt.Errorf(\"fstab line exceeds scanner buffer: %w\", err)\n    }\n    return fmt.Errorf(\"error reading fstab: %w\", err)\n}","preventionTips":["Keep /etc/fstab small and human-generated","Check dmesg for disk I/O errors on nodes with recurring fstab issues"],"tags":["nodeup","linode","fstab","bufio"],"backgroundTag":"fstab-scan-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"}