Skip to content

fix(pnfs): recover an MDS that loses its storage, and report it on NFSExport - #909

Merged
boddumanohar merged 4 commits into
mainfrom
fix/mds-restart-unhealthy-guest
Nov 12, 2026
Merged

boddumanohar merged 4 commits into
mainfrom
fix/mds-restart-unhealthy-guest

Conversation

@boddumanohar

@boddumanohar boddumanohar commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Problem

RCA pnfs_mds_stays_dead_after_state_disk_journal_abort_rca_20261112: a replacement MDS lost its storage paths and its state disk 2 h 46 m after boot, and stayed 0/1 with restarts=0 for 19 h 39 m. All 61 NFSExports still reported Ready, and the StorageCluster stayed Online. Every pNFS client had no data path, and nothing restarted the MDS or reported the outage.

What failed, as reproduced on cluster 111:

  1. /healthz is a constant 200, and the supervisor only cleared readiness once the guest had booted. Readiness never restarts a pod.
  2. The agent's health check passed while the state disk took no writes and while an export's XFS had shut down on a log I/O error. A check that hung in the kernel kept its last answer.
  3. A container restart does not recover the MDS. The host removed the state volume's NVMe device after its 60 s loss timeout, and the CSI node plugin stopped reconnecting it. Only a new pod stages the volume again. Deleting the pod by hand recovered it in 22 s.
  4. The nfsd watchdog only logged.
  5. A failed export health check was only an event, so the NFSExport stayed Ready.

The RCA's "no reconnect after 30/30" comes from the agent hanging on the dead state disk. With the agent alive, the path keeper reconnects within 10 s.

Changes

MDS runner and guest agent (csi-driver/)

  • internal/mds/runner/supervisor.go: once the guest has booted, if it stays unhealthy longer than --unhealthy-deadline (90 s), the runner kills QEMU and exits, and kubelet restarts the container.

  • internal/mds/agent/health.go: the health check also fails when:

    • the state disk takes no write (write and fsync a probe file);
    • an export's filesystem fails stat;
    • nfsd has been in a stuck episode for 3 minutes.

    Each check is bounded by 5 s and reports NOT_SERVING if it doesn't answer in time.

  • nfsd_watchdog.go: StuckFor() reports how long the current stuck episode has lasted.

  • paths.go: CheckFilesystems() checks every export the path keeper holds.

