kubernetes/kops · error
error disabling swap: %v
Error message
error disabling swap: %v
What it means
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.
Source
Thrown at nodeup/pkg/model/linode.go:49
// LinodeBuilder writes the Akamai (Linode)-specific configuration
type LinodeBuilder struct {
*NodeupModelContext
}
var _ fi.NodeupModelBuilder = &LinodeBuilder{}
// Build configures Akamai (Linode)-specific node settings including swap disabling.
func (b *LinodeBuilder) Build(c *fi.NodeupModelBuilderContext) error {
if b.CloudProvider() != kops.CloudProviderLinode {
return nil
}
// Akamai (Linode) instances ship with swap enabled. Disable it when MemorySwapBehavior is unset,
// since the default kubelet swap mode (NoSwap) requires swap to be off.
if b.NodeupConfig.KubeletConfig.MemorySwapBehavior == "" {
if err := b.disableSwap(c); err != nil {
return fmt.Errorf("error disabling swap: %v", err)
}
}
return nil
}
// disableSwap disables swap at the OS level and removes swap entries from /etc/fstab
func (b *LinodeBuilder) disableSwap(c *fi.NodeupModelBuilderContext) error {
// Read current /etc/fstab
fstabPath := "/etc/fstab"
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))View on GitHub (pinned to 4c8573c808)
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
Example fix
// before (spec.kubelet absent → default NoSwap, swap must be disabled) # no kubelet config // after kubelet: memorySwapBehavior: LimitedSwap
Defensive patterns
Strategy: validation
Validate before calling
if b.NodeupConfig.KubeletConfig == nil || b.NodeupConfig.KubeletConfig.MemorySwapBehavior == "" {
// will run disableSwap; ensure /etc/fstab exists first
if _, err := os.Stat("/etc/fstab"); err != nil {
return fmt.Errorf("/etc/fstab missing; disableSwap would fail: %w", err)
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error building kubelet server cert: %v
- error building kubelet config: %v
- error loading AWS config: %v
- error querying Azure instance metadata: %v
- error querying DigitalOcean droplet ID: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/743881ebb84bbcfb.
Report an issue: GitHub.