From e9e005a47f9b815dcc059e0e9ca9d2d4eb7cbedf Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 27 Jun 2026 02:53:22 -0700 Subject: [PATCH] phase100: close nvme csi multipath live gate --- .../cmd/blockcsi/g15d_manifest_test.go | 12 ++ .../core/authority/observation_store.go | 34 +++++ .../observation_store_slotfact_test.go | 27 ++++ seaweed-block/core/csi/controller.go | 15 ++- seaweed-block/core/csi/controller_test.go | 49 ++++++++ seaweed-block/core/csi/node.go | 41 ++++++ seaweed-block/core/csi/node_test.go | 76 ++++++++++++ .../core/host/master/frontend_status_test.go | 27 ++++ seaweed-block/core/host/master/host.go | 33 +++-- seaweed-block/docs/roadmap.md | 19 +-- seaweed-block/internal/docs/current-plan.md | 53 +++++--- ..._finishedplan_nvme_csi_multipath_attach.md | 71 +++++++++++ .../internal/docs/product-roadmap.md | 20 +-- ...e100-nvme-csi-multipath-live-qa-signoff.md | 85 +++++++++++++ seaweed-block/scripts/build-alpha-images.sh | 19 ++- seaweed-block/scripts/run-g15d-k8s-dynamic.sh | 117 ++++++++++++++++++ ...n-phase100-nvme-csi-multipath-live-gate.sh | 92 ++++++++++++++ .../nvme-csi-multipath-live-chain.yaml | 107 ++++++++++++++++ 18 files changed, 850 insertions(+), 47 deletions(-) create mode 100644 seaweed-block/internal/docs/finished-plans/phase100_finishedplan_nvme_csi_multipath_attach.md create mode 100644 seaweed-block/internal/docs/qa-assignments/phase100-nvme-csi-multipath-live-qa-signoff.md create mode 100644 seaweed-block/scripts/run-phase100-nvme-csi-multipath-live-gate.sh create mode 100644 seaweed-block/testops/scenarios/nvme-csi-multipath-live-chain.yaml diff --git a/seaweed-block/cmd/blockcsi/g15d_manifest_test.go b/seaweed-block/cmd/blockcsi/g15d_manifest_test.go index 65a83ff3ab..45e095e986 100644 --- a/seaweed-block/cmd/blockcsi/g15d_manifest_test.go +++ b/seaweed-block/cmd/blockcsi/g15d_manifest_test.go @@ -96,13 +96,25 @@ func TestG15d_K8sRunner_AppliesLauncherGeneratedManifest(t *testing.T) { "SW_BLOCK_ISCSI_CHAP_USERNAME", "SW_BLOCK_ISCSI_CHAP_SECRET", "SW_BLOCK_FRONTEND_PROTOCOL", + "SW_BLOCK_STAGE2_MULTIPATH", + "SW_BLOCK_DYNAMIC_REPLICATION_FACTOR", + "SW_BLOCK_SAME_NODE_LOGICAL_REPLICAS", "csi.storage.k8s.io/node-stage-secret-name", `sw-block.seaweedfs.com/protocol: \"nvme\"`, `protocol: \"nvme\"`, "frontend_protocol=$FRONTEND_PROTOCOL", + "stage2_multipath=$STAGE2_MULTIPATH", + "dynamic_replication_factor=${DYNAMIC_REPLICATION_FACTOR:-manifest-default}", + "stage2_multipath:", + "same_node_logical_replicas=$SAME_NODE_LOGICAL_REPLICAS", + "--expected-slots-per-volume=${SAME_NODE_LOGICAL_REPLICAS}", + "failed to override dynamic replicationFactor", + "failed to inject --stage2-multipath into", + "failed to pin dynamic pod to same-node NVMe target host", "expected_git_revision=${EXPECTED_GIT_REVISION:-unknown}", "blockmaster.version.txt", "blockcsi.version.txt", + "blockcsi-node.log", "blockvolume.version.txt", "kube-system-imageids.txt", "image revision mismatch", diff --git a/seaweed-block/core/authority/observation_store.go b/seaweed-block/core/authority/observation_store.go index 97ae180c01..67d995246d 100644 --- a/seaweed-block/core/authority/observation_store.go +++ b/seaweed-block/core/authority/observation_store.go @@ -130,6 +130,40 @@ func (s *ObservationStore) SlotFact(volumeID, replicaID string) (SlotFact, bool) return best, found } +// ReplicaIDsForVolume returns fresh, usable replica IDs currently +// observed for a volume. It is a read-only evidence helper for +// dynamic-lifecycle status surfaces; callers that own a static +// topology must keep using topology membership as their allow-list. +func (s *ObservationStore) ReplicaIDsForVolume(volumeID string) []string { + if volumeID == "" { + return nil + } + s.mu.Lock() + defer s.mu.Unlock() + now := s.now() + seen := map[string]struct{}{} + for _, obs := range s.observations { + if !obs.ExpiresAt.IsZero() && now.After(obs.ExpiresAt) { + continue + } + for _, slot := range obs.Slots { + if slot.VolumeID != volumeID || slot.ReplicaID == "" { + continue + } + if slotExpired(slot, obs, now) || slot.DataAddr == "" { + continue + } + seen[slot.ReplicaID] = struct{}{} + } + } + out := make([]string, 0, len(seen)) + for replicaID := range seen { + out = append(out, replicaID) + } + sort.Strings(out) + return out +} + // SetNowForTest replaces the store's clock source. Tests use this // to drive expiry / freshness deterministically. Symmetric with // authority.TopologyController.SetNowForTest. Production code diff --git a/seaweed-block/core/authority/observation_store_slotfact_test.go b/seaweed-block/core/authority/observation_store_slotfact_test.go index 70adcf8a9f..deaeec0fa4 100644 --- a/seaweed-block/core/authority/observation_store_slotfact_test.go +++ b/seaweed-block/core/authority/observation_store_slotfact_test.go @@ -39,6 +39,33 @@ func TestObservationStore_SlotFact_NoObservation_ReturnsFalse(t *testing.T) { } } +func TestObservationStore_ReplicaIDsForVolume_ReturnsFreshUsableSlots(t *testing.T) { + now := time.Date(2026, 6, 27, 10, 0, 0, 0, time.UTC) + s := NewObservationStore(FreshnessConfig{FreshnessWindow: 30 * time.Second}, func() time.Time { return now }) + if err := s.Ingest(Observation{ + ServerID: "m01", + ObservedAt: now, + Slots: []SlotFact{ + {VolumeID: "v1", ReplicaID: "r2", DataAddr: "127.0.0.1:19103"}, + {VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19101"}, + {VolumeID: "v1", ReplicaID: "empty", DataAddr: ""}, + {VolumeID: "other", ReplicaID: "r3", DataAddr: "127.0.0.1:19105"}, + }, + }); err != nil { + t.Fatalf("Ingest: %v", err) + } + got := s.ReplicaIDsForVolume("v1") + want := []string{"r1", "r2"} + if len(got) != len(want) { + t.Fatalf("replicas=%v want %v", got, want) + } + for i := range want { + if got[i] != want[i] { + t.Fatalf("replicas=%v want %v", got, want) + } + } +} + func TestObservationStore_SlotFact_EmptyDataAddr_FailsClosed(t *testing.T) { now := time.Date(2026, 4, 27, 10, 0, 0, 0, time.UTC) s := NewObservationStore(FreshnessConfig{FreshnessWindow: 30 * time.Second}, func() time.Time { return now }) diff --git a/seaweed-block/core/csi/controller.go b/seaweed-block/core/csi/controller.go index 123a642248..6169f01d5b 100644 --- a/seaweed-block/core/csi/controller.go +++ b/seaweed-block/core/csi/controller.go @@ -62,14 +62,18 @@ func (s *ControllerServer) CreateVolume(ctx context.Context, req *csipb.CreateVo } } protocol := normalizeProtocol(created.Protocol) + volumeContext := map[string]string{ + "replicationFactor": strconv.Itoa(created.ReplicationFactor), + "protocol": string(protocol), + } + if iscsiMultipathFromContext(req.GetParameters()) { + volumeContext["stage2_multipath"] = "true" + } return &csipb.CreateVolumeResponse{ Volume: &csipb.Volume{ VolumeId: created.VolumeID, CapacityBytes: int64(created.SizeBytes), - VolumeContext: map[string]string{ - "replicationFactor": strconv.Itoa(created.ReplicationFactor), - "protocol": string(protocol), - }, + VolumeContext: volumeContext, }, }, nil } @@ -123,6 +127,9 @@ func (s *ControllerServer) ControllerPublishVolume(ctx context.Context, req *csi if len(pubCtx) == 0 { return nil, status.Errorf(codes.FailedPrecondition, "volume %q has no attachable frontend target", req.GetVolumeId()) } + if iscsiMultipathFromContext(req.GetVolumeContext()) { + pubCtx["stage2_multipath"] = "true" + } return &csipb.ControllerPublishVolumeResponse{PublishContext: pubCtx}, nil } diff --git a/seaweed-block/core/csi/controller_test.go b/seaweed-block/core/csi/controller_test.go index 10daa308be..62fa38864d 100644 --- a/seaweed-block/core/csi/controller_test.go +++ b/seaweed-block/core/csi/controller_test.go @@ -153,6 +153,32 @@ func TestControllerPublish_DoesNotExposeAuthorityGenerationInPublishContext(t *t } } +func TestControllerPublish_CarriesStage2MultipathRequestFromVolumeContext(t *testing.T) { + lookup := &stubLookup{target: PublishTarget{ + VolumeID: "v1", + ReplicaID: "r1", + Protocol: ProtocolNVMe, + NVMeAddr: "127.0.0.1:4420", + NQN: "nqn.2026-05.io.seaweedfs:v1", + NSID: 1, + }} + s := NewControllerServer(lookup) + + resp, err := s.ControllerPublishVolume(context.Background(), &csipb.ControllerPublishVolumeRequest{ + VolumeId: "v1", + NodeId: "node-a", + VolumeContext: map[string]string{ + "stage2_multipath": "true", + }, + }) + if err != nil { + t.Fatalf("ControllerPublishVolume: %v", err) + } + if got := resp.GetPublishContext()["stage2_multipath"]; got != "true" { + t.Fatalf("stage2_multipath=%q context=%v", got, resp.GetPublishContext()) + } +} + func TestControllerPublish_FailsClosedWithoutVerifiedTarget(t *testing.T) { s := NewControllerServer(&stubLookup{err: ErrPublishTargetNotFound}) _, err := s.ControllerPublishVolume(context.Background(), &csipb.ControllerPublishVolumeRequest{ @@ -400,6 +426,29 @@ func TestG15c_ControllerCreateVolume_RecordsProtocolSelection(t *testing.T) { } } +func TestControllerCreateVolume_CarriesStage2MultipathVolumeContext(t *testing.T) { + prov := &stubProvisioner{} + s := NewControllerServerWithProvisioner(nil, prov) + resp, err := s.CreateVolume(context.Background(), &csipb.CreateVolumeRequest{ + Name: "pvc-a", + CapacityRange: &csipb.CapacityRange{ + RequiredBytes: 1048576, + }, + VolumeCapabilities: []*csipb.VolumeCapability{testVolumeCapability()}, + Parameters: map[string]string{ + "protocol": "nvme", + "replicationFactor": "2", + "stage2_multipath": "true", + }, + }) + if err != nil { + t.Fatalf("CreateVolume: %v", err) + } + if got := resp.GetVolume().GetVolumeContext()["stage2_multipath"]; got != "true" { + t.Fatalf("stage2_multipath=%q context=%v", got, resp.GetVolume().GetVolumeContext()) + } +} + func TestG15c_ControllerCreateVolume_RejectsConflictingProtocolParameters(t *testing.T) { for _, tc := range []struct { name string diff --git a/seaweed-block/core/csi/node.go b/seaweed-block/core/csi/node.go index ad2b0dfc95..2d4d884a75 100644 --- a/seaweed-block/core/csi/node.go +++ b/seaweed-block/core/csi/node.go @@ -285,6 +285,11 @@ func (s *NodeServer) stageNVMe(ctx context.Context, req *csipb.NodeStageVolumeRe } publish := s.refreshPublishContext(ctx, volumeID, req.GetPublishContext()) publishContext := publish.Context + multipathRequested := iscsiMultipathFromContext(publishContext) || iscsiMultipathFromContext(req.GetPublishContext()) || iscsiMultipathFromContext(req.GetVolumeContext()) + if multipathRequested { + publish = s.waitForNVMeMultipathPublishContext(ctx, volumeID, publish, 2) + publishContext = publish.Context + } addr, nqn := nvmeFromContext(publishContext) addrs := nvmeAddrsFromContext(publishContext) if addr == "" || nqn == "" { @@ -720,6 +725,42 @@ func hasISCSIMultipathPortals(ctx map[string]string, minPortals int) bool { return iscsiMultipathFromContext(ctx) && len(iscsiPortalsFromContext(ctx)) >= minPortals } +func (s *NodeServer) waitForNVMeMultipathPublishContext(ctx context.Context, volumeID string, current publishContextResult, minPortals int) publishContextResult { + if hasNVMeMultipathPortals(current.Context, minPortals) { + return current + } + if s.lookup == nil { + return current + } + deadline := time.NewTimer(stage2MultipathPublishWait) + defer deadline.Stop() + ticker := time.NewTicker(stage2MultipathPublishPoll) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return current + case <-deadline.C: + return current + case <-ticker.C: + target, err := s.lookup.LookupPublishTarget(ctx, volumeID, s.nodeID) + if err != nil { + continue + } + if refreshed := publishContext(target); len(refreshed) > 0 { + current = publishContextResult{Context: refreshed, Target: target, HasTarget: true} + if hasNVMeMultipathPortals(current.Context, minPortals) { + return current + } + } + } + } +} + +func hasNVMeMultipathPortals(ctx map[string]string, minPortals int) bool { + return iscsiMultipathFromContext(ctx) && len(nvmeAddrsFromContext(ctx)) >= minPortals +} + func cloneStringMap(in map[string]string) map[string]string { out := make(map[string]string, len(in)+1) for k, v := range in { diff --git a/seaweed-block/core/csi/node_test.go b/seaweed-block/core/csi/node_test.go index 56b42b6ca2..05048912e5 100644 --- a/seaweed-block/core/csi/node_test.go +++ b/seaweed-block/core/csi/node_test.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" "testing" + "time" csipb "github.com/container-storage-interface/spec/lib/go/csi" "google.golang.org/grpc/codes" @@ -188,6 +189,17 @@ func newTestNodeWithNVMe(mi *mockISCSIUtil, mn *mockNVMeUtil, mm *mockMountUtil) }) } +func newTestNodeWithNVMeLookup(mi *mockISCSIUtil, mn *mockNVMeUtil, mm *mockMountUtil, lookup PublishTargetLookup) *NodeServer { + return NewNodeServer(NodeConfig{ + NodeID: "node-a", + IQNPrefix: "iqn.2026-05.example.v3", + ISCSIUtil: mi, + NVMeUtil: mn, + MountUtil: mm, + Lookup: lookup, + }) +} + func newTestNodeWithLookup(mi *mockISCSIUtil, mm *mockMountUtil, lookup PublishTargetLookup) *NodeServer { return NewNodeServer(NodeConfig{ NodeID: "node-a", @@ -653,6 +665,70 @@ func TestNodeStage_NVMeMultipathConnectsAllTargets(t *testing.T) { } } +func TestNodeStage_NVMeMultipathWaitsForRefreshedMultiPortalTarget(t *testing.T) { + mi, mn, mm := newMockISCSIUtil(), newMockNVMeUtil(), newMockMountUtil() + lookup := &sequenceLookup{targets: []PublishTarget{ + { + VolumeID: "v1", + ReplicaID: "r1", + Protocol: ProtocolNVMe, + NVMeAddr: "127.0.0.1:4420", + NQN: "nqn.2026-05.io.seaweedfs:v1", + NSID: 1, + }, + { + VolumeID: "v1", + ReplicaID: "r1", + Protocol: ProtocolNVMe, + NVMeAddr: "127.0.0.1:4420", + NVMeAddrs: []string{"127.0.0.1:4420", "127.0.0.1:4421"}, + NQN: "nqn.2026-05.io.seaweedfs:v1", + NSID: 1, + Multipath: true, + }, + }} + ns := newTestNodeWithNVMeLookup(mi, mn, mm, lookup) + staging := t.TempDir() + + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + defer cancel() + _, err := ns.NodeStageVolume(ctx, &csipb.NodeStageVolumeRequest{ + VolumeId: "v1", + StagingTargetPath: staging, + VolumeCapability: testVolumeCapability(), + PublishContext: map[string]string{ + "protocol": "nvme", + "nvmeAddr": "127.0.0.1:4420", + "nqn": "nqn.2026-05.io.seaweedfs:v1", + "stage2_multipath": "true", + }, + VolumeContext: map[string]string{ + "stage2_multipath": "true", + }, + }) + if err != nil { + t.Fatalf("NodeStageVolume: %v", err) + } + for _, want := range []string{ + "connect:127.0.0.1:4420:nqn.2026-05.io.seaweedfs:v1", + "connect:127.0.0.1:4421:nqn.2026-05.io.seaweedfs:v1", + } { + found := false + for _, call := range mn.calls { + if call == want { + found = true + break + } + } + if !found { + t.Fatalf("missing %q in nvme calls=%v", want, mn.calls) + } + } + if info := ns.staged["v1"]; info == nil || !info.multipath || len(info.nvmeAddrs) != 2 { + t.Fatalf("staged info=%+v", info) + } +} + func TestNodeStage_NVMeCleansUpConnectWhenMountFails(t *testing.T) { _, mn, mm := newMockISCSIUtil(), newMockNVMeUtil(), newMockMountUtil() mm.formatAndMountErr = errors.New("mkfs failed") diff --git a/seaweed-block/core/host/master/frontend_status_test.go b/seaweed-block/core/host/master/frontend_status_test.go index b08d5e211f..150cac2725 100644 --- a/seaweed-block/core/host/master/frontend_status_test.go +++ b/seaweed-block/core/host/master/frontend_status_test.go @@ -134,6 +134,33 @@ func TestNodeLoss_StatusFrontendsForAssignedVolume_CurrentPrimaryFirstForCSIAtta } } +func TestDynamicLifecycle_ReplicaSlotsForMergesFreshObservedSlots(t *testing.T) { + obs := authority.NewObservationHost(authority.ObservationHostConfig{}) + for _, hb := range []authority.HeartbeatMessage{ + frontendHeartbeat("node-a", "v1", "r2", "127.0.0.1:4421"), + frontendHeartbeat("node-a", "v1", "r1", "127.0.0.1:4420"), + } { + if err := obs.IngestHeartbeat(hb); err != nil { + t.Fatalf("ingest heartbeat: %v", err) + } + } + h := &Host{ + obs: obs, + lifecycle: &LifecycleStores{}, + } + + got := h.replicaSlotsFor("v1") + want := []string{"r1", "r2"} + if len(got) != len(want) { + t.Fatalf("replica slots=%v want %v", got, want) + } + for i := range want { + if got[i] != want[i] { + t.Fatalf("replica slots=%v want %v", got, want) + } + } +} + func TestStatusFrontendsForAssignedLine_FailClosedWhenUnassignedOrMissing(t *testing.T) { obs := authority.NewObservationHost(authority.ObservationHostConfig{}) if got := statusFrontendsForAssignedLine(obs, "v1", "r1", false); len(got) != 0 { diff --git a/seaweed-block/core/host/master/host.go b/seaweed-block/core/host/master/host.go index a4010c36b0..3d29b25f60 100644 --- a/seaweed-block/core/host/master/host.go +++ b/seaweed-block/core/host/master/host.go @@ -314,10 +314,11 @@ func (h *Host) ObservationHost() *authority.ObservationHost { return h.obs } // must not be treated as assignment authority. func (h *Host) Lifecycle() *LifecycleStores { return h.lifecycle } -// replicaSlotsFor returns the accepted-topology replica IDs for a -// volume, or nil if the volume isn't in accepted topology. Used -// by AssignmentService to fan-in per-(vol, rid) publisher -// subscriptions for volume-scoped delivery. +// replicaSlotsFor returns replica IDs for a volume. Static topology +// remains the allow-list. Dynamic lifecycle volumes may not persist +// placement slots in the lifecycle record, so read-only status paths +// merge fresh observed slots from the observation store; assignment +// authority still comes from the publisher/controller, not this helper. func (h *Host) replicaSlotsFor(volumeID string) []string { for _, v := range h.topo.Volumes { if v.VolumeID != volumeID { @@ -329,18 +330,34 @@ func (h *Host) replicaSlotsFor(volumeID string) []string { } return out } + var out []string if h.lifecycle != nil && h.lifecycle.Placements != nil { if placement, ok := h.lifecycle.Placements.GetPlacement(volumeID); ok { - out := make([]string, 0, len(placement.Slots)) for _, slot := range placement.Slots { if slot.ReplicaID != "" { - out = append(out, slot.ReplicaID) + out = appendReplicaID(out, slot.ReplicaID) } } - return out } } - return nil + if h.lifecycle != nil && h.obs != nil { + for _, replicaID := range h.obs.Store().ReplicaIDsForVolume(volumeID) { + out = appendReplicaID(out, replicaID) + } + } + if len(out) == 0 { + return nil + } + return out +} + +func appendReplicaID(in []string, replicaID string) []string { + for _, existing := range in { + if existing == replicaID { + return in + } + } + return append(in, replicaID) } // Start runs the publisher, observation rebuild loop, and gRPC diff --git a/seaweed-block/docs/roadmap.md b/seaweed-block/docs/roadmap.md index 409f44116a..8a3bba0e61 100644 --- a/seaweed-block/docs/roadmap.md +++ b/seaweed-block/docs/roadmap.md @@ -458,12 +458,13 @@ Recommended order from here: not be marked shipped until matching `seaweed-block` and `seaweed-block-csi` images are published from the same commit and pass the pinned-image Day-1 smoke. NVMe multipath is not part of this release claim. -58. Phase 100: Kubernetes CSI NVMe multipath attach. **Active** - The component slice preserves multiple NVMe frontend paths for one - NQN/NSID through master status, CSI publish context, and NodeStage - connection calls. This is not yet a live Kubernetes app-pod claim; the next - gate must prove dynamic PVC, mounted writer/reader I/O, and NVMe cleanup in - k3s. +58. Phase 100: Kubernetes CSI NVMe multipath attach. **Closed 2026-06-27, + live k3s PASS** + The supported lab path now proves dynamic PVC `protocol=nvme`, + `replicationFactor=2`, two NVMe frontend paths for one NQN/NSID, CSI + publish/NodeStage multipath attach, mounted writer/reader I/O, and zero + Seaweed Block NVMe residue after delete. This is not a RoCE, performance, + broad host compatibility, production HA, or soak claim. 59. Add backup/restore after it can reuse the same action owner, evidence, and status model rather than creating another isolated control plane. @@ -659,9 +660,9 @@ control-plane path is mature. 1. iSCSI and NVMe-oF are the current release-gated frontends. iSCSI remains the default path for broad compatibility. NVMe-oF is now - covered by ANA-aware direct-host multipath/failover and CSI - protocol-selection gates. Kubernetes CSI NVMe multipath attach remains the - next NVMe parity gap. + covered by ANA-aware direct-host multipath/failover, CSI protocol selection, + and a supported-lab Kubernetes CSI NVMe multipath attach gate. Broader host + compatibility, RoCE, performance, and soak remain future work. The runtime should be managed as a cluster of explicit mini-protocols: authority/epoch, replication recovery, iSCSI, NVMe, CSI lifecycle, and diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index c72abcceb4..d802786aa7 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,6 +1,6 @@ # Current Plan: Phase 100 Kubernetes CSI NVMe Multipath Attach -Status: active; D1/D2 component slice PASS. +Status: closed; D1/D2 component slice PASS, live Kubernetes gate PASS. ## Goal @@ -53,6 +53,8 @@ Added: ```text scripts/run-phase100-nvme-csi-multipath-component-gate.sh testops/scenarios/nvme-csi-multipath-component-chain.yaml +scripts/run-phase100-nvme-csi-multipath-live-gate.sh +testops/scenarios/nvme-csi-multipath-live-chain.yaml ``` The component gate proves: @@ -72,24 +74,47 @@ swblock run 20260627-013844-4a23: PASS, 10/10 actions go test ./core/frontend/nvme ./cmd/blockvolume ./core/csi ./core/launcher -count=1: PASS ``` +## D3/D4 Live Kubernetes Slice + +Implemented the live attach close gate: + +- dynamic PVC can request `protocol=nvme`, `replicationFactor=2`, and + `stage2_multipath=true`; +- CSI `CreateVolumeResponse.VolumeContext` carries the safe multipath attach + parameter forward into PV volume attributes; +- `ControllerPublish` preserves the multipath request in publish context; +- `NodeStage` performs a bounded refresh until `nvmeAddrs` contains at least two + portals, then connects each portal for the same NQN; +- dynamic lifecycle status can merge fresh observed replica IDs for read-only + publish-target aggregation when lifecycle records do not persist placement + slots; +- the live runner imports fresh local images to every schedulable node and + removes stale containerd tags before import. + +Verification: + +```text +swblock run testops/scenarios/nvme-csi-multipath-live-chain.yaml +run: 20260627-024451-2ee8 +result: PASS, 18/18 actions + +phase100_nvme_csi_multipath_live_status=ok +generated_nvme_listen_count=2 +generated_nqn_unique_count=1 +generated_nsid_unique_count=1 +node_stage_nvme_multipath_count=1 +node_stage_two_portals_count=1 +nvme_residue_count=0 +``` + ## Non-Claims -- no live Kubernetes app pod NVMe multipath claim yet; - no RoCE, performance, broad host compatibility, or production HA claim; - no automatic release claim for the operation milestone; - no backup/snapshot/restore. ## Next -After the component gate passes, continue Phase 100 with a live Kubernetes gate: - -```text -NVMe multipath frontend deployment - -> CSI dynamic PVC with protocol=nvme - -> NodeStage connects multiple paths for one NQN/NSID - -> writer/reader verifies mounted data - -> cleanup checks nvme subsystem/controller residue -``` - -The live gate should be the release-quality proof for the NVMe multipath attach -claim. +Phase 100 is closed for the supported lab path. The next NVMe work should not +expand the claim broadly yet; use a larger follow-up milestone for soak, +failure-path behavior, or ANA/CSI status surfacing if needed. diff --git a/seaweed-block/internal/docs/finished-plans/phase100_finishedplan_nvme_csi_multipath_attach.md b/seaweed-block/internal/docs/finished-plans/phase100_finishedplan_nvme_csi_multipath_attach.md new file mode 100644 index 0000000000..b1067f591e --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase100_finishedplan_nvme_csi_multipath_attach.md @@ -0,0 +1,71 @@ +# Phase 100 Finished Plan: Kubernetes CSI NVMe Multipath Attach + +Status: closed on 2026-06-27. + +## What Closed + +Phase 100 closed the first supported-lab Kubernetes NVMe multipath attach path: + +```text +dynamic PVC protocol=nvme, replicationFactor=2 + -> launcher emits two blockvolume frontends for one NQN/NSID + -> blockmaster status exposes a multipath publish target + -> CSI publish context carries nvmeAddrs + -> NodeStage connects both NVMe portal addresses + -> app pod writes/reads through the mounted namespace + -> PVC delete leaves no Seaweed Block NVMe subsystem residue +``` + +## Product Changes + +- `PublishTarget` and CSI publish context now carry `NVMeAddrs`. +- Master status lookup groups NVMe frontend paths only when they share one + `NQN` and `NSID`. +- CSI `CreateVolumeResponse.VolumeContext` carries `stage2_multipath=true` + forward from StorageClass parameters. +- `ControllerPublish` preserves the multipath request in publish context. +- `NodeStage` waits for refreshed NVMe multipath publish context and connects + every portal for the same NQN. +- Dynamic lifecycle status can use fresh observed replica IDs as read-only + evidence for publish-target aggregation. +- The live gate imports fresh local images to all schedulable nodes and removes + stale k3s/containerd tags before import. + +## Gates + +Component: + +```text +swblock run testops/scenarios/nvme-csi-multipath-component-chain.yaml +run: 20260627-013844-4a23 +result: PASS, 10/10 actions +``` + +Live Kubernetes: + +```text +swblock run testops/scenarios/nvme-csi-multipath-live-chain.yaml +run: 20260627-024451-2ee8 +result: PASS, 18/18 actions +``` + +Live summary: + +```text +phase100_nvme_csi_multipath_live_status=ok +dynamic_pvc_writer_reader=pass +generated_nvme_listen_count=2 +generated_nqn_unique_count=1 +generated_nsid_unique_count=1 +node_stage_nvme_multipath_count=1 +node_stage_two_portals_count=1 +nvme_residue_count=0 +``` + +## Non-Claims + +- No RoCE/RDMA claim. +- No performance or soak claim. +- No broad distro/kernel compatibility claim. +- No production HA claim. +- No backup/snapshot/restore claim. diff --git a/seaweed-block/internal/docs/product-roadmap.md b/seaweed-block/internal/docs/product-roadmap.md index b156f3901d..7cef97d2f5 100644 --- a/seaweed-block/internal/docs/product-roadmap.md +++ b/seaweed-block/internal/docs/product-roadmap.md @@ -57,13 +57,13 @@ This is the short internal roadmap. Keep it current and readable. evidence refs, cleanup visibility, safe next-step hints, and cross-surface agreement. This remains read-only and does not add mutating operator lifecycle. -- Current development slice: NVMe Kubernetes CSI multipath attach. The +- Recently closed development slice: NVMe Kubernetes CSI multipath attach. The returned-replica rebuild/reintegration/failback/frontend-publication operation loop reached a coherent close point at Phase 98, and Phase 99 pinned the - existing NVMe ANA/CSI baseline. Phase 100 starts the next storage feature by - preserving multiple NVMe frontend paths for one NQN/NSID through master - status, CSI publish context, and NodeStage. Live Kubernetes writer/reader - evidence remains the next gate before any NVMe multipath release claim. + existing NVMe ANA/CSI baseline. Phase 100 closed the next storage feature for + the supported lab path: multiple NVMe frontend paths for one NQN/NSID now + survive dynamic PVC provisioning, master status, CSI publish context, + NodeStage, app writer/reader I/O, and delete cleanup. Phases 46-67 made returned replicas visible, fenced, action-gated, rebuild/catch-up-capable, terminal-evidence-driven, and ACK-eligibility-published. Phases 68-98 then @@ -786,11 +786,11 @@ Approximate engineering effort if scope remains tight: plus the published-image Day-1 smoke before marking the operation milestone released. Development has moved ahead in parallel; this does not mark the operation milestone released. -- Phase 100 Kubernetes CSI NVMe Multipath Attach is active. The current slice - implements and gates the component path from master NVMe frontend grouping to - CSI `nvmeAddrs` publish context and NodeStage multi-address connect. A live - k3s dynamic-PVC writer/reader gate is still required before claiming - Kubernetes NVMe multipath attach. +- Phase 100 Kubernetes CSI NVMe Multipath Attach is closed. It implements and + gates the path from dynamic PVC `protocol=nvme` and `replicationFactor=2` to + master NVMe frontend grouping, CSI `nvmeAddrs` publish context, NodeStage + multi-address connect, mounted writer/reader I/O, and zero NVMe residue after + delete in the supported lab. - Phase 41-44 are the Operation Layer v0.5 release train: lifecycle-owner foundation, real API/admission proof, first bounded finalizer mutation, and delete lifecycle close gate. diff --git a/seaweed-block/internal/docs/qa-assignments/phase100-nvme-csi-multipath-live-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase100-nvme-csi-multipath-live-qa-signoff.md new file mode 100644 index 0000000000..160ca76c20 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase100-nvme-csi-multipath-live-qa-signoff.md @@ -0,0 +1,85 @@ +# Phase 100 NVMe CSI Multipath Live QA Sign-off + +Status: PASS. + +Validated source: current Phase 100 working tree before commit. + +## Scope + +This gate validates the live Kubernetes path: + +```text +dynamic PVC protocol=nvme, replicationFactor=2 + -> launcher creates two NVMe frontends for one NQN/NSID + -> CSI ControllerPublish/NodeStage preserve the multipath requirement + -> NodeStage connects both NVMe portal addresses + -> app pod writes and reads through the mounted namespace + -> PVC delete leaves no Seaweed Block NVMe subsystem residue +``` + +## Evidence + +Runner: + +```text +swblock run testops/scenarios/nvme-csi-multipath-live-chain.yaml +run: 20260627-024451-2ee8 +result: PASS, 18/18 actions +``` + +Summary: + +```text +phase100_nvme_csi_multipath_live_status=ok +dynamic_pvc_writer_reader=pass +generated_nvme_listen_count=2 +generated_nqn_unique_count=1 +generated_nsid_unique_count=1 +generated_iscsi_arg_count=0 +node_stage_nvme_multipath_count=1 +node_stage_two_portals_count=1 +run_pass_count=1 +nvme_residue_count=0 +``` + +NodeStage evidence: + +```text +NodeStageVolume: ... staged transport=nvme + portal=127.0.0.1:4420 + portals=127.0.0.1:4420,127.0.0.1:4421 + multipath=true +``` + +Cleanup evidence: + +```text +nvme_residue_count=0 +kubectl get pv,pvc,pod -A: no Seaweed Block test residue +``` + +## Findings Closed During The Gate + +- Dynamic PVC multipath required `stage2_multipath` to flow through + `CreateVolumeResponse.VolumeContext`, `ControllerPublish` publish context, and + `NodeStage` bounded refresh. Without that, the app path worked but staged only + one NVMe portal. +- Dynamic lifecycle status needed fresh observed replica IDs as a read-only + fallback for CSI publish-target aggregation. Static topology remains the + allow-list for static volumes. +- The live gate must import `:local` images to every schedulable node and remove + stale containerd tags before import. Otherwise k3s may run old `sw-block` or + `sw-block-csi` binaries even after a fresh Docker build. + +## Non-Claims + +- No RoCE/RDMA transport claim. +- No performance claim. +- No broad distro/kernel compatibility claim. +- No production HA or long soak claim. + +## Verdict + +PASS. Phase 100 closes the Kubernetes CSI NVMe multipath attach slice for the +supported lab path: dynamic PVC, two NVMe paths for one NQN/NSID, mounted +writer/reader, and zero NVMe residue after delete. diff --git a/seaweed-block/scripts/build-alpha-images.sh b/seaweed-block/scripts/build-alpha-images.sh index e43245e39e..32ea39ce99 100755 --- a/seaweed-block/scripts/build-alpha-images.sh +++ b/seaweed-block/scripts/build-alpha-images.sh @@ -10,6 +10,7 @@ IMPORT_K3S_NODES="${SW_BLOCK_IMPORT_K3S_NODES:-}" IMPORT_K3S_SSH_USER="${SW_BLOCK_IMPORT_K3S_SSH_USER:-${USER:-}}" IMPORT_K3S_SSH_KEY="${SW_BLOCK_IMPORT_K3S_SSH_KEY:-}" IMPORT_K3S_REMOTE_DIR="${SW_BLOCK_IMPORT_K3S_REMOTE_DIR:-/tmp/sw-block-alpha-images}" +DOCKER_NO_CACHE="${SW_BLOCK_DOCKER_NO_CACHE:-0}" if [[ -n "$ARTIFACT_DIR" ]]; then mkdir -p "$ARTIFACT_DIR" @@ -20,9 +21,15 @@ echo "[alpha-build] image=$IMAGE" echo "[alpha-build] csi_image=$CSI_IMAGE" echo "[alpha-build] import_k3s=$IMPORT_K3S" echo "[alpha-build] import_k3s_nodes=${IMPORT_K3S_NODES:-}" +echo "[alpha-build] docker_no_cache=$DOCKER_NO_CACHE" -docker build -t "$IMAGE" -f "$ROOT/deploy/k8s/g15b/Dockerfile.sw-block" "$ROOT" -docker build -t "$CSI_IMAGE" -f "$ROOT/deploy/k8s/g15b/Dockerfile.blockcsi" "$ROOT" +docker_build_args=() +if [[ "$DOCKER_NO_CACHE" == "1" || "$DOCKER_NO_CACHE" == "true" ]]; then + docker_build_args+=(--no-cache) +fi + +docker build "${docker_build_args[@]}" -t "$IMAGE" -f "$ROOT/deploy/k8s/g15b/Dockerfile.sw-block" "$ROOT" +docker build "${docker_build_args[@]}" -t "$CSI_IMAGE" -f "$ROOT/deploy/k8s/g15b/Dockerfile.blockcsi" "$ROOT" record_build_evidence() { [[ -n "$ARTIFACT_DIR" ]] || return 0 @@ -32,6 +39,7 @@ record_build_evidence() { echo "SW_BLOCK_CSI_IMAGE=$CSI_IMAGE" echo "SW_BLOCK_IMPORT_K3S=$IMPORT_K3S" echo "SW_BLOCK_IMPORT_K3S_NODES=$IMPORT_K3S_NODES" + echo "SW_BLOCK_DOCKER_NO_CACHE=$DOCKER_NO_CACHE" echo "SW_BLOCK_IMAGE_ID=$(docker image inspect "$IMAGE" --format '{{.Id}}')" echo "SW_BLOCK_CSI_IMAGE_ID=$(docker image inspect "$CSI_IMAGE" --format '{{.Id}}')" if git -C "$ROOT" rev-parse --git-dir >/dev/null 2>&1; then @@ -52,16 +60,21 @@ import_k3s_image() { local image="$1" local log_name="$2" local -a ctr=() + local -a ctr_rm=() if command -v sudo >/dev/null 2>&1 && sudo -n k3s --version >/dev/null 2>&1; then ctr=(sudo -n k3s ctr -n k8s.io images import -) + ctr_rm=(sudo -n k3s ctr -n k8s.io images rm) elif command -v k3s >/dev/null 2>&1 && k3s --version >/dev/null 2>&1; then ctr=(k3s ctr -n k8s.io images import -) + ctr_rm=(k3s ctr -n k8s.io images rm) else echo "SW_BLOCK_IMPORT_K3S=1 requires k3s or passwordless sudo k3s on PATH" >&2 exit 2 fi echo "[alpha-build] k3s_import image=$image" + "${ctr_rm[@]}" "$image" >/dev/null 2>&1 || true + "${ctr_rm[@]}" "docker.io/library/$image" >/dev/null 2>&1 || true if [[ -n "$ARTIFACT_DIR" ]]; then docker save "$image" | "${ctr[@]}" >"$ARTIFACT_DIR/$log_name" 2>&1 else @@ -132,6 +145,7 @@ import_k3s_image_to_node() { echo "[alpha-build] k3s_import image=$image node=$node" if [[ -n "$ARTIFACT_DIR" ]]; then { + run_ssh "$target" "sudo -n k3s ctr -n k8s.io images rm '$image' >/dev/null 2>&1 || true; sudo -n k3s ctr -n k8s.io images rm 'docker.io/library/$image' >/dev/null 2>&1 || true" run_ssh "$target" "mkdir -p '$IMPORT_K3S_REMOTE_DIR'" docker save "$image" | run_ssh "$target" "cat > '$IMPORT_K3S_REMOTE_DIR/$tar_name'" run_ssh "$target" "sudo -n k3s ctr -n k8s.io images import '$IMPORT_K3S_REMOTE_DIR/$tar_name'" @@ -139,6 +153,7 @@ import_k3s_image_to_node() { run_ssh "$target" "rm -f '$IMPORT_K3S_REMOTE_DIR/$tar_name'" } >"$ARTIFACT_DIR/$log_name" 2>&1 else + run_ssh "$target" "sudo -n k3s ctr -n k8s.io images rm '$image' >/dev/null 2>&1 || true; sudo -n k3s ctr -n k8s.io images rm 'docker.io/library/$image' >/dev/null 2>&1 || true" run_ssh "$target" "mkdir -p '$IMPORT_K3S_REMOTE_DIR'" docker save "$image" | run_ssh "$target" "cat > '$IMPORT_K3S_REMOTE_DIR/$tar_name'" run_ssh "$target" "sudo -n k3s ctr -n k8s.io images import '$IMPORT_K3S_REMOTE_DIR/$tar_name'" diff --git a/seaweed-block/scripts/run-g15d-k8s-dynamic.sh b/seaweed-block/scripts/run-g15d-k8s-dynamic.sh index 25c64be7f2..24856ee14e 100755 --- a/seaweed-block/scripts/run-g15d-k8s-dynamic.sh +++ b/seaweed-block/scripts/run-g15d-k8s-dynamic.sh @@ -23,6 +23,9 @@ CHAP_USERNAME="${SW_BLOCK_ISCSI_CHAP_USERNAME:-}" CHAP_SECRET="${SW_BLOCK_ISCSI_CHAP_SECRET:-}" CHAP_SECRET_NAME="${SW_BLOCK_ISCSI_CHAP_SECRET_NAME:-sw-block-iscsi-chap}" FRONTEND_PROTOCOL="${SW_BLOCK_FRONTEND_PROTOCOL:-iscsi}" +STAGE2_MULTIPATH="${SW_BLOCK_STAGE2_MULTIPATH:-0}" +DYNAMIC_REPLICATION_FACTOR="${SW_BLOCK_DYNAMIC_REPLICATION_FACTOR:-}" +SAME_NODE_LOGICAL_REPLICAS="${SW_BLOCK_SAME_NODE_LOGICAL_REPLICAS:-1}" BLOCKVOLUME_NAMESPACE="kube-system" if [[ "$LAUNCHER_PVC_OWNER_REF" == "1" || "$LAUNCHER_PVC_OWNER_REF" == "true" ]]; then BLOCKVOLUME_NAMESPACE="$NAMESPACE" @@ -43,6 +46,32 @@ if [[ "$FRONTEND_PROTOCOL" == "nvme" && "$CHAP_ENABLED" == "1" ]]; then echo "iSCSI CHAP is not compatible with SW_BLOCK_FRONTEND_PROTOCOL=nvme" >&2 exit 2 fi +if [[ "$STAGE2_MULTIPATH" != "0" && "$STAGE2_MULTIPATH" != "1" && "$STAGE2_MULTIPATH" != "true" ]]; then + echo "SW_BLOCK_STAGE2_MULTIPATH must be 0, 1, or true; got: $STAGE2_MULTIPATH" >&2 + exit 2 +fi +case "$SAME_NODE_LOGICAL_REPLICAS" in + ''|*[!0-9]*) + echo "SW_BLOCK_SAME_NODE_LOGICAL_REPLICAS must be a positive integer; got: $SAME_NODE_LOGICAL_REPLICAS" >&2 + exit 2 + ;; +esac +if [[ "$SAME_NODE_LOGICAL_REPLICAS" -lt 1 ]]; then + echo "SW_BLOCK_SAME_NODE_LOGICAL_REPLICAS must be >= 1; got: $SAME_NODE_LOGICAL_REPLICAS" >&2 + exit 2 +fi +if [[ -n "$DYNAMIC_REPLICATION_FACTOR" ]]; then + case "$DYNAMIC_REPLICATION_FACTOR" in + *[!0-9]*) + echo "SW_BLOCK_DYNAMIC_REPLICATION_FACTOR must be a positive integer; got: $DYNAMIC_REPLICATION_FACTOR" >&2 + exit 2 + ;; + esac + if [[ "$DYNAMIC_REPLICATION_FACTOR" -lt 1 ]]; then + echo "SW_BLOCK_DYNAMIC_REPLICATION_FACTOR must be >= 1; got: $DYNAMIC_REPLICATION_FACTOR" >&2 + exit 2 + fi +fi mkdir -p "$ARTIFACT_DIR" if [[ -n "$ALPHA_IMAGES_ENV" ]]; then @@ -103,6 +132,43 @@ sed -e "s/__NODE_NAME__/${NODE_NAME}/g" \ -e "s/sw-block:local/${IMAGE_SED}/g" \ -e "s/imagePullPolicy: Never/imagePullPolicy: IfNotPresent/g" \ "$ROOT/deploy/k8s/g15d/block-stack.yaml" >"$STACK_RENDERED" +if [[ "$SAME_NODE_LOGICAL_REPLICAS" -gt 1 ]]; then + SW_BLOCK_G15D_NODE_NAME="$NODE_NAME" SW_BLOCK_G15D_REPLICAS="$SAME_NODE_LOGICAL_REPLICAS" python3 - "$STACK_RENDERED" <<'PY' +import os +import re +import sys + +path = sys.argv[1] +node = os.environ["SW_BLOCK_G15D_NODE_NAME"] +replicas = int(os.environ["SW_BLOCK_G15D_REPLICAS"]) +raw = open(path, encoding="utf-8").read() +nodes = [" nodes:"] +for i in range(replicas): + idx = i + 1 + nodes.extend([ + f" - server_id: {node}-r{idx}", + f" data_addr: 127.0.0.1:{19101 + (i * 10)}", + f" ctrl_addr: 127.0.0.1:{19102 + (i * 10)}", + " labels:", + f" kubernetes.io/hostname: {node}", + " pools:", + " - pool_id: default", + " total_bytes: 1073741824", + " free_bytes: 1073741824", + " block_size: 4096", + ]) +replacement = "\n".join(nodes) +raw = re.sub( + r" nodes:\n(?: .*\n| .*\n| .*\n)*?---", + replacement + "\n---", + raw, + count=1, +) +raw = raw.replace('--expected-slots-per-volume=1', f'--expected-slots-per-volume={replicas}') +open(path, "w", encoding="utf-8").write(raw) +PY + grep -q -- "--expected-slots-per-volume=${SAME_NODE_LOGICAL_REPLICAS}" "$STACK_RENDERED" || { echo "failed to configure same-node logical replica count" >&2; exit 1; } +fi if [[ "$BLOCKVOLUME_NAMESPACE" != "kube-system" ]]; then awk '/--launcher-namespace=/{print; print " - \"--launcher-pvc-owner-ref\""; next} {print}' "$STACK_RENDERED" >"$STACK_RENDERED.tmp" mv "$STACK_RENDERED.tmp" "$STACK_RENDERED" @@ -126,10 +192,41 @@ if [[ "$BLOCKVOLUME_NAMESPACE" != "kube-system" ]]; then mv "$CSI_CONTROLLER_RENDERED.tmp" "$CSI_CONTROLLER_RENDERED" grep -q -- '--kubernetes-pvc-uid-lookup' "$CSI_CONTROLLER_RENDERED" || { echo "failed to inject --kubernetes-pvc-uid-lookup into $CSI_CONTROLLER_RENDERED" >&2; exit 1; } fi +if [[ "$STAGE2_MULTIPATH" == "1" || "$STAGE2_MULTIPATH" == "true" ]]; then + awk '/--node-id=\$\(NODE_NAME\)/{print; print " - \"--stage2-multipath\""; next} {print}' "$CSI_CONTROLLER_RENDERED" >"$CSI_CONTROLLER_RENDERED.tmp" + mv "$CSI_CONTROLLER_RENDERED.tmp" "$CSI_CONTROLLER_RENDERED" + grep -q -- '--stage2-multipath' "$CSI_CONTROLLER_RENDERED" || { echo "failed to inject --stage2-multipath into $CSI_CONTROLLER_RENDERED" >&2; exit 1; } +fi sed -e "s/sw-block-csi:local/${CSI_IMAGE_SED}/g" \ -e "s/imagePullPolicy: Never/imagePullPolicy: IfNotPresent/g" \ "$ROOT/deploy/k8s/g15b/csi-node.yaml" >"$CSI_NODE_RENDERED" +if [[ "$STAGE2_MULTIPATH" == "1" || "$STAGE2_MULTIPATH" == "true" ]]; then + awk '/--node-id=\$\(NODE_NAME\)/{print; print " - \"--stage2-multipath\""; next} {print}' "$CSI_NODE_RENDERED" >"$CSI_NODE_RENDERED.tmp" + mv "$CSI_NODE_RENDERED.tmp" "$CSI_NODE_RENDERED" + grep -q -- '--stage2-multipath' "$CSI_NODE_RENDERED" || { echo "failed to inject --stage2-multipath into $CSI_NODE_RENDERED" >&2; exit 1; } +fi cp "$DYNAMIC_PVC_MANIFEST" "$DYNAMIC_RENDERED" +if [[ -n "$DYNAMIC_REPLICATION_FACTOR" ]]; then + awk -v rf="$DYNAMIC_REPLICATION_FACTOR" ' + /^ replicationFactor:/ { print " replicationFactor: \"" rf "\""; next } + { print } + ' "$DYNAMIC_RENDERED" >"$DYNAMIC_RENDERED.tmp" + mv "$DYNAMIC_RENDERED.tmp" "$DYNAMIC_RENDERED" + grep -q "replicationFactor: \"${DYNAMIC_REPLICATION_FACTOR}\"" "$DYNAMIC_RENDERED" || { echo "failed to override dynamic replicationFactor" >&2; exit 1; } +fi +if [[ "$SAME_NODE_LOGICAL_REPLICAS" -gt 1 ]]; then + awk -v node="$NODE_NAME" ' + /^ restartPolicy:/ { + print " nodeSelector:" + print " kubernetes.io/hostname: " node + print + next + } + { print } + ' "$DYNAMIC_RENDERED" >"$DYNAMIC_RENDERED.tmp" + mv "$DYNAMIC_RENDERED.tmp" "$DYNAMIC_RENDERED" + grep -q "kubernetes.io/hostname: ${NODE_NAME}" "$DYNAMIC_RENDERED" || { echo "failed to pin dynamic pod to same-node NVMe target host" >&2; exit 1; } +fi if [[ "$CHAP_ENABLED" == "1" ]]; then awk -v secret="$CHAP_SECRET_NAME" -v ns="$NAMESPACE" ' /^parameters:/ { @@ -154,6 +251,17 @@ if [[ "$FRONTEND_PROTOCOL" == "nvme" ]]; then ' "$DYNAMIC_RENDERED" >"$DYNAMIC_RENDERED.tmp" mv "$DYNAMIC_RENDERED.tmp" "$DYNAMIC_RENDERED" fi +if [[ "$STAGE2_MULTIPATH" == "1" || "$STAGE2_MULTIPATH" == "true" ]]; then + awk ' + /^parameters:/ { + print + print " stage2_multipath: \"true\"" + next + } + {print} + ' "$DYNAMIC_RENDERED" >"$DYNAMIC_RENDERED.tmp" + mv "$DYNAMIC_RENDERED.tmp" "$DYNAMIC_RENDERED" +fi log "artifact_dir=$ARTIFACT_DIR" if [[ -n "$ALPHA_IMAGES_ENV" ]]; then @@ -169,6 +277,9 @@ log "launcher_pvc_owner_ref=$LAUNCHER_PVC_OWNER_REF" log "launcher_state_hostpath=${LAUNCHER_STATE_HOSTPATH:-}" log "chap_enabled=$CHAP_ENABLED" log "frontend_protocol=$FRONTEND_PROTOCOL" +log "stage2_multipath=$STAGE2_MULTIPATH" +log "dynamic_replication_factor=${DYNAMIC_REPLICATION_FACTOR:-manifest-default}" +log "same_node_logical_replicas=$SAME_NODE_LOGICAL_REPLICAS" log "expected_git_revision=${EXPECTED_GIT_REVISION:-unknown}" log "dynamic_pvc_manifest=$DYNAMIC_PVC_MANIFEST" kubectl version --client=true >"$ARTIFACT_DIR/kubectl-version.txt" 2>&1 || true @@ -197,6 +308,12 @@ collect_daemon_logs() { capture_once "$ARTIFACT_DIR/pod.log" kubectl -n "$NAMESPACE" logs sw-block-dynamic-smoke capture_once "$ARTIFACT_DIR/blockmaster.log" kubectl -n kube-system logs deploy/sw-blockmaster -c blockmaster capture_once "$ARTIFACT_DIR/blockcsi-controller.log" kubectl -n kube-system logs deploy/sw-block-csi-controller -c block-csi + { + for pod in $(kubectl -n kube-system get pod -l app=sw-block-csi-node -o name 2>/dev/null); do + echo "### $pod" + kubectl -n kube-system logs "$pod" -c block-csi --tail=-1 2>&1 || true + done + } >"$ARTIFACT_DIR/blockcsi-node.log" 2>&1 || true capture_once "$ARTIFACT_DIR/csi-provisioner.log" kubectl -n kube-system logs deploy/sw-block-csi-controller -c csi-provisioner capture_once "$ARTIFACT_DIR/csi-attacher.log" kubectl -n kube-system logs deploy/sw-block-csi-controller -c csi-attacher capture_once "$ARTIFACT_DIR/blockvolume-generated.log" kubectl -n "$BLOCKVOLUME_NAMESPACE" logs -l sw-block.seaweedfs.com/volume -c blockvolume --tail=-1 diff --git a/seaweed-block/scripts/run-phase100-nvme-csi-multipath-live-gate.sh b/seaweed-block/scripts/run-phase100-nvme-csi-multipath-live-gate.sh new file mode 100644 index 0000000000..cf950e7e2b --- /dev/null +++ b/seaweed-block/scripts/run-phase100-nvme-csi-multipath-live-gate.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +set -euo pipefail + +PRODUCT_ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase100-nvme-csi-multipath-live-gate}" +SUMMARY="${ARTIFACT_DIR}/phase100-nvme-csi-multipath-live-summary.txt" +LIVE_DIR="${ARTIFACT_DIR}/live" + +mkdir -p "${ARTIFACT_DIR}" +: >"${SUMMARY}" + +write_summary() { + echo "$*" | tee -a "${SUMMARY}" >/dev/null +} + +count_pattern() { + local path="$1" + local pattern="$2" + grep -Ec -- "$pattern" "$path" 2>/dev/null || true +} + +write_summary "phase100_nvme_csi_multipath_live_status=running" +write_summary "phase100_scope=live_k8s_dynamic_pvc_nvme_multipath_attach" +write_summary "replication_factor=2" +write_summary "same_node_logical_replicas=2" + +if ! ( + cd "${PRODUCT_ROOT}" + SW_BLOCK_FRONTEND_PROTOCOL=nvme \ + SW_BLOCK_STAGE2_MULTIPATH=1 \ + SW_BLOCK_DYNAMIC_REPLICATION_FACTOR=2 \ + SW_BLOCK_SAME_NODE_LOGICAL_REPLICAS=2 \ + SW_BLOCK_LAUNCHER_PVC_OWNER_REF=1 \ + SW_BLOCK_RUN_LABEL=phase100-nvme-multipath \ + SW_BLOCK_ARTIFACT_DIR="${LIVE_DIR}" \ + bash scripts/run-alpha-k8s-dynamic.sh "${PRODUCT_ROOT}" +); then + write_summary "phase100_nvme_csi_multipath_live_status=failed" + exit 1 +fi + +write_summary "dynamic_pvc_writer_reader=pass" + +GENERATED="${LIVE_DIR}/generated-blockvolume.yaml" +CSI_NODE_LOG="${LIVE_DIR}/blockcsi-node.log" +RUN_LOG="${LIVE_DIR}/run.log" +NVME_AFTER="${LIVE_DIR}/nvme-list-subsys.after-delete.json" + +nvme_listen_count="$(count_pattern "${GENERATED}" "--nvme-listen=")" +nqn_unique_count="$(grep -Eo -- '--nvme-subsysnqn=[^", ]+' "${GENERATED}" 2>/dev/null | sort -u | wc -l | tr -d ' ')" +nsid_unique_count="$(grep -Eo -- '--nvme-ns=[0-9]+' "${GENERATED}" 2>/dev/null | sort -u | wc -l | tr -d ' ')" +iscsi_arg_count="$(count_pattern "${GENERATED}" "--iscsi-listen=")" +node_stage_multipath_count="$(count_pattern "${CSI_NODE_LOG}" "transport=nvme.*multipath=true|multipath=true.*transport=nvme")" +node_stage_two_portals_count="$(count_pattern "${CSI_NODE_LOG}" "portals=[^[:space:]]*,[^[:space:]]*")" +run_pass_count="$(count_pattern "${RUN_LOG}" "PASS: dynamic PVC create/delete completed checksum write/read and cleanup")" +nvme_residue_count="$(count_pattern "${NVME_AFTER}" "nqn\\.2026-05\\.io\\.seaweedfs")" + +write_summary "generated_nvme_listen_count=${nvme_listen_count}" +write_summary "generated_nqn_unique_count=${nqn_unique_count}" +write_summary "generated_nsid_unique_count=${nsid_unique_count}" +write_summary "generated_iscsi_arg_count=${iscsi_arg_count}" +write_summary "node_stage_nvme_multipath_count=${node_stage_multipath_count}" +write_summary "node_stage_two_portals_count=${node_stage_two_portals_count}" +write_summary "run_pass_count=${run_pass_count}" +write_summary "nvme_residue_count=${nvme_residue_count}" + +if [[ "${nvme_listen_count}" -lt 2 ]]; then + echo "expected at least two generated NVMe listen paths, got ${nvme_listen_count}" >&2 + exit 1 +fi +if [[ "${nqn_unique_count}" != "1" || "${nsid_unique_count}" != "1" ]]; then + echo "expected one shared NQN/NSID across generated NVMe paths, got nqn=${nqn_unique_count} nsid=${nsid_unique_count}" >&2 + exit 1 +fi +if [[ "${iscsi_arg_count}" != "0" ]]; then + echo "NVMe gate rendered iSCSI args" >&2 + exit 1 +fi +if [[ "${node_stage_multipath_count}" -lt 1 || "${node_stage_two_portals_count}" -lt 1 ]]; then + echo "CSI NodeStage did not report NVMe multipath with two portals" >&2 + exit 1 +fi +if [[ "${run_pass_count}" -lt 1 ]]; then + echo "dynamic PVC run did not report PASS" >&2 + exit 1 +fi +if [[ "${nvme_residue_count}" != "0" ]]; then + echo "dangling Seaweed Block NVMe subsystem after delete" >&2 + exit 1 +fi + +write_summary "phase100_nvme_csi_multipath_live_status=ok" diff --git a/seaweed-block/testops/scenarios/nvme-csi-multipath-live-chain.yaml b/seaweed-block/testops/scenarios/nvme-csi-multipath-live-chain.yaml new file mode 100644 index 0000000000..50eb64b8b8 --- /dev/null +++ b/seaweed-block/testops/scenarios/nvme-csi-multipath-live-chain.yaml @@ -0,0 +1,107 @@ +name: nvme-csi-multipath-live-chain +timeout: 30m + +env: + product_root: "/tmp/seaweed_block" + ssh_key: "C:\\work\\dev_server\\testdev_key" + +topology: + nodes: + m02: + host: 192.168.1.184 + user: testdev + key: "{{ ssh_key }}" + +phases: + - name: pre_clean + actions: + - action: pre_run_cleanup + node: m02 + kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target" + nvme_disconnect: "true" + iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs" + - action: exec + node: m02 + cmd: "kubectl -n default delete pod sw-block-dynamic-smoke --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-dynamic-v1 --ignore-not-found=true --wait=true --timeout=120s; kubectl get pv --no-headers 2>/dev/null | awk '$6==\"sw-block-dynamic\" {print $1}' | xargs -r -I{} kubectl patch pv {} --type=merge -p '{\"metadata\":{\"finalizers\":null}}'; kubectl get pv --no-headers 2>/dev/null | awk '$6==\"sw-block-dynamic\" {print $1}' | xargs -r kubectl delete pv --ignore-not-found=true --wait=false; kubectl delete storageclass sw-block-dynamic --ignore-not-found=true; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live" + - action: assert_no_active_iscsi_sessions + node: m02 + iqn_substr: "io.seaweedfs" + + - name: pin_build_alpha_images + actions: + - action: exec + node: m02 + timeout: 8m + cmd: "cd {{ product_root }} && bash scripts/build-alpha-images.sh {{ product_root }}" + env.SW_BLOCK_IMPORT_K3S: "1" + env.SW_BLOCK_IMPORT_K3S_NODES: "192.168.1.181" + env.SW_BLOCK_IMPORT_K3S_SSH_USER: "testdev" + env.SW_BLOCK_IMPORT_K3S_SSH_KEY: "{{ ssh_key }}" + env.SW_BLOCK_DOCKER_NO_CACHE: "1" + env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live/pin_build" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live/pin_build/alpha-images.env" + pattern: "SW_BLOCK_IMAGE_ID=" + save_as: pin_image_id_count + - action: assert_greater + actual: "{{ pin_image_id_count }}" + threshold: "0" + + - name: nvme_multipath_dynamic_pvc + actions: + - action: exec + node: m02 + timeout: 15m + cmd: "cd {{ product_root }} && bash scripts/run-phase100-nvme-csi-multipath-live-gate.sh {{ product_root }}" + env.SW_BLOCK_ALPHA_IMAGES_ENV: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live/pin_build/alpha-images.env" + env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live/live_gate" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live/live_gate/phase100-nvme-csi-multipath-live-summary.txt" + pattern: "^phase100_nvme_csi_multipath_live_status=ok$" + save_as: live_ok + - action: assert_greater + actual: "{{ live_ok }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live/live_gate/phase100-nvme-csi-multipath-live-summary.txt" + pattern: "^generated_nvme_listen_count=2$" + save_as: two_nvme_paths + - action: assert_greater + actual: "{{ two_nvme_paths }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live/live_gate/phase100-nvme-csi-multipath-live-summary.txt" + pattern: "^node_stage_nvme_multipath_count=[1-9][0-9]*$" + save_as: node_stage_multipath + - action: assert_greater + actual: "{{ node_stage_multipath }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live/live_gate/phase100-nvme-csi-multipath-live-summary.txt" + pattern: "^nvme_residue_count=0$" + save_as: nvme_clean + - action: assert_greater + actual: "{{ nvme_clean }}" + threshold: "0" + + - name: collect_and_cleanup + always: true + actions: + - action: pre_run_cleanup + node: m02 + kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target" + nvme_disconnect: "true" + iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs" + - action: exec + node: m02 + cmd: "kubectl -n default delete pod sw-block-dynamic-smoke --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-dynamic-v1 --ignore-not-found=true --wait=true --timeout=120s; kubectl get pv --no-headers 2>/dev/null | awk '$6==\"sw-block-dynamic\" {print $1}' | xargs -r -I{} kubectl patch pv {} --type=merge -p '{\"metadata\":{\"finalizers\":null}}'; kubectl get pv --no-headers 2>/dev/null | awk '$6==\"sw-block-dynamic\" {print $1}' | xargs -r kubectl delete pv --ignore-not-found=true --wait=false; kubectl delete storageclass sw-block-dynamic --ignore-not-found=true" + - action: collect_path + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase100-nvme-csi-multipath-live" + name: "remote-phases" + ignore_error: true