{"record":{"id":"743881ebb84bbcfb","repo":"kubernetes/kops","slug":"error-disabling-swap-v","errorCode":null,"errorMessage":"error disabling swap: %v","messagePattern":"error disabling swap: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodeup/pkg/model/linode.go","lineNumber":49,"sourceCode":"\n// LinodeBuilder writes the Akamai (Linode)-specific configuration\ntype LinodeBuilder struct {\n\t*NodeupModelContext\n}\n\nvar _ fi.NodeupModelBuilder = &LinodeBuilder{}\n\n// Build configures Akamai (Linode)-specific node settings including swap disabling.\nfunc (b *LinodeBuilder) Build(c *fi.NodeupModelBuilderContext) error {\n\tif b.CloudProvider() != kops.CloudProviderLinode {\n\t\treturn nil\n\t}\n\n\t// Akamai (Linode) instances ship with swap enabled. Disable it when MemorySwapBehavior is unset,\n\t// since the default kubelet swap mode (NoSwap) requires swap to be off.\n\tif b.NodeupConfig.KubeletConfig.MemorySwapBehavior == \"\" {\n\t\tif err := b.disableSwap(c); err != nil {\n\t\t\treturn fmt.Errorf(\"error disabling swap: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// disableSwap disables swap at the OS level and removes swap entries from /etc/fstab\nfunc (b *LinodeBuilder) disableSwap(c *fi.NodeupModelBuilderContext) error {\n\t// Read current /etc/fstab\n\tfstabPath := \"/etc/fstab\"\n\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))","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/nodeup/pkg/model/linode.go#L31-L67","documentation":"nodeup's LinodeBuilder.Build disables OS-level swap on Akamai (Linode) instances when KubeletConfig.MemorySwapBehavior is unset, because the default kubelet swap mode (NoSwap) requires swap to be off. It wraps any error returned by disableSwap (fstab read/scan/write-task failures) in this generic message. Seeing it means nodeup could not prepare the node's swap state during model building.","triggerScenarios":"nodeup Build() runs on a Linode/Akamai image with swap enabled and MemorySwapBehavior empty, and b.disableSwap(c) fails — e.g. /etc/fstab is missing or unreadable, or the fstab scan errors.","commonSituations":"Custom Linode images without /etc/fstab; fstab permissions changed by hardening tooling; read-only root filesystems; set MemorySwapBehavior (e.g. LimitedSwap) to skip the disable path entirely.","solutions":["Set spec.kubelet.memorySwapBehavior (e.g. LimitedSwap) in the cluster spec so the disableSwap path is skipped","Ensure /etc/fstab exists and is readable on the Linode image before nodeup runs","Inspect the wrapped inner error (%v) to identify the exact fstab failure","Boot the instance in rescue mode and verify swap/fstab state, then rerun kops replace/create instance"],"exampleFix":"// before (spec.kubelet absent → default NoSwap, swap must be disabled)\n# no kubelet config\n// after\nkubelet:\n  memorySwapBehavior: LimitedSwap","handlingStrategy":"validation","validationCode":"if b.NodeupConfig.KubeletConfig == nil || b.NodeupConfig.KubeletConfig.MemorySwapBehavior == \"\" {\n    // will run disableSwap; ensure /etc/fstab exists first\n    if _, err := os.Stat(\"/etc/fstab\"); err != nil {\n        return fmt.Errorf(\"/etc/fstab missing; disableSwap would fail: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set kubelet.memorySwapBehavior explicitly in the cluster spec to control whether swap handling runs","Ensure base images always ship a valid /etc/fstab","Wrap nodeup runs with logging that captures the inner %v error"],"tags":["nodeup","linode","swap","kubelet"],"backgroundTag":"swap-disable-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"}