Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions csi-driver/cmd/mds-runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@ func run(ctx context.Context, c config) error {
if err := netsetup.Apply(ctx, plan, netsetup.ExecIPTables); err != nil {
return err
}
if plan.HostPath {
if err := startHostPath(ctx, plan, c.hostProxy); err != nil {
return err
}
}

if err := os.MkdirAll(c.runDir, 0o700); err != nil {
return err
}
Expand Down Expand Up @@ -239,6 +233,12 @@ func run(ctx context.Context, c config) error {
guest.Arch, guest.Hostname, guest.CPUs, guest.MemoryMiB, guest.Address, uplink)

sup := &runner.Supervisor{
StoragePath: func(ctx context.Context) error {
if !plan.HostPath {
return nil
}
return startHostPath(ctx, plan, c.hostProxy)
},
Start: runner.StartProcess(binary, args, os.Stdout, os.Stderr),
Probe: runner.GRPCHealthProbe(agentAddress),
Powerdown: func(ctx context.Context) error {
Expand Down
12 changes: 12 additions & 0 deletions csi-driver/internal/mds/runner/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ type Process interface {

// Supervisor runs one guest.
type Supervisor struct {
// StoragePath starts what carries the guest's connections to its storage,
// before QEMU, and serves it until ctx ends. Run hands it a context that
// outlives Run's own and ends only once QEMU has exited, because a guest
// powering down still flushes and unmounts through it. Optional.
StoragePath func(ctx context.Context) error
// Start starts QEMU.
Start func(ctx context.Context) (Process, error)
// Probe returns nil while the guest is healthy.
Expand All @@ -64,6 +69,13 @@ type Supervisor struct {
// it down, or until it fails. It returns nil only for a shutdown that was
// asked for.
func (s *Supervisor) Run(ctx context.Context) error {
if s.StoragePath != nil {
storage, stopStorage := context.WithCancel(context.WithoutCancel(ctx))
defer stopStorage()
if err := s.StoragePath(storage); err != nil {
return fmt.Errorf("starting the guest's storage path: %w", err)
}
}
proc, err := s.Start(ctx)
if err != nil {
return fmt.Errorf("starting QEMU: %w", err)
Expand Down
37 changes: 37 additions & 0 deletions csi-driver/internal/mds/runner/supervisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,40 @@ func TestAFailedDrainStillPowersDown(t *testing.T) {
t.Errorf("Run = %v, want a clean shutdown", err)
}
}

// Regression: 2026-11-11-mds-forwarder-dies-before-guest. The host-path
// forwarder carries the guest's NVMe/TCP connections, and it was served under
// the runner's stop-signal context. SIGTERM therefore cut the guest's storage
// at the moment the power button was pressed: unmounting the exported XFS hung
// on paths that no longer existed, the guest never powered down, and QEMU was
// killed after the shutdown grace on every MDS move (about 20 s of client
// stall each time).
func TestTheGuestKeepsItsStorageUntilItHasPoweredDown(t *testing.T) {
q := newFakeQEMU()
s := supervisor(q)
var storage context.Context
s.StoragePath = func(ctx context.Context) error { storage = ctx; return nil }
s.Powerdown = func(context.Context) error {
// The guest flushes and unmounts on the way down, through its storage.
if storage.Err() != nil {
return errors.New("the guest's storage path is gone")
}
q.stop(nil)
return nil
}
ctx, cancel := context.WithCancel(context.Background())
done := runAsync(ctx, s)

waitFor(t, "readiness", s.Ready)
cancel()

if err := result(t, done); err != nil {
t.Errorf("Run after a requested shutdown = %v, want nil", err)
}
if q.killed.Load() {
t.Error("QEMU was killed: the guest lost its storage before it could power down")
}
if storage.Err() == nil {
t.Error("the storage path outlived Run")
}
}
2 changes: 2 additions & 0 deletions operator/docs/tests/test-plan-pnfs-rwx.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ restarted rather than migrated (design §13).
| U-104 | The runner's debug key is a private pair the guest accepts, new at every boot | Positive | `TestDebugSSHKeyIsAPrivatePairTheGuestAccepts`, `TestDebugSSHKeyIsNewEveryBoot` |
| U-105 | Regression (run `pnfs-1791652310`): the runner drains the guest and waits before the power button, and a failed drain still powers it down | Regression | `TestShutdownDrainsTheGuestBeforeThePowerButton`, `TestAFailedDrainStillPowersDown` |
| U-117 | Regression (2026-11-11-standby-guest-never-activated): a guest booted without its state mounted is activated, a blank state disk is formatted first, an unreadable one never, and a serving guest is left as it is | Regression | `TestAGuestBootedAsAStandbyIsActivated`, `TestABlankStateDiskIsFormattedFirst`, `TestAnUnreadableStateDiskIsNeverFormatted`, `TestAGuestAlreadyServingIsLeftAsItIs` |
| U-116 | Regression (2026-11-11-mds-forwarder-dies-before-guest): the guest keeps its storage path through the power-down, so it powers down instead of being killed | Regression | `TestTheGuestKeepsItsStorageUntilItHasPoweredDown` |
| U-106 | The drain drops every packet carrying a request to the guest's NFS port and lets bare ACKs through | Positive | `TestTheDrainDropsRequestsButNotAcknowledgments` |
| U-107 | Regression (run `pnfs-1791662135`): the kernel command line keeps unknown exports answered with a retry for 60s after nfsd starts | Regression | `TestKernelCmdlineCarriesTheStaticAddress` |
| U-76 | The relay resolves connections as the operator's identity, and delete proceeds without the control plane | Positive | `TestCreateHandsTheGuestAConnectionResolvedForTheOperatorsIdentity`, `TestDeleteGoesAheadWithoutTheControlPlane` |
Expand Down Expand Up @@ -325,6 +326,7 @@ through the control plane's API.
| O-49 | Regression (run `pnfs-1791662135`): exports reconcile concurrently, so a restart reassembles them together | Regression | `TestExportsReconcileConcurrently` |
| O-50 | Regression (2026-11-11-mds-proxy-remote-ports): on a managed consumer with no StorageNode, the mds-proxy is told the listener ports the remote control plane reports, asked with the cluster secret | Regression | `TestTheMDSProxyIsToldTheListenerPortsOfARemoteStorageCluster` |
| O-51 | A remote control plane that does not answer leaves the published mds-proxy ports in place | Negative | `TestAnUnreachableControlPlaneKeepsThePublishedPorts` |
| O-52 | Regression (2026-11-11-pnfs-mds-not-in-eviction-targets): a maintenance window holds the pNFS metadata server on the drained worker, and none on another worker | Regression | `TestTheWindowHoldsThePNFSMetadataServer` |

---

Expand Down
2 changes: 1 addition & 1 deletion operator/internal/controllers/driver/mds.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const KVMCapableValue = "true"

// MDSClusterLabel carries the storage cluster's full ID on the metadata server
// pod and its StatefulSet. The name only carries a prefix of it.
const MDSClusterLabel = "storage.simplyblock.io/cluster-id"
const MDSClusterLabel = utils.LabelMDSClusterID

// MDSTemplateHashAnnotation records MDSTemplateHash on the metadata server
// StatefulSet, so an operator release can tell whether the pod template is the
Expand Down
42 changes: 42 additions & 0 deletions operator/internal/controllers/node/hostmaintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,3 +725,45 @@ func TestAMaintenanceWindowSendsNothingToANodeLeavingTheCluster(t *testing.T) {
})
}
}

// anMDSPod is the pNFS metadata server's pod, labeled as its StatefulSet labels
// it: by its per-cluster name and the cluster it serves.
func anMDSPod(worker string) *corev1.Pod {
return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: "simplyblock-pnfs-mds-2b201eb1-0",
Namespace: opsNamespace,
Labels: map[string]string{
"app": "simplyblock-pnfs-mds-2b201eb1",
"storage.simplyblock.io/cluster-id": "2b201eb1-15b6-4bb6-a341-23acde78bb6c",
},
},
Spec: corev1.PodSpec{NodeName: worker},
Status: corev1.PodStatus{Phase: corev1.PodRunning},
}
}

// Regression: 2026-11-11-pnfs-mds-not-in-eviction-targets. The window's budget
// held the SPDK pod, the management API, and FoundationDB, and nothing else, so
// a drain of the worker evicted the pNFS metadata server at once, even while
// the control plane refused or deferred the maintenance it was drained for.
// Every pNFS client in the cluster stalled until a new metadata server had
// booted and ended its grace period, three times in a day for maintenance that
// never ran.
func TestTheWindowHoldsThePNFSMetadataServer(t *testing.T) {
mds := anMDSPod(opsWorker)
elsewhere := anMDSPod("another-worker")
elsewhere.Name = "simplyblock-pnfs-mds-other-0"
r, apiClient := anOpsWorld(t, aControlPlane(), anSpdkPod(opsWorker, "4420"), mds, elsewhere)

if err := r.Workload.BlockEviction(
context.Background(), opsNamespace, opsCluster, opsWorker); err != nil {
t.Fatalf("holding the eviction: %v", err)
}
if !guarded(t, apiClient, mds.Name) {
t.Error("the metadata server on the drained worker is not held by the window's budget")
}
if guarded(t, apiClient, elsewhere.Name) {
t.Error("a metadata server on another worker was held by this worker's window")
}
}
42 changes: 34 additions & 8 deletions operator/internal/controllers/node/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import (
policyv1 "k8s.io/api/policy/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -399,24 +401,48 @@ func (w *Workload) agentPodOn(
// the window with nothing to ask, which is what the operator saw on 2026-09-29
// when its shutdown took a connection refused from the webAPI mid-flight.
//
// The pNFS metadata server is here because every pNFS client in the cluster goes
// through it: evicting it stalls them all until a new one has booted and ended
// its grace period, which a drain must not cost while the control plane has not
// yet agreed to the maintenance.
//
// The node agent's DaemonSet pod is deliberately absent. A budget over it holds
// no drain, and the agent is what the window needs answering in AwaitingHost.
var evictionTargets = []map[string]string{
{utils.LabelRole: utils.LabelSpdkProxyRole},
{atlaskube.LabelApp: controlplane.ComponentWebAPI},
{utils.LabelFDBClusterName: controlplane.ComponentFDBCluster},
var evictionTargets = []labels.Selector{
labels.SelectorFromSet(labels.Set{utils.LabelRole: utils.LabelSpdkProxyRole}),
labels.SelectorFromSet(labels.Set{atlaskube.LabelApp: controlplane.ComponentWebAPI}),
labels.SelectorFromSet(labels.Set{utils.LabelFDBClusterName: controlplane.ComponentFDBCluster}),
mdsPods,
}

// mdsPods selects every pNFS metadata server pod, by the cluster label only they
// carry.
var mdsPods = func() labels.Selector {
req, err := labels.NewRequirement(utils.LabelMDSClusterID, selection.Exists, nil)
if err != nil {
panic(err)
}
return labels.NewSelector().Add(*req)
}()

// podsMatching lists the pods on one worker that carry every given label,
// skipping any that is already on its way out.
func (w *Workload) podsMatching(
ctx context.Context, namespace, worker string, labels map[string]string,
ctx context.Context, namespace, worker string, set map[string]string,
) ([]corev1.Pod, error) {
return w.podsSelected(ctx, namespace, worker, labels.SelectorFromSet(set))
}

// podsSelected lists the pods on one worker that the selector matches, skipping
// any that is already on its way out.
func (w *Workload) podsSelected(
ctx context.Context, namespace, worker string, selector labels.Selector,
) ([]corev1.Pod, error) {
var pods corev1.PodList
err := w.List(ctx, &pods,
client.InNamespace(namespace), client.MatchingLabels(labels))
client.InNamespace(namespace), client.MatchingLabelsSelector{Selector: selector})
if err != nil {
return nil, fmt.Errorf("list the pods matching %v: %w", labels, err)
return nil, fmt.Errorf("list the pods matching %v: %w", selector, err)
}
on := make([]corev1.Pod, 0, len(pods.Items))
for i := range pods.Items {
Expand Down Expand Up @@ -509,7 +535,7 @@ func (w *Workload) BlockEviction(
ctx context.Context, namespace, cluster, worker string,
) error {
for _, selector := range evictionTargets {
pods, err := w.podsMatching(ctx, namespace, worker, selector)
pods, err := w.podsSelected(ctx, namespace, worker, selector)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions operator/internal/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ const (
// thing about it that is the same on every worker.
LabelRole = "role"
LabelSpdkProxyRole = "simplyblock-storage-node"
// LabelMDSClusterID names the cluster a pNFS metadata server pod serves. Only
// metadata server pods carry it.
LabelMDSClusterID = "storage.simplyblock.io/cluster-id"
)

// NodeIsLeaving reports whether a control-plane node status, lowercased, is one
Expand Down
Loading