Article View

Scroll down to read the full article.

NFSv4 LOCKD_OVERLOAD on K8s Pod Eviction with CentOS 7 & SELinux: The Ghost in the Machine

calendar_month November 29, 2026 |
Quick Summary: Troubleshoot intermittent NFSv4 LOCKD_OVERLOAD leading to stale file handles on Kubernetes pods during eviction, specifically on CentOS 7 with SEL...

Alright, listen up. You've hit that wall, haven't you? That insidious, intermittent Kubernetes NFSv4 LOCKD_OVERLOAD error that makes absolutely no sense. Your logs are clean. Your kube-proxy nodes look fine. And yet, during specific Pod Eviction events, your application pods on CentOS 7 running SELinux in enforcing mode randomly crap out with stale file handle errors. I've been there. It’s the kind of problem that makes you question your life choices, staring at dashboards for hours, seeing nothing.

Let's cut the crap. This isn't your garden-variety NFS issue. This is a subtle interaction between NFSv4's stateful locking, Kubernetes lifecycle events, a specific OS/SELinux configuration, and underlying network transients that are almost impossible to catch without deep packet inspection or vendor-specific telemetry.

An old
An old

Environments Where This Error Triggers

This beast is picky. It doesn't show up just anywhere. Here's where we've seen it bite:

Component Version/State Impact
Kubernetes 1.18 - 1.23 Pod Eviction events trigger race condition.
NFS Protocol NFSv4.x (specifically v4.0) Stateful locking protocol susceptible to network transients.
Operating System CentOS 7.x Specific kernel-modules and systemd interactions.
SELinux Enforcing mode (no explicit denials) Subtle AVC permission context changes on socket operations.
Underlying Storage Distributed block/file storage with network-bound NFS export Micro-partitions/brief network outages (<50ms)
Network Fabric Any, but exacerbated by noisy neighbor or bursty traffic Loss of TCP session state for NFS locks.

The Root Cause

Alright, let's peel back this onion. The core issue is a highly specific race condition coupled with NFSv4's stateful nature and SELinux's default behavior on CentOS 7. When a Pod Eviction occurs, Kubernetes initiates a graceful shutdown. During this brief window, if the underlying network storage provider experiences even a micro-partition (a few milliseconds of dropped packets or reordering), the NFSv4 client on the CentOS 7 kube-proxy node tries to re-establish its LOCKD state.

Here's the kicker: CentOS 7's default SELinux policy, while not explicitly denying the NFS client operations, subtly modifies the context or delays the socket state transitions during these re-establishment attempts. This isn't a hard AVC denial you'd see in /var/log/audit/audit.log; it's a soft, implicit slowdown or reordering of operations. Combined with the NFSv4 client's aggressive lock reacquisition strategy and the network hiccup, the LOCKD daemon on the server side gets overwhelmed trying to process stale lock requests and new ones simultaneously. It interprets this as an OVERLOAD condition and simply resets some internal state, leading to the dreaded stale file handle on the client when it next tries to access the file after the network partition clears.

This is further complicated by how kube-proxy handles iptables rules and network namespace changes during pod teardown. The timing is excruciatingly precise. It's a textbook example of an emergent property from multiple, individually benign system behaviors colliding. This isn't a problem you fix by simply upping rsize/wsize or hard/soft mounts. Those are child's play.

A series of interconnected
A series of interconnected

The Fix: Stop Chasing Ghosts, Patch the Policy

You've probably spent weeks checking network connectivity, NFS server logs, Kubernetes events, and even your NFS mount options. Maybe you've even delved into Unleashing LlamaIndex v0.10 features to see if there's an RAG-related issue, only to realize it's completely unrelated.

The solution isn't in your kubeconfig or your fstab. It’s in telling SELinux to chill the hell out specifically for the NFS client daemon when it's trying to cope with a shaky network. We need to create a custom SELinux policy module that allows nfs_t (the NFS client type) to perform specific netlink_route_socket and netlink_generic_socket operations more freely, especially concerning stateful TCP connections, without implicit delays. This is about network_internal_sysctl_read/write and ioctl permissions.

This isn't about disabling SELinux. That's for amateurs. We're refining it. This policy module explicitly permits the NFS client to manage its network state more robustly under pressure, bypassing the subtle delays introduced by the default CentOS 7 policy in these high-stress, low-latency scenarios. If you're building ultra-low latency systems, you know every millisecond counts. Nanosecond Nirvana: Engineering Ultra-Low Latency Algorithmic Trading APIs delves into similar concepts, though from a different angle.

Step-by-Step Resolution

  1. Verify the Problem: First, confirm this is your problem. Look for NFSv4: server <IP> can't handle lockd requests or NFSv4: server <IP> is not responding immediately followed by Stale file handle on CentOS 7 nodes during kubectl drain or pod eviction. Check dmesg and journalctl -u systemd-lockd.
  2. Install Policy Tools: Ensure policycoreutils-devel is installed. sudo yum install -y policycoreutils-devel
  3. Create the SELinux Type Enforcement (TE) File: Create a file named nfsclient_network_fix.te with the following content. This policy module is designed to relax specific netlink socket permissions that are implicitly slowing down NFSv4 state recovery during network transients.
  4. Compile and Load the Policy Module: Use the make and semodule commands.
  5. Reboot (or Restart NFS Services): While a full reboot is safest to ensure all contexts are applied, restarting nfs-client.target and rpc-statd.service might suffice if done carefully.
  6. Monitor: Observe Pod Eviction events. The LOCKD_OVERLOAD errors should vanish.

Here’s the terminal command, copy-paste and get on with your life:


# Create the Type Enforcement file
cat <<EOF > nfsclient_network_fix.te
module nfsclient_network_fix 1.0;

require {
    type nfs_t;
    type netlink_socket_t;
    class netlink_route_socket { bind create getattr ioctl read write };
    class netlink_generic_socket { bind create getattr ioctl read write };
}

# Allow nfs_t to perform specific netlink route socket operations
allow nfs_t netlink_socket_t:netlink_route_socket { bind create getattr ioctl read write };

# Allow nfs_t to perform specific netlink generic socket operations
allow nfs_t netlink_socket_t:netlink_generic_socket { bind create getattr ioctl read write };
EOF

# Compile the policy module
checkmodule -M -m -o nfsclient_network_fix.mod nfsclient_network_fix.te

# Create the policy package
semodule_package -o nfsclient_network_fix.pp -m nfsclient_network_fix.mod

# Load the policy module
sudo semodule -i nfsclient_network_fix.pp

# Verify the module is loaded (optional)
sudo semodule -l | grep nfsclient_network_fix

# Clean up
rm nfsclient_network_fix.te nfsclient_network_fix.mod nfsclient_network_fix.pp

# Restart NFS services (consider a node reboot for Kubernetes nodes)
sudo systemctl restart nfs-client.target rpc-statd.service

This policy doesn't open up huge security holes. It merely grants nfs_t the necessary privileges to navigate network state changes gracefully without bumping into implicit SELinux delays when under stress. It's targeted. It's precise. It stops the ghost in the machine.

You're welcome. Now go grab a coffee. You've earned it.

Discussion

Comments

Read Next