Operator watchdog (operator/internal/controllers/driver/mds_watchdog.go)

  • MDSReadinessWatchdog, a leader-elected Runnable modeled on the web API watchdog. It marks an MDS pod once the pod has been ready.
  • If a marked pod stays unready for 3 minutes, it deletes the pod (preconditioned on the pod's UID) and emits an MDSPodStuck event. The StatefulSet then creates a new pod, which stages the state volume again.
  • No RBAC change.

NFSExport status (api/v1alpha2/nfsexport_types.go, internal/controller/nfsexport_controller.go)

  • New field status.conditions, a list map keyed by type.
  • A Ready export's MDSReady condition is:
    • False with reason MDSUnreachable while there is no session with the MDS;
    • False with reason HealthCheckFailed while the export fails its check;
    • True with reason Serving otherwise.
  • It is written only when it changes, with an event on every change of its status, and shown as an MDSReady printcolumn. The phase does not change.
  • CRDs, dist/install.yaml, the upgrade manifests, and the chart are regenerated. The design doc (§17 Logs and status) is updated.

Tests

Each regression test failed against the unfixed code and passes now:

  • Runner, U-123: TestAGuestThatStaysUnhealthyAfterBootIsKilled. U-124 checks that a brief unhealthy spell doesn't restart anything.
  • Agent, U-125 to U-128: state disk takes no write, export filesystem shut down, nfsd stuck past the limit, a hanging check, and the filesystem check over every kept export.
  • Watchdog, O-53 and O-54: a pod unready past the threshold is recreated. Pods unready only briefly, never ready, ready, or not an MDS are left alone.
  • NFSExport, O-55 and O-56: MDSReady goes False on a failed check and on a missing session, is True when healthy, and recovers.

These pass:

  • go test -race ./internal/mds/...
  • make -C csi-driver unit-test
  • the operator's ./internal/... with envtest
  • both components' lint
  • check-crds.py
  • the house-style gate

Cluster tests (cluster 111, k3s, 3 storage nodes)

The fault: on the MDS's worker, reject outbound TCP to the lvol port 4426 for about 2.5 minutes. Both the host's state-disk paths and the guest's export paths go through that port. A writer pod on another node writes once a second.

Before (main) Runner fix only Runner and operator fix
MDS unready 0/1 for good, 0 restarts container restart at about 90 s, then CrashLoopBackOff on /dev/mds-state the same, then the pod recreated after 3 minutes
Recovery none none until the pod was deleted by hand automatic: ready about 3.5 min after the fault, writer back to ok without a restart

A final run with all three parts (operator d8303b663, CRD applied):

Time (UTC) MDS pod MDSReady Writer
14:39:04 block applied True/Serving ok
14:39:26 0/1 True/Serving ok
14:40:34 0/1 False/HealthCheckFailed EIO
14:40:45 runner exits, container restarts False/MDSUnreachable EIO
14:41:43 block lifted, CrashLoopBackOff False/MDSUnreachable EIO
14:42:51 pod recreated (new UID) False/MDSUnreachable EIO
14:43:14 1/1 True/Serving ok from 14:42:48 on, no restart

The events MDSUnhealthy, MDSReadyFalse, and MDSReadyTrue were all emitted. In total the data path was down for about 4 minutes, with no human action.

Follow-ups

  • CSI: reconnect a block volume whose device the kernel removed, or use ctrl_loss_tmo=-1 for the MDS state volume, so a container restart alone recovers.
  • Health: fail when an export has had 0 live paths for 60 s, so a connection loss is caught before a filesystem breaks.
  • Extract a shared core from the web API and MDS watchdogs.

Supersedes #910.

A replacement MDS lost its storage paths and its state disk 2 h 46 m after
boot and then sat unready, with no restart, for 19 h 39 m: the supervisor
only cleared readiness once the guest had booted, /healthz is a constant
200, and readiness never restarts a pod.

- The runner kills QEMU and exits when a booted guest has been unhealthy for
  longer than --unhealthy-deadline (90 s), so kubelet restarts the pod.
- The agent's health also fails when the state disk takes no write, when an
  export's filesystem fails getattr (an XFS shut down on an I/O error), and
  when the nfsd watchdog has been in a stuck episode for 3 minutes.
- A health check that blocks reports NOT_SERVING after 5 s instead of
  keeping its last answer.

Regression: 2026-11-12-pnfs-mds-stays-dead-after-state-disk-journal-abort
@boddumanohar
boddumanohar force-pushed the fix/mds-restart-unhealthy-guest branch from 82d5be8 to e128c7a Compare November 12, 2026 12:55
An MDS that lost its storage paths stayed unready for 19 h 39 m. The runner
now restarts its container (#909), but on cluster 111 the restarted
container crash-looped on a missing /dev/mds-state: the host had removed the
state volume's device, and only a new pod stages the volume again. Deleting
the pod by hand recovered the MDS in 22 s.

MDSReadinessWatchdog marks an MDS pod once it has been ready, and deletes a
marked pod that has been unready for 3 minutes, preconditioned on its UID,
with an MDSPodStuck event. The StatefulSet creates the replacement. A pod
that never turned ready is left to the runner's boot deadline.

Regression: 2026-11-12-pnfs-mds-stays-dead-after-state-disk-journal-abort
61 NFSExports reported Ready for 19 h 39 m while their metadata server
served nothing: a failed health check was only an event, and a missing
session requeued without a word.

NFSExport status gains conditions. A Ready export's MDSReady is False with
reason MDSUnreachable while the operator has no session with the metadata
server, False with HealthCheckFailed while the export fails its check, and
True with Serving otherwise. It is written only when it changes, with an
event on every change of its status, and shown in an MDSReady printcolumn.
The phase does not move on it.

Regression: 2026-11-12-pnfs-mds-stays-dead-after-state-disk-journal-abort
@boddumanohar boddumanohar changed the title fix(pnfs): restart an MDS guest that stays unhealthy after boot fix(pnfs): recover an MDS that loses its storage, and report it on NFSExport Nov 12, 2026
@boddumanohar
boddumanohar marked this pull request as ready for review November 12, 2026 16:44
@boddumanohar
boddumanohar merged commit e65157b into main Nov 12, 2026
29 checks passed
@boddumanohar
boddumanohar deleted the fix/mds-restart-unhealthy-guest branch November 12, 2026 17:57
boddumanohar added a commit that referenced this pull request Nov 17, 2026
…SFAM-2857) (#927)

* fix(pnfs): restart the MDS only when nfsd stops completing requests (SFAM-2857)

Since #909 a stuck nfsd makes the metadata server guest unhealthy, and the
runner restarts the pod 90s later. The watchdog counted a thread as stuck when
it sat on the same wchan for three ticks, without asking whether requests
completed meanwhile. Under heavy writes every request a thread serves blocks in
the same place, so a busy nfsd looked stuck, and restarting the singleton MDS
put write EIO on every pNFS volume in the cluster.

StuckFor now reports a stall only while nfsd completes no RPC calls: work
arriving with none processed, or a thread on one wait with the call counter
flat. A thread on one wait while calls advance still logs and dumps stacks, but
no longer counts toward health. Without RPC statistics the old rule applies.

SimplyblockDriver.spec.pnfs.mds.unhealthyDeadline passes --unhealthy-deadline to
the runner, so the restart can be delayed or turned off (0s) without pinning an
older image.

* chore(operator): regenerate the installer for spec.pnfs.mds.unhealthyDeadline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants