mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
phase166: add nvme rdma multipath reconnect contract
This commit is contained in:
1 parent
9e21e53637
commit
cfd686d34a
15 files changed
+1635
-152
No files matched your search
@@ -122,7 +122,9 @@ func publishContext(t PublishTarget) map[string]string {
|
||||
ctx["protocol"] = string(t.Protocol)
|
||||
}
|
||||
if t.Protocol == ProtocolNVMe {
|
||||
ctx["nvmeTransport"] = string(normalizeFrontendTransport(t.Protocol, t.FrontendTransport))
|
||||
if t.FrontendTransport != "" {
|
||||
ctx["nvmeTransport"] = string(t.FrontendTransport)
|
||||
}
|
||||
}
|
||||
if t.ISCSIAddr != "" && t.IQN != "" {
|
||||
ctx["iscsiAddr"] = t.ISCSIAddr
|
||||
|
||||
@@ -367,12 +367,12 @@ func (r *realNVMeUtil) IsConnected(ctx context.Context, nqn string) (bool, error
|
||||
return nvmeSubsystemPathCount(doc, nqn) > 0, nil
|
||||
}
|
||||
|
||||
func (r *realNVMeUtil) IsPathConnected(ctx context.Context, nqn, addr string) (bool, error) {
|
||||
func (r *realNVMeUtil) IsPathConnected(ctx context.Context, nqn string, transport FrontendTransport, addr string) (bool, error) {
|
||||
doc, err := nvmeListSubsystems(ctx)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return nvmeSubsystemHasPath(doc, nqn, addr), nil
|
||||
return nvmeSubsystemHasPath(doc, nqn, transport, addr), nil
|
||||
}
|
||||
|
||||
func (r *realNVMeUtil) ListPaths(ctx context.Context, nqn string) ([]NVMeConnectedPath, error) {
|
||||
@@ -439,7 +439,7 @@ func nvmeSubsystemPathCount(doc any, nqn string) int {
|
||||
return total
|
||||
}
|
||||
|
||||
func nvmeSubsystemHasPath(doc any, nqn, addr string) bool {
|
||||
func nvmeSubsystemHasPath(doc any, nqn string, transport FrontendTransport, addr string) bool {
|
||||
host, port, err := splitHostPort(addr)
|
||||
if err != nil {
|
||||
return false
|
||||
@@ -451,6 +451,14 @@ func nvmeSubsystemHasPath(doc any, nqn, addr string) bool {
|
||||
paths, _ := sub["Paths"].([]any)
|
||||
for _, path := range paths {
|
||||
pathMap, _ := path.(map[string]any)
|
||||
pathTransport, _ := pathMap["Transport"].(string)
|
||||
if FrontendTransport(strings.ToLower(pathTransport)) != transport {
|
||||
continue
|
||||
}
|
||||
pathState, _ := pathMap["State"].(string)
|
||||
if !strings.EqualFold(pathState, "live") {
|
||||
continue
|
||||
}
|
||||
rawAddr, _ := pathMap["Address"].(string)
|
||||
if rawAddr == "" {
|
||||
continue
|
||||
@@ -483,7 +491,12 @@ func nvmeSubsystemPaths(doc any, nqn string) []NVMeConnectedPath {
|
||||
if addr == "" && controller == "" {
|
||||
continue
|
||||
}
|
||||
out = append(out, NVMeConnectedPath{Addr: addr, Controller: controller})
|
||||
pathTransport, _ := pathMap["Transport"].(string)
|
||||
out = append(out, NVMeConnectedPath{
|
||||
Addr: addr,
|
||||
Controller: controller,
|
||||
Transport: FrontendTransport(strings.ToLower(pathTransport)),
|
||||
})
|
||||
}
|
||||
}
|
||||
return out
|
||||
|
||||
@@ -60,19 +60,27 @@ func TestNVMeSubsystemHasPathRequiresTargetAddressNotSourceAddress(t *testing.T)
|
||||
"NQN": "nqn.2026-05.io.seaweedfs:v1",
|
||||
"Paths": []any{
|
||||
map[string]any{
|
||||
"Address": "traddr=192.168.1.181,trsvcid=4420,src_addr=192.168.1.184",
|
||||
"State": "live",
|
||||
"Address": "traddr=192.168.1.181,trsvcid=4420,src_addr=192.168.1.184",
|
||||
"State": "live",
|
||||
"Transport": "tcp",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
if !nvmeSubsystemHasPath(doc, "nqn.2026-05.io.seaweedfs:v1", "192.168.1.181:4420") {
|
||||
if !nvmeSubsystemHasPath(doc, "nqn.2026-05.io.seaweedfs:v1", FrontendTransportTCP, "192.168.1.181:4420") {
|
||||
t.Fatal("expected exact traddr/trsvcid path to match")
|
||||
}
|
||||
if nvmeSubsystemHasPath(doc, "nqn.2026-05.io.seaweedfs:v1", "192.168.1.184:4420") {
|
||||
if nvmeSubsystemHasPath(doc, "nqn.2026-05.io.seaweedfs:v1", FrontendTransportTCP, "192.168.1.184:4420") {
|
||||
t.Fatal("src_addr must not satisfy requested target traddr")
|
||||
}
|
||||
if nvmeSubsystemHasPath(doc, "nqn.2026-05.io.seaweedfs:v1", FrontendTransportRDMA, "192.168.1.181:4420") {
|
||||
t.Fatal("TCP path must not satisfy requested RDMA transport")
|
||||
}
|
||||
doc["Subsystems"].([]any)[0].(map[string]any)["Paths"].([]any)[0].(map[string]any)["State"] = "reconnecting"
|
||||
if nvmeSubsystemHasPath(doc, "nqn.2026-05.io.seaweedfs:v1", FrontendTransportTCP, "192.168.1.181:4420") {
|
||||
t.Fatal("reconnecting path must not satisfy a live-path check")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNVMeSubsystemPathsReturnsAddressAndController(t *testing.T) {
|
||||
@@ -82,12 +90,16 @@ func TestNVMeSubsystemPathsReturnsAddressAndController(t *testing.T) {
|
||||
"NQN": "nqn.2026-05.io.seaweedfs:v1",
|
||||
"Paths": []any{
|
||||
map[string]any{
|
||||
"Name": "nvme2",
|
||||
"Address": "traddr=192.168.1.181,trsvcid=4420,src_addr=192.168.1.184",
|
||||
"Name": "nvme2",
|
||||
"Address": "traddr=192.168.1.181,trsvcid=4420,src_addr=192.168.1.184",
|
||||
"State": "live",
|
||||
"Transport": "tcp",
|
||||
},
|
||||
map[string]any{
|
||||
"Controller": "/dev/nvme3",
|
||||
"Address": "traddr=192.168.1.184,trsvcid=4520",
|
||||
"State": "live",
|
||||
"Transport": "rdma",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -95,8 +107,10 @@ func TestNVMeSubsystemPathsReturnsAddressAndController(t *testing.T) {
|
||||
"NQN": "nqn.2026-05.io.seaweedfs:other",
|
||||
"Paths": []any{
|
||||
map[string]any{
|
||||
"Name": "nvme9",
|
||||
"Address": "traddr=192.168.1.199,trsvcid=4420",
|
||||
"Name": "nvme9",
|
||||
"Address": "traddr=192.168.1.199,trsvcid=4420",
|
||||
"State": "live",
|
||||
"Transport": "tcp",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -107,10 +121,10 @@ func TestNVMeSubsystemPathsReturnsAddressAndController(t *testing.T) {
|
||||
if len(paths) != 2 {
|
||||
t.Fatalf("paths=%+v", paths)
|
||||
}
|
||||
if paths[0].Addr != "192.168.1.181:4420" || paths[0].Controller != "/dev/nvme2" {
|
||||
if paths[0].Addr != "192.168.1.181:4420" || paths[0].Controller != "/dev/nvme2" || paths[0].Transport != FrontendTransportTCP {
|
||||
t.Fatalf("path[0]=%+v", paths[0])
|
||||
}
|
||||
if paths[1].Addr != "192.168.1.184:4520" || paths[1].Controller != "/dev/nvme3" {
|
||||
if paths[1].Addr != "192.168.1.184:4520" || paths[1].Controller != "/dev/nvme3" || paths[1].Transport != FrontendTransportRDMA {
|
||||
t.Fatalf("path[1]=%+v", paths[1])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,13 +45,14 @@ type NVMeUtil interface {
|
||||
DisconnectPath(ctx context.Context, controller string) error
|
||||
GetDeviceByNQN(ctx context.Context, nqn string) (string, error)
|
||||
IsConnected(ctx context.Context, nqn string) (bool, error)
|
||||
IsPathConnected(ctx context.Context, nqn, addr string) (bool, error)
|
||||
IsPathConnected(ctx context.Context, nqn string, transport FrontendTransport, addr string) (bool, error)
|
||||
ListPaths(ctx context.Context, nqn string) ([]NVMeConnectedPath, error)
|
||||
}
|
||||
|
||||
type NVMeConnectedPath struct {
|
||||
Addr string
|
||||
Controller string
|
||||
Transport FrontendTransport
|
||||
}
|
||||
|
||||
type ISCSIAuth struct {
|
||||
@@ -347,45 +348,79 @@ func (s *NodeServer) stageNVMe(ctx context.Context, req *csipb.NodeStageVolumeRe
|
||||
if connected && !s.hasStagedIdentity(volumeID, stagingPath) {
|
||||
s.logger.Printf("NodeStageVolume: %s NVMe subsystem %q already connected without marker at %s; recreating staging identity", volumeID, nqn, stagingPath)
|
||||
}
|
||||
pathsBeforeConnect, err := s.nvmeUtil.ListPaths(ctx, nqn)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "list nvme paths before connect: %v", err)
|
||||
}
|
||||
existingControllers := make(map[string]struct{}, len(pathsBeforeConnect))
|
||||
for _, path := range pathsBeforeConnect {
|
||||
if path.Controller != "" {
|
||||
existingControllers[path.Controller] = struct{}{}
|
||||
}
|
||||
}
|
||||
attemptedPaths := make(map[string]struct{}, len(addrs))
|
||||
connectStarted := false
|
||||
success := false
|
||||
defer func() {
|
||||
if success || !connectStarted {
|
||||
return
|
||||
}
|
||||
paths, listErr := s.nvmeUtil.ListPaths(context.Background(), nqn)
|
||||
if listErr != nil {
|
||||
s.logger.Printf("NodeStageVolume: %s rollback list NVMe paths failed: %v", volumeID, listErr)
|
||||
return
|
||||
}
|
||||
for _, path := range paths {
|
||||
if path.Controller == "" {
|
||||
continue
|
||||
}
|
||||
if _, existed := existingControllers[path.Controller]; existed {
|
||||
continue
|
||||
}
|
||||
if path.Transport != nvmeTransport {
|
||||
continue
|
||||
}
|
||||
if _, attempted := attemptedPaths[path.Addr]; !attempted {
|
||||
continue
|
||||
}
|
||||
if disconnectErr := s.nvmeUtil.DisconnectPath(context.Background(), path.Controller); disconnectErr != nil {
|
||||
s.logger.Printf("NodeStageVolume: %s rollback disconnect NVMe path %s failed: %v", volumeID, path.Controller, disconnectErr)
|
||||
}
|
||||
}
|
||||
}()
|
||||
if connectAllPaths {
|
||||
for _, pathAddr := range addrs {
|
||||
pathConnected, err := s.nvmeUtil.IsPathConnected(ctx, nqn, pathAddr)
|
||||
pathConnected, err := s.nvmeUtil.IsPathConnected(ctx, nqn, nvmeTransport, pathAddr)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "check nvme path connect: %v", err)
|
||||
}
|
||||
if !pathConnected {
|
||||
attemptedPaths[pathAddr] = struct{}{}
|
||||
connectStarted = true
|
||||
if err := s.nvmeUtil.Connect(ctx, nvmeTransport, pathAddr, nqn); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "nvme connect: %v", err)
|
||||
}
|
||||
connectStarted = true
|
||||
}
|
||||
}
|
||||
} else if !connected {
|
||||
if err := s.nvmeUtil.Connect(ctx, nvmeTransport, addr, nqn); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "nvme connect: %v", err)
|
||||
} else {
|
||||
pathConnected, err := s.nvmeUtil.IsPathConnected(ctx, nqn, nvmeTransport, addr)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "check nvme path connect: %v", err)
|
||||
}
|
||||
if !pathConnected {
|
||||
attemptedPaths[addr] = struct{}{}
|
||||
connectStarted = true
|
||||
if err := s.nvmeUtil.Connect(ctx, nvmeTransport, addr, nqn); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "nvme connect: %v", err)
|
||||
}
|
||||
}
|
||||
connectStarted = true
|
||||
}
|
||||
if connectAllPaths {
|
||||
for _, pathAddr := range addrs {
|
||||
pathConnected, err := s.nvmeUtil.IsPathConnected(ctx, nqn, pathAddr)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "verify nvme path connect: %v", err)
|
||||
}
|
||||
if !pathConnected {
|
||||
return nil, status.Errorf(codes.FailedPrecondition, "NVMe multipath %q missing path %s", nqn, pathAddr)
|
||||
}
|
||||
}
|
||||
} else if !connected {
|
||||
connected = true
|
||||
if err := s.waitForNVMePathsConnected(ctx, nqn, nvmeTransport, addrs, 60*time.Second); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err := s.pruneStaleMountedNVMePaths(ctx, nqn, nvmeTransport, addrs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success := false
|
||||
defer func() {
|
||||
if !success && connectStarted {
|
||||
_ = s.nvmeUtil.Disconnect(context.Background(), nqn)
|
||||
}
|
||||
}()
|
||||
|
||||
device, err := s.nvmeUtil.GetDeviceByNQN(ctx, nqn)
|
||||
if err != nil {
|
||||
@@ -413,7 +448,6 @@ func (s *NodeServer) stageNVMe(ctx context.Context, req *csipb.NodeStageVolumeRe
|
||||
if err := writeTargetFile(stagingPath, nqn); err != nil {
|
||||
s.logger.Printf("NodeStageVolume: %s: %v (non-fatal)", volumeID, err)
|
||||
}
|
||||
|
||||
s.stagedMu.Lock()
|
||||
s.staged[volumeID] = &stagedVolumeInfo{
|
||||
nqn: nqn,
|
||||
@@ -546,6 +580,14 @@ func (s *NodeServer) reconcileMountedNVMePaths(ctx context.Context, req *csipb.N
|
||||
if err != nil {
|
||||
return mountedNVMeReconcileOutcome{}, status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
stagedTransport, err := nvmeTransportFromContexts(req.GetPublishContext(), req.GetVolumeContext())
|
||||
if err != nil {
|
||||
return mountedNVMeReconcileOutcome{}, status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
if stagedTransport != nvmeTransport {
|
||||
return mountedNVMeReconcileOutcome{}, status.Errorf(codes.FailedPrecondition,
|
||||
"mounted NVMe transport change requires restage: staged=%s desired=%s", stagedTransport, nvmeTransport)
|
||||
}
|
||||
if len(addrs) == 0 {
|
||||
addrs = []string{addr}
|
||||
}
|
||||
@@ -561,7 +603,7 @@ func (s *NodeServer) reconcileMountedNVMePaths(ctx context.Context, req *csipb.N
|
||||
outcome := mountedNVMeReconcileOutcome{}
|
||||
if connectAllPaths {
|
||||
for _, pathAddr := range addrs {
|
||||
pathConnected, err := s.nvmeUtil.IsPathConnected(ctx, nqn, pathAddr)
|
||||
pathConnected, err := s.nvmeUtil.IsPathConnected(ctx, nqn, nvmeTransport, pathAddr)
|
||||
if err != nil {
|
||||
return mountedNVMeReconcileOutcome{}, status.Errorf(codes.Internal, "check nvme path connect: %v", err)
|
||||
}
|
||||
@@ -573,35 +615,33 @@ func (s *NodeServer) reconcileMountedNVMePaths(ctx context.Context, req *csipb.N
|
||||
}
|
||||
outcome.connectedNewPath = true
|
||||
}
|
||||
if err := s.waitForNVMePathsConnected(ctx, nqn, addrs, 60*time.Second); err != nil {
|
||||
if err := s.waitForNVMePathsConnected(ctx, nqn, nvmeTransport, addrs, 60*time.Second); err != nil {
|
||||
return mountedNVMeReconcileOutcome{}, err
|
||||
}
|
||||
pruned, err := s.pruneStaleMountedNVMePaths(ctx, nqn, addrs)
|
||||
pruned, err := s.pruneStaleMountedNVMePaths(ctx, nqn, nvmeTransport, addrs)
|
||||
if err != nil {
|
||||
return mountedNVMeReconcileOutcome{}, err
|
||||
}
|
||||
outcome.prunedStalePath = pruned
|
||||
} else {
|
||||
connected, err := s.nvmeUtil.IsConnected(ctx, nqn)
|
||||
pathConnected, err := s.nvmeUtil.IsPathConnected(ctx, nqn, nvmeTransport, addr)
|
||||
if err != nil {
|
||||
return mountedNVMeReconcileOutcome{}, status.Errorf(codes.Internal, "check nvme connect: %v", err)
|
||||
return mountedNVMeReconcileOutcome{}, status.Errorf(codes.Internal, "check nvme path connect: %v", err)
|
||||
}
|
||||
if !connected {
|
||||
if !pathConnected {
|
||||
if err := s.nvmeUtil.Connect(ctx, nvmeTransport, addr, nqn); err != nil {
|
||||
return mountedNVMeReconcileOutcome{}, status.Errorf(codes.Internal, "nvme reconnect: %v", err)
|
||||
}
|
||||
outcome.connectedNewPath = true
|
||||
}
|
||||
}
|
||||
|
||||
if err := writeTransportFile(stagingPath, transportNVMe); err != nil {
|
||||
s.logger.Printf("NodeStageVolume: %s: %v (non-fatal)", volumeID, err)
|
||||
}
|
||||
if err := writeVolumeFile(stagingPath, volumeID); err != nil {
|
||||
s.logger.Printf("NodeStageVolume: %s: %v (non-fatal)", volumeID, err)
|
||||
}
|
||||
if err := writeTargetFile(stagingPath, nqn); err != nil {
|
||||
s.logger.Printf("NodeStageVolume: %s: %v (non-fatal)", volumeID, err)
|
||||
if err := s.waitForNVMePathsConnected(ctx, nqn, nvmeTransport, []string{addr}, 60*time.Second); err != nil {
|
||||
return mountedNVMeReconcileOutcome{}, err
|
||||
}
|
||||
pruned, err := s.pruneStaleMountedNVMePaths(ctx, nqn, nvmeTransport, []string{addr})
|
||||
if err != nil {
|
||||
return mountedNVMeReconcileOutcome{}, err
|
||||
}
|
||||
outcome.prunedStalePath = pruned
|
||||
}
|
||||
|
||||
s.stagedMu.Lock()
|
||||
@@ -622,7 +662,7 @@ func (s *NodeServer) reconcileMountedNVMePaths(ctx context.Context, req *csipb.N
|
||||
return outcome, nil
|
||||
}
|
||||
|
||||
func (s *NodeServer) pruneStaleMountedNVMePaths(ctx context.Context, nqn string, desiredAddrs []string) (bool, error) {
|
||||
func (s *NodeServer) pruneStaleMountedNVMePaths(ctx context.Context, nqn string, transport FrontendTransport, desiredAddrs []string) (bool, error) {
|
||||
if s.nvmeUtil == nil || nqn == "" || len(desiredAddrs) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
@@ -641,7 +681,7 @@ func (s *NodeServer) pruneStaleMountedNVMePaths(ctx context.Context, nqn string,
|
||||
if path.Addr == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := desired[path.Addr]; ok {
|
||||
if _, ok := desired[path.Addr]; ok && path.Transport == transport {
|
||||
continue
|
||||
}
|
||||
if path.Controller == "" {
|
||||
@@ -655,7 +695,7 @@ func (s *NodeServer) pruneStaleMountedNVMePaths(ctx context.Context, nqn string,
|
||||
return pruned, nil
|
||||
}
|
||||
|
||||
func (s *NodeServer) waitForNVMePathsConnected(ctx context.Context, nqn string, addrs []string, timeout time.Duration) error {
|
||||
func (s *NodeServer) waitForNVMePathsConnected(ctx context.Context, nqn string, transport FrontendTransport, addrs []string, timeout time.Duration) error {
|
||||
deadline := time.NewTimer(timeout)
|
||||
defer deadline.Stop()
|
||||
ticker := time.NewTicker(200 * time.Millisecond)
|
||||
@@ -664,7 +704,7 @@ func (s *NodeServer) waitForNVMePathsConnected(ctx context.Context, nqn string,
|
||||
for {
|
||||
lastMissing = ""
|
||||
for _, pathAddr := range addrs {
|
||||
pathConnected, err := s.nvmeUtil.IsPathConnected(ctx, nqn, pathAddr)
|
||||
pathConnected, err := s.nvmeUtil.IsPathConnected(ctx, nqn, transport, pathAddr)
|
||||
if err != nil {
|
||||
return status.Errorf(codes.Internal, "verify nvme path connect: %v", err)
|
||||
}
|
||||
@@ -680,7 +720,7 @@ func (s *NodeServer) waitForNVMePathsConnected(ctx context.Context, nqn string,
|
||||
case <-ctx.Done():
|
||||
return status.Errorf(codes.Internal, "verify nvme path connect: %v", ctx.Err())
|
||||
case <-deadline.C:
|
||||
return status.Errorf(codes.FailedPrecondition, "NVMe multipath %q missing path %s", nqn, lastMissing)
|
||||
return status.Errorf(codes.FailedPrecondition, "NVMe %q missing %s path %s", nqn, transport, lastMissing)
|
||||
case <-ticker.C:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,28 +94,44 @@ type mockMountUtil struct {
|
||||
}
|
||||
|
||||
type mockNVMeUtil struct {
|
||||
connectErr error
|
||||
disconnectErr error
|
||||
getDeviceResult string
|
||||
getDeviceErr error
|
||||
connected map[string]bool
|
||||
connectedPaths map[string]bool
|
||||
calls []string
|
||||
connectTransports []FrontendTransport
|
||||
connectErr error
|
||||
connectCreatesPathOnError bool
|
||||
disconnectErr error
|
||||
getDeviceResult string
|
||||
getDeviceErr error
|
||||
connected map[string]bool
|
||||
connectedPaths map[string]bool
|
||||
pathConnectDelay map[string]int
|
||||
pathChecks map[string]int
|
||||
calls []string
|
||||
connectTransports []FrontendTransport
|
||||
}
|
||||
|
||||
func newMockNVMeUtil() *mockNVMeUtil {
|
||||
return &mockNVMeUtil{connected: map[string]bool{}, connectedPaths: map[string]bool{}, getDeviceResult: "/dev/nvme1n1"}
|
||||
return &mockNVMeUtil{
|
||||
connected: map[string]bool{},
|
||||
connectedPaths: map[string]bool{},
|
||||
pathConnectDelay: map[string]int{},
|
||||
pathChecks: map[string]int{},
|
||||
getDeviceResult: "/dev/nvme1n1",
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mockNVMeUtil) Connect(_ context.Context, transport FrontendTransport, addr, nqn string) error {
|
||||
m.calls = append(m.calls, "connect:"+addr+":"+nqn)
|
||||
m.connectTransports = append(m.connectTransports, transport)
|
||||
if m.connectErr != nil {
|
||||
if m.connectCreatesPathOnError {
|
||||
m.connected[nqn] = true
|
||||
m.connectedPaths[mockNVMePathKey(nqn, transport, addr)] = true
|
||||
}
|
||||
return m.connectErr
|
||||
}
|
||||
m.connected[nqn] = true
|
||||
m.connectedPaths[nqn+"|"+addr] = true
|
||||
key := mockNVMePathKey(nqn, transport, addr)
|
||||
if m.pathConnectDelay[key] == 0 {
|
||||
m.connectedPaths[key] = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -139,11 +155,11 @@ func (m *mockNVMeUtil) DisconnectPath(_ context.Context, controller string) erro
|
||||
return m.disconnectErr
|
||||
}
|
||||
for key := range m.connectedPaths {
|
||||
nqn, addr, ok := strings.Cut(key, "|")
|
||||
nqn, transport, addr, ok := parseMockNVMePathKey(key)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if mockNVMeController(nqn, addr) == controller {
|
||||
if mockNVMeController(nqn, transport, addr) == controller {
|
||||
delete(m.connectedPaths, key)
|
||||
}
|
||||
}
|
||||
@@ -160,31 +176,51 @@ func (m *mockNVMeUtil) IsConnected(_ context.Context, nqn string) (bool, error)
|
||||
return m.connected[nqn], nil
|
||||
}
|
||||
|
||||
func (m *mockNVMeUtil) IsPathConnected(_ context.Context, nqn, addr string) (bool, error) {
|
||||
func (m *mockNVMeUtil) IsPathConnected(_ context.Context, nqn string, transport FrontendTransport, addr string) (bool, error) {
|
||||
m.calls = append(m.calls, "ispathconnected:"+addr+":"+nqn)
|
||||
return m.connectedPaths[nqn+"|"+addr], nil
|
||||
key := mockNVMePathKey(nqn, transport, addr)
|
||||
if !m.connectedPaths[key] && m.pathConnectDelay[key] > 0 {
|
||||
m.pathChecks[key]++
|
||||
if m.pathChecks[key] >= m.pathConnectDelay[key] {
|
||||
m.connectedPaths[key] = true
|
||||
}
|
||||
}
|
||||
return m.connectedPaths[key], nil
|
||||
}
|
||||
|
||||
func (m *mockNVMeUtil) ListPaths(_ context.Context, nqn string) ([]NVMeConnectedPath, error) {
|
||||
m.calls = append(m.calls, "listpaths:"+nqn)
|
||||
var paths []NVMeConnectedPath
|
||||
for key := range m.connectedPaths {
|
||||
gotNQN, addr, ok := strings.Cut(key, "|")
|
||||
gotNQN, transport, addr, ok := parseMockNVMePathKey(key)
|
||||
if !ok || gotNQN != nqn {
|
||||
continue
|
||||
}
|
||||
paths = append(paths, NVMeConnectedPath{
|
||||
Addr: addr,
|
||||
Controller: mockNVMeController(gotNQN, addr),
|
||||
Controller: mockNVMeController(gotNQN, transport, addr),
|
||||
Transport: transport,
|
||||
})
|
||||
}
|
||||
sort.Slice(paths, func(i, j int) bool { return paths[i].Addr < paths[j].Addr })
|
||||
return paths, nil
|
||||
}
|
||||
|
||||
func mockNVMeController(nqn, addr string) string {
|
||||
func mockNVMePathKey(nqn string, transport FrontendTransport, addr string) string {
|
||||
return nqn + "|" + string(transport) + "|" + addr
|
||||
}
|
||||
|
||||
func parseMockNVMePathKey(key string) (string, FrontendTransport, string, bool) {
|
||||
parts := strings.SplitN(key, "|", 3)
|
||||
if len(parts) != 3 {
|
||||
return "", "", "", false
|
||||
}
|
||||
return parts[0], FrontendTransport(parts[1]), parts[2], true
|
||||
}
|
||||
|
||||
func mockNVMeController(nqn string, transport FrontendTransport, addr string) string {
|
||||
replacer := strings.NewReplacer(":", "-", ".", "-", "/", "-", "|", "-", "=", "-")
|
||||
return "/dev/mock-" + replacer.Replace(nqn+"-"+addr)
|
||||
return "/dev/mock-" + replacer.Replace(nqn+"-"+string(transport)+"-"+addr)
|
||||
}
|
||||
|
||||
func newMockMountUtil() *mockMountUtil {
|
||||
@@ -671,7 +707,11 @@ func TestNodeStage_NVMeProtocolUsesNVMeTarget(t *testing.T) {
|
||||
}
|
||||
want := []string{
|
||||
"isconnected:nqn.2026-05.io.seaweedfs:v1",
|
||||
"listpaths:nqn.2026-05.io.seaweedfs:v1",
|
||||
"ispathconnected:127.0.0.1:4420:nqn.2026-05.io.seaweedfs:v1",
|
||||
"connect:127.0.0.1:4420:nqn.2026-05.io.seaweedfs:v1",
|
||||
"ispathconnected:127.0.0.1:4420:nqn.2026-05.io.seaweedfs:v1",
|
||||
"listpaths:nqn.2026-05.io.seaweedfs:v1",
|
||||
"getdevice:nqn.2026-05.io.seaweedfs:v1",
|
||||
}
|
||||
for i, w := range want {
|
||||
@@ -752,12 +792,14 @@ func TestNodeStage_NVMeMultipathConnectsAllTargets(t *testing.T) {
|
||||
}
|
||||
want := []string{
|
||||
"isconnected:nqn.2026-05.io.seaweedfs:v1",
|
||||
"listpaths:nqn.2026-05.io.seaweedfs:v1",
|
||||
"ispathconnected:127.0.0.1:4420:nqn.2026-05.io.seaweedfs:v1",
|
||||
"connect:127.0.0.1:4420:nqn.2026-05.io.seaweedfs:v1",
|
||||
"ispathconnected:127.0.0.1:4421:nqn.2026-05.io.seaweedfs:v1",
|
||||
"connect:127.0.0.1:4421:nqn.2026-05.io.seaweedfs:v1",
|
||||
"ispathconnected:127.0.0.1:4420:nqn.2026-05.io.seaweedfs:v1",
|
||||
"ispathconnected:127.0.0.1:4421:nqn.2026-05.io.seaweedfs:v1",
|
||||
"listpaths:nqn.2026-05.io.seaweedfs:v1",
|
||||
"getdevice:nqn.2026-05.io.seaweedfs:v1",
|
||||
}
|
||||
for i, w := range want {
|
||||
@@ -878,7 +920,7 @@ func TestNodeStage_NVMeRecreatesStagingIdentityForAlreadyConnectedSubsystem(t *t
|
||||
addrs := []string{"127.0.0.1:4420", "127.0.0.1:4421"}
|
||||
mn.connected[nqn] = true
|
||||
for _, addr := range addrs {
|
||||
mn.connectedPaths[nqn+"|"+addr] = true
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportTCP, addr)] = true
|
||||
}
|
||||
staging := t.TempDir()
|
||||
|
||||
@@ -934,14 +976,13 @@ func TestNodeStage_NVMeCleansUpConnectWhenMountFails(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("expected mount failure")
|
||||
}
|
||||
foundDisconnect := false
|
||||
for _, call := range mn.calls {
|
||||
if call == "disconnect:nqn.2026-05.io.seaweedfs:v1" {
|
||||
foundDisconnect = true
|
||||
}
|
||||
nqn := "nqn.2026-05.io.seaweedfs:v1"
|
||||
controller := mockNVMeController(nqn, FrontendTransportTCP, "127.0.0.1:4420")
|
||||
if !containsString(mn.calls, "disconnectpath:"+controller) {
|
||||
t.Fatalf("expected scoped cleanup disconnect, calls=%v", mn.calls)
|
||||
}
|
||||
if !foundDisconnect {
|
||||
t.Fatalf("expected cleanup disconnect, calls=%v", mn.calls)
|
||||
if containsString(mn.calls, "disconnect:"+nqn) {
|
||||
t.Fatalf("rollback must not disconnect the whole subsystem, calls=%v", mn.calls)
|
||||
}
|
||||
if ns.staged["v1"] != nil {
|
||||
t.Fatalf("staged entry must not be recorded after mount failure: %+v", ns.staged["v1"])
|
||||
@@ -966,20 +1007,115 @@ func TestNodeStage_NVMeMultipathCleansUpConnectsWhenMountFails(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("expected mount failure")
|
||||
}
|
||||
foundDisconnect := false
|
||||
for _, call := range mn.calls {
|
||||
if call == "disconnect:nqn.2026-05.io.seaweedfs:v1" {
|
||||
foundDisconnect = true
|
||||
nqn := "nqn.2026-05.io.seaweedfs:v1"
|
||||
for _, addr := range []string{"127.0.0.1:4420", "127.0.0.1:4421"} {
|
||||
controller := mockNVMeController(nqn, FrontendTransportTCP, addr)
|
||||
if !containsString(mn.calls, "disconnectpath:"+controller) {
|
||||
t.Fatalf("expected scoped cleanup disconnect for %s, calls=%v", addr, mn.calls)
|
||||
}
|
||||
}
|
||||
if !foundDisconnect {
|
||||
t.Fatalf("expected cleanup disconnect, calls=%v", mn.calls)
|
||||
if containsString(mn.calls, "disconnect:"+nqn) {
|
||||
t.Fatalf("rollback must not disconnect the whole subsystem, calls=%v", mn.calls)
|
||||
}
|
||||
if ns.staged["v1"] != nil {
|
||||
t.Fatalf("staged entry must not be recorded after mount failure: %+v", ns.staged["v1"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestPhase166_NodeStageWaitsForRDMAPathToBecomeLive(t *testing.T) {
|
||||
mn, mm := newMockNVMeUtil(), newMockMountUtil()
|
||||
ns := newTestNodeWithNVMe(newMockISCSIUtil(), mn, mm)
|
||||
nqn := "nqn.2026-05.io.seaweedfs:v1"
|
||||
addr := "10.0.0.3:4420"
|
||||
key := mockNVMePathKey(nqn, FrontendTransportRDMA, addr)
|
||||
mn.pathConnectDelay[key] = 2
|
||||
|
||||
_, err := ns.NodeStageVolume(context.Background(), &csipb.NodeStageVolumeRequest{
|
||||
VolumeId: "v1",
|
||||
StagingTargetPath: t.TempDir(),
|
||||
VolumeCapability: testVolumeCapability(),
|
||||
PublishContext: map[string]string{
|
||||
"protocol": "nvme",
|
||||
"nvmeTransport": "rdma",
|
||||
"nvmeAddr": addr,
|
||||
"nqn": nqn,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("NodeStageVolume: %v", err)
|
||||
}
|
||||
if mn.pathChecks[key] < 2 {
|
||||
t.Fatalf("path checks=%d want at least 2", mn.pathChecks[key])
|
||||
}
|
||||
}
|
||||
|
||||
func TestPhase166_NodeStageRollbackPreservesPreexistingPath(t *testing.T) {
|
||||
mn, mm := newMockNVMeUtil(), newMockMountUtil()
|
||||
mm.formatAndMountErr = errors.New("mkfs failed")
|
||||
ns := newTestNodeWithNVMe(newMockISCSIUtil(), mn, mm)
|
||||
nqn := "nqn.2026-05.io.seaweedfs:v1"
|
||||
existingAddr := "10.0.0.1:4420"
|
||||
newAddr := "10.0.0.3:4420"
|
||||
mn.connected[nqn] = true
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportRDMA, existingAddr)] = true
|
||||
|
||||
_, err := ns.NodeStageVolume(context.Background(), &csipb.NodeStageVolumeRequest{
|
||||
VolumeId: "v1",
|
||||
StagingTargetPath: t.TempDir(),
|
||||
VolumeCapability: testVolumeCapability(),
|
||||
PublishContext: map[string]string{
|
||||
"protocol": "nvme",
|
||||
"nvmeTransport": "rdma",
|
||||
"nvmeAddr": existingAddr,
|
||||
"nvmeAddrs": existingAddr + "," + newAddr,
|
||||
"nqn": nqn,
|
||||
"stage2_multipath": "true",
|
||||
},
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected mount failure")
|
||||
}
|
||||
existingController := mockNVMeController(nqn, FrontendTransportRDMA, existingAddr)
|
||||
newController := mockNVMeController(nqn, FrontendTransportRDMA, newAddr)
|
||||
if containsString(mn.calls, "disconnectpath:"+existingController) {
|
||||
t.Fatalf("rollback disconnected preexisting path, calls=%v", mn.calls)
|
||||
}
|
||||
if !containsString(mn.calls, "disconnectpath:"+newController) {
|
||||
t.Fatalf("rollback did not disconnect new path, calls=%v", mn.calls)
|
||||
}
|
||||
if !mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportRDMA, existingAddr)] {
|
||||
t.Fatal("preexisting path was removed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPhase166_NodeStageRollsBackControllerCreatedByFailedConnect(t *testing.T) {
|
||||
mn, mm := newMockNVMeUtil(), newMockMountUtil()
|
||||
mn.connectErr = errors.New("connect command failed after controller creation")
|
||||
mn.connectCreatesPathOnError = true
|
||||
ns := newTestNodeWithNVMe(newMockISCSIUtil(), mn, mm)
|
||||
nqn := "nqn.2026-05.io.seaweedfs:v1"
|
||||
addr := "10.0.0.3:4420"
|
||||
|
||||
_, err := ns.NodeStageVolume(context.Background(), &csipb.NodeStageVolumeRequest{
|
||||
VolumeId: "v1",
|
||||
StagingTargetPath: t.TempDir(),
|
||||
VolumeCapability: testVolumeCapability(),
|
||||
PublishContext: map[string]string{
|
||||
"protocol": "nvme",
|
||||
"nvmeTransport": "rdma",
|
||||
"nvmeAddr": addr,
|
||||
"nqn": nqn,
|
||||
},
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected connect failure")
|
||||
}
|
||||
controller := mockNVMeController(nqn, FrontendTransportRDMA, addr)
|
||||
if !containsString(mn.calls, "disconnectpath:"+controller) {
|
||||
t.Fatalf("failed connect controller was not rolled back, calls=%v", mn.calls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeStage_ConfiguresCHAPBeforeLogin(t *testing.T) {
|
||||
mi, mm := newMockISCSIUtil(), newMockMountUtil()
|
||||
ns := newTestNode(mi, mm)
|
||||
@@ -1073,7 +1209,7 @@ func TestNodeStage_MountedNVMeReconnectsMissingPublishedPath(t *testing.T) {
|
||||
oldAddr := "127.0.0.1:4420"
|
||||
newAddr := "127.0.0.1:4421"
|
||||
mn.connected[nqn] = true
|
||||
mn.connectedPaths[nqn+"|"+oldAddr] = true
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportTCP, oldAddr)] = true
|
||||
lookup := &sequenceLookup{targets: []PublishTarget{{
|
||||
VolumeID: "v1",
|
||||
ReplicaID: "r1",
|
||||
@@ -1204,7 +1340,7 @@ func TestMountedNVMeReconnectOwner_ReconcilesMissingPublishedPath(t *testing.T)
|
||||
oldAddr := "127.0.0.1:4420"
|
||||
newAddr := "127.0.0.1:4421"
|
||||
mn.connected[nqn] = true
|
||||
mn.connectedPaths[nqn+"|"+oldAddr] = true
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportTCP, oldAddr)] = true
|
||||
lookup := &sequenceLookup{targets: []PublishTarget{{
|
||||
VolumeID: "v1",
|
||||
ReplicaID: "r1",
|
||||
@@ -1277,9 +1413,9 @@ func TestMountedNVMeReconnectOwner_PrunesStaleDesiredPath(t *testing.T) {
|
||||
otherAddr := "127.0.0.3:4420"
|
||||
mn.connected[nqn] = true
|
||||
mn.connected[otherNQN] = true
|
||||
mn.connectedPaths[nqn+"|"+oldAddr] = true
|
||||
mn.connectedPaths[nqn+"|"+remainingAddr] = true
|
||||
mn.connectedPaths[otherNQN+"|"+otherAddr] = true
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportTCP, oldAddr)] = true
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportTCP, remainingAddr)] = true
|
||||
mn.connectedPaths[mockNVMePathKey(otherNQN, FrontendTransportTCP, otherAddr)] = true
|
||||
lookup := &sequenceLookup{targets: []PublishTarget{{
|
||||
VolumeID: "v1",
|
||||
ReplicaID: "r1",
|
||||
@@ -1325,22 +1461,26 @@ func TestMountedNVMeReconnectOwner_PrunesStaleDesiredPath(t *testing.T) {
|
||||
if result.Checked != 1 || result.Reconnected != 1 || result.Pruned != 1 || result.Failed != 0 {
|
||||
t.Fatalf("result=%+v", result)
|
||||
}
|
||||
if mn.connectedPaths[nqn+"|"+oldAddr] {
|
||||
if mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportTCP, oldAddr)] {
|
||||
t.Fatalf("stale old path %s still connected", oldAddr)
|
||||
}
|
||||
for _, key := range []string{nqn + "|" + newAddr, nqn + "|" + remainingAddr, otherNQN + "|" + otherAddr} {
|
||||
for _, key := range []string{
|
||||
mockNVMePathKey(nqn, FrontendTransportTCP, newAddr),
|
||||
mockNVMePathKey(nqn, FrontendTransportTCP, remainingAddr),
|
||||
mockNVMePathKey(otherNQN, FrontendTransportTCP, otherAddr),
|
||||
} {
|
||||
if !mn.connectedPaths[key] {
|
||||
t.Fatalf("expected path %s to remain connected, paths=%v", key, mn.connectedPaths)
|
||||
}
|
||||
}
|
||||
if !containsString(mn.calls, "disconnectpath:"+mockNVMeController(nqn, oldAddr)) {
|
||||
if !containsString(mn.calls, "disconnectpath:"+mockNVMeController(nqn, FrontendTransportTCP, oldAddr)) {
|
||||
t.Fatalf("missing scoped stale path disconnect, calls=%v", mn.calls)
|
||||
}
|
||||
if containsString(mn.calls, "disconnect:"+nqn) || containsString(mn.calls, "disconnect:"+otherNQN) {
|
||||
t.Fatalf("prune must not use full subsystem disconnect, calls=%v", mn.calls)
|
||||
}
|
||||
for _, call := range mn.calls {
|
||||
if call == "disconnectpath:"+mockNVMeController(otherNQN, otherAddr) {
|
||||
if call == "disconnectpath:"+mockNVMeController(otherNQN, FrontendTransportTCP, otherAddr) {
|
||||
t.Fatalf("prune touched unrelated NQN, calls=%v", mn.calls)
|
||||
}
|
||||
}
|
||||
@@ -1349,13 +1489,174 @@ func TestMountedNVMeReconnectOwner_PrunesStaleDesiredPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMountedNVMeReconnectOwner_ReplacesSingleRDMAEndpoint(t *testing.T) {
|
||||
_, mn, mm := newMockISCSIUtil(), newMockNVMeUtil(), newMockMountUtil()
|
||||
nqn := "nqn.2026-05.io.seaweedfs:v1"
|
||||
oldAddr := "10.0.0.3:4420"
|
||||
newAddr := "10.0.0.3:4520"
|
||||
mn.connected[nqn] = true
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportRDMA, oldAddr)] = true
|
||||
lookup := &sequenceLookup{targets: []PublishTarget{{
|
||||
VolumeID: "v1",
|
||||
ReplicaID: "r1",
|
||||
Protocol: ProtocolNVMe,
|
||||
FrontendTransport: FrontendTransportRDMA,
|
||||
NVMeAddr: newAddr,
|
||||
NVMeAddrs: []string{newAddr},
|
||||
NQN: nqn,
|
||||
NSID: 1,
|
||||
}}}
|
||||
ns := NewNodeServer(NodeConfig{
|
||||
NodeID: "node-a",
|
||||
NVMeUtil: mn,
|
||||
MountUtil: mm,
|
||||
Lookup: lookup,
|
||||
})
|
||||
staging := t.TempDir()
|
||||
mm.mounted[staging] = true
|
||||
if err := writeTransportFile(staging, transportNVMe); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := writeVolumeFile(staging, "v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := writeTargetFile(staging, nqn); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ns.staged["v1"] = &stagedVolumeInfo{
|
||||
nqn: nqn,
|
||||
nvmeAddr: oldAddr,
|
||||
nvmeAddrs: []string{oldAddr},
|
||||
nvmeTransport: FrontendTransportRDMA,
|
||||
transport: transportNVMe,
|
||||
stagingPath: staging,
|
||||
}
|
||||
|
||||
result, err := ns.ReconcileMountedNVMeVolumes(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("ReconcileMountedNVMeVolumes: %v", err)
|
||||
}
|
||||
if result.Checked != 1 || result.Reconnected != 1 || result.Pruned != 1 || result.Failed != 0 {
|
||||
t.Fatalf("result=%+v", result)
|
||||
}
|
||||
if len(mn.connectTransports) != 1 || mn.connectTransports[0] != FrontendTransportRDMA {
|
||||
t.Fatalf("connect transports=%v want [rdma]", mn.connectTransports)
|
||||
}
|
||||
if !mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportRDMA, newAddr)] ||
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportRDMA, oldAddr)] {
|
||||
t.Fatalf("connected paths=%v", mn.connectedPaths)
|
||||
}
|
||||
if !containsString(mn.calls, "disconnectpath:"+mockNVMeController(nqn, FrontendTransportRDMA, oldAddr)) {
|
||||
t.Fatalf("missing scoped stale path disconnect, calls=%v", mn.calls)
|
||||
}
|
||||
connectIndex, disconnectIndex := -1, -1
|
||||
for i, call := range mn.calls {
|
||||
if call == "connect:"+newAddr+":"+nqn {
|
||||
connectIndex = i
|
||||
}
|
||||
if call == "disconnectpath:"+mockNVMeController(nqn, FrontendTransportRDMA, oldAddr) {
|
||||
disconnectIndex = i
|
||||
}
|
||||
}
|
||||
if connectIndex < 0 || disconnectIndex < 0 || connectIndex >= disconnectIndex {
|
||||
t.Fatalf("new path must connect before old path is pruned, calls=%v", mn.calls)
|
||||
}
|
||||
if containsString(mn.calls, "disconnect:"+nqn) {
|
||||
t.Fatalf("single-path replacement must not disconnect the whole subsystem, calls=%v", mn.calls)
|
||||
}
|
||||
info := ns.staged["v1"]
|
||||
if info == nil || info.nvmeTransport != FrontendTransportRDMA || info.nvmeAddr != newAddr {
|
||||
t.Fatalf("staged info=%+v", info)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMountedNVMeReconnectOwner_DoesNotAcceptTCPAtDesiredRDMAEndpoint(t *testing.T) {
|
||||
_, mn, mm := newMockISCSIUtil(), newMockNVMeUtil(), newMockMountUtil()
|
||||
nqn := "nqn.2026-05.io.seaweedfs:v1"
|
||||
addr := "10.0.0.3:4420"
|
||||
mn.connected[nqn] = true
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportTCP, addr)] = true
|
||||
lookup := &sequenceLookup{targets: []PublishTarget{{
|
||||
VolumeID: "v1",
|
||||
Protocol: ProtocolNVMe,
|
||||
FrontendTransport: FrontendTransportRDMA,
|
||||
NVMeAddr: addr,
|
||||
NQN: nqn,
|
||||
}}}
|
||||
ns := NewNodeServer(NodeConfig{NodeID: "node-a", NVMeUtil: mn, MountUtil: mm, Lookup: lookup})
|
||||
staging := t.TempDir()
|
||||
mm.mounted[staging] = true
|
||||
if err := writeTransportFile(staging, transportNVMe); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := writeVolumeFile(staging, "v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := writeTargetFile(staging, nqn); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ns.staged["v1"] = &stagedVolumeInfo{
|
||||
nqn: nqn, nvmeAddr: addr, nvmeAddrs: []string{addr},
|
||||
nvmeTransport: FrontendTransportRDMA, transport: transportNVMe, stagingPath: staging,
|
||||
}
|
||||
|
||||
result, err := ns.ReconcileMountedNVMeVolumes(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("ReconcileMountedNVMeVolumes: %v", err)
|
||||
}
|
||||
if result.Reconnected != 1 || result.Pruned != 1 || result.Failed != 0 {
|
||||
t.Fatalf("result=%+v", result)
|
||||
}
|
||||
if !mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportRDMA, addr)] ||
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportTCP, addr)] {
|
||||
t.Fatalf("connected paths=%v", mn.connectedPaths)
|
||||
}
|
||||
if len(mn.connectTransports) != 1 || mn.connectTransports[0] != FrontendTransportRDMA {
|
||||
t.Fatalf("connect transports=%v want [rdma]", mn.connectTransports)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMountedNVMeReconnectOwner_RejectsTransportChangeWithoutRestage(t *testing.T) {
|
||||
_, mn, mm := newMockISCSIUtil(), newMockNVMeUtil(), newMockMountUtil()
|
||||
nqn := "nqn.2026-05.io.seaweedfs:v1"
|
||||
addr := "10.0.0.3:4420"
|
||||
lookup := &sequenceLookup{targets: []PublishTarget{{
|
||||
VolumeID: "v1", Protocol: ProtocolNVMe, FrontendTransport: FrontendTransportTCP,
|
||||
NVMeAddr: addr, NQN: nqn,
|
||||
}}}
|
||||
ns := NewNodeServer(NodeConfig{NodeID: "node-a", NVMeUtil: mn, MountUtil: mm, Lookup: lookup})
|
||||
staging := t.TempDir()
|
||||
mm.mounted[staging] = true
|
||||
if err := writeTransportFile(staging, transportNVMe); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := writeVolumeFile(staging, "v1"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := writeTargetFile(staging, nqn); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ns.staged["v1"] = &stagedVolumeInfo{
|
||||
nqn: nqn, nvmeAddr: addr, nvmeAddrs: []string{addr},
|
||||
nvmeTransport: FrontendTransportRDMA, transport: transportNVMe, stagingPath: staging,
|
||||
}
|
||||
|
||||
_, err := ns.ReconcileMountedNVMeVolumes(context.Background())
|
||||
if err == nil || !strings.Contains(err.Error(), "transport change requires restage") {
|
||||
t.Fatalf("err=%v want transport-change refusal", err)
|
||||
}
|
||||
if len(mn.connectTransports) != 0 {
|
||||
t.Fatalf("transport mismatch must fail before connect, transports=%v", mn.connectTransports)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMountedNVMeReconnectOwnerLoop_InvokesReconnect(t *testing.T) {
|
||||
_, mn, mm := newMockISCSIUtil(), newMockNVMeUtil(), newMockMountUtil()
|
||||
nqn := "nqn.2026-05.io.seaweedfs:v1"
|
||||
oldAddr := "127.0.0.1:4420"
|
||||
newAddr := "127.0.0.1:4421"
|
||||
mn.connected[nqn] = true
|
||||
mn.connectedPaths[nqn+"|"+oldAddr] = true
|
||||
mn.connectedPaths[mockNVMePathKey(nqn, FrontendTransportTCP, oldAddr)] = true
|
||||
lookup := &sequenceLookup{targets: []PublishTarget{{
|
||||
VolumeID: "v1",
|
||||
ReplicaID: "r1",
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# Phase 166 NVMe/RDMA Kubernetes Multipath Status
|
||||
|
||||
Status: **HOLD - implementation complete, live close gate infrastructure-blocked**
|
||||
|
||||
Phase 166 requires an already-mounted RF2 Kubernetes volume to have two live
|
||||
RDMA controllers, keep I/O running while one non-primary target is unavailable,
|
||||
reconnect that exact RDMA path, and replace one desired endpoint without
|
||||
restaging. No TCP controller may satisfy an RDMA path.
|
||||
|
||||
## Implemented Contract
|
||||
|
||||
- CSI matches a desired path by exact `(transport, NQN, address)` and accepts
|
||||
only controllers whose state is `live`.
|
||||
- Initial stage and mounted reconcile connect missing desired endpoints before
|
||||
pruning stale controllers.
|
||||
- Initial-stage rollback is scoped to controllers created by that attempt; it
|
||||
does not disconnect pre-existing or unrelated controllers.
|
||||
- A mounted volume rejects a transport change and requires restage instead of
|
||||
silently mixing TCP and RDMA.
|
||||
- Publish context carries explicit `rdma` intent while preserving legacy TCP
|
||||
behavior when the transport field is absent.
|
||||
- The close gate requires a non-primary outage, surviving-path mounted I/O,
|
||||
exact path restoration, endpoint replacement, cross-surface agreement, no
|
||||
TCP fallback, and scoped zero-residue cleanup.
|
||||
|
||||
## Evidence
|
||||
|
||||
| Check | Result | Evidence |
|
||||
| --- | --- | --- |
|
||||
| Source and script contracts | PASS | `go test ./core/csi ./cmd/blockcsi ./core/ops ./core/launcher ./scripts -count=1`; changed shell scripts pass `bash -n`; Phase 133 and 166 scenarios validate. |
|
||||
| Kubernetes single-path RDMA regression | PASS | Phase 165 run `20260718-054945-77d5`: transport `rdma`, host controller `10.0.0.3`, writer/reader verified, no TCP fallback, clean detach and zero residue. |
|
||||
| Shared RF2 reconnect logic over NVMe/TCP | PASS | Phase 133 run `20260718-061457-5ed4`, 35/35 actions: two initial paths; non-primary endpoint `192.168.1.184:4420` replaced by `192.168.1.184:4520`; surviving `192.168.1.181:4420` controller preserved; mounted I/O and Pod UID preserved; old path absent; CRD/report/dashboard/explain agree; cleanup clean. |
|
||||
| RF2 RDMA mounted reconnect close gate | BLOCKED | The current lab has only two RoCE-capable nodes, m01 (`10.0.0.1`) and m02 (`10.0.0.3`), and both must host the RF2 targets. The initiator therefore shares a node with one target; Linux rejects that local RDMA self-connect with `Invalid argument`. tp01 is offline and is not a RoCE-capable replacement. |
|
||||
|
||||
The Phase 133 regression asserts stable behavior, not observation of a transient
|
||||
stale controller. A valid result is that the old path is already absent when
|
||||
sampled, provided the new desired path is live, the surviving controller is
|
||||
unchanged, the final exact path set is correct, mounted I/O is continuous, and
|
||||
`stale_old_path_pruned=true`.
|
||||
|
||||
## Unblock Requirement
|
||||
|
||||
Provide a third Ready Kubernetes node with working RoCE configuration and
|
||||
reachability to both m01 and m02 RDMA frontend addresses. Both RF2 targets must
|
||||
be remote from the initiator. Then run:
|
||||
|
||||
```powershell
|
||||
C:\work\swblock.exe run -results-dir C:\work\seaweed_block\results `
|
||||
-env app_node=<third-kubernetes-node> `
|
||||
-env app_ssh_addr=<third-node-management-ip> `
|
||||
C:\work\seaweed_block\testops\scenarios\nvme-rdma-k8s-multipath-reconnect-chain.yaml
|
||||
```
|
||||
|
||||
Phase 166 closes only after that live gate emits
|
||||
`phase166_nvme_rdma_k8s_multipath_reconnect_status=ok` and
|
||||
`cleanup_status=ok`. Component regressions do not substitute for this result.
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
# Phase 166 NVMe/RDMA Kubernetes Multipath Reconnect
|
||||
|
||||
Status: implementation complete; live close gate blocked by lab topology.
|
||||
|
||||
Phase 165 proved the first opt-in Kubernetes NVMe/RDMA publish and attach path:
|
||||
StorageClass intent, target publication, CSI attach, mounted I/O, status, and
|
||||
cleanup all used RDMA without TCP fallback. Initial Phase 166 live runs also
|
||||
proved an important boundary: tearing down the only target behind a mounted
|
||||
single-path filesystem causes I/O errors even when the target returns with the
|
||||
same controller identity and durable hostPath. Transparent outage recovery
|
||||
therefore requires a surviving path; it cannot be claimed from reconnect logic
|
||||
alone.
|
||||
|
||||
## Validation Status
|
||||
|
||||
- The transport-aware CSI reconnect contract and the Phase 166 TestOps close
|
||||
gate are implemented. Local CSI, launcher, ops, script, and scenario checks
|
||||
pass.
|
||||
- Phase 165's published Kubernetes NVMe/RDMA path remains green: one live RDMA
|
||||
controller, mounted writer/reader I/O, no TCP fallback, and zero residue.
|
||||
- The shared reconnect implementation passes the Phase 133 NVMe/TCP RF2
|
||||
endpoint-replacement gate: two initial paths, connect the new endpoint,
|
||||
preserve the surviving controller and mounted Pod, prune the old endpoint,
|
||||
cross-surface agreement, and zero residue.
|
||||
- The Phase 166 RF2 RDMA close gate is not yet runnable honestly on the current
|
||||
lab. m01 and m02 are the only RoCE-capable nodes and also host the two RF2
|
||||
targets. Placing the initiator on either node makes one path a local RDMA
|
||||
self-connect, which the kernel rejects with `Invalid argument`. tp01 is
|
||||
offline and was not configured as a RoCE initiator.
|
||||
- Unblock by adding a third Ready RoCE-capable Kubernetes initiator, or another
|
||||
validated topology where both target endpoints are remote to the initiator.
|
||||
Until that exists, Phase 166 remains open and must not be described as live
|
||||
RDMA multipath support.
|
||||
|
||||
## Goal
|
||||
|
||||
Close the mounted NVMe/RDMA reconnect loop with RF2 multipath. Keep a workload
|
||||
mounted while one RDMA path is unavailable or replaced, reconnect the exact
|
||||
desired RDMA endpoint, and prune only the stale controller after the new path is
|
||||
live.
|
||||
|
||||
## Deliverables
|
||||
|
||||
### D1. Exact Live-Path Contract
|
||||
|
||||
- Reconcile each desired path by exact `(transport, NQN, address)`.
|
||||
- Count a path as connected only when its controller state is `live`.
|
||||
- Preserve explicit `rdma` publish evidence through reconnect calls.
|
||||
- Reject transport changes on an existing staging mount; require restage rather
|
||||
than silently mixing TCP and RDMA.
|
||||
|
||||
### D2. RF2 RDMA Multipath Baseline
|
||||
|
||||
- Publish one RF2 volume from m01 and m02 over their RoCE frontend addresses.
|
||||
- Attach two live RDMA controllers for one NQN to the Kubernetes workload node.
|
||||
- Use hostPath persistence so a restarted target reopens the same durable data.
|
||||
- Require Stage 2 multipath, mounted writer/reader I/O, and no TCP controller.
|
||||
|
||||
### D3. Surviving-Path Outage And Recovery
|
||||
|
||||
- Stop or restart one non-primary RDMA target while the other path remains live.
|
||||
- Preserve the mounted Pod UID and complete I/O during the one-path interval.
|
||||
- Restore the target and require CSI-node to reconnect the missing exact RDMA
|
||||
path without restaging the workload.
|
||||
- Require two live RDMA paths and readable pre-outage data after recovery.
|
||||
|
||||
### D4. Desired Endpoint Replacement
|
||||
|
||||
- Change one replica's desired RDMA listen endpoint while the other path remains
|
||||
live.
|
||||
- Connect the new endpoint before pruning the old controller.
|
||||
- Assert the old endpoint disappears, the new endpoint is live, the second path
|
||||
is untouched, and mounted I/O continues with the same Pod UID.
|
||||
|
||||
### D5. Control, User, And Safety Surfaces
|
||||
|
||||
- Require publish context, host sysfs, `SwBlockVolume.status`, report, dashboard,
|
||||
and explain to agree on RDMA and the current two-path set.
|
||||
- Never satisfy a desired RDMA path with a TCP controller at the same address.
|
||||
- Do not report a reconnecting controller as live.
|
||||
- Scope disconnect/prune/cleanup to the gate-owned NQN and endpoint; do not use
|
||||
`disconnect-all` in the product path or touch unrelated controllers.
|
||||
|
||||
### D6. TestOps Close Gate
|
||||
|
||||
- Reuse the proven Phase 111/132/133 RF2 multipath harness through a thin
|
||||
Phase 166 RDMA wrapper rather than duplicating a single-node gate.
|
||||
- Run with fresh matching product and CSI images on the m01/m02 RoCE lab.
|
||||
- Require source tests, two-path baseline, outage I/O, exact reconnect,
|
||||
connect-before-prune ordering, surface agreement, no TCP fallback, and
|
||||
independent zero-residue verification in one bundle.
|
||||
|
||||
## Exit Criteria
|
||||
|
||||
Phase 166 closes only when an already-mounted Kubernetes RF2 NVMe/RDMA PVC
|
||||
retains I/O through loss of one target path, reconnects that path after target
|
||||
recovery, replaces one desired RDMA endpoint without remounting the Pod, and
|
||||
finishes with exactly two live desired RDMA paths and zero residue.
|
||||
|
||||
This phase does not claim transparent recovery after loss of the only NVMe path,
|
||||
authority promotion or target-node failover, performance, broad hardware
|
||||
compatibility, or an RTO/SLO. Those require separate evidence. The failed
|
||||
single-path live runs are retained as evidence for this boundary rather than
|
||||
being weakened into a passing test.
|
||||
@@ -13,6 +13,7 @@ CHAP_SECRET_NAME="${SW_BLOCK_ISCSI_CHAP_SECRET_NAME:-sw-block-iscsi-chap}"
|
||||
MASTER_PORT="${SW_BLOCK_MASTER_PORT_FORWARD_PORT:-}"
|
||||
CLEANUP_REQUESTED="${SW_BLOCK_MULTI_VOLUME_CLEANUP:-1}"
|
||||
MULTI_VOLUME_PROTOCOL="${SW_BLOCK_MULTI_VOLUME_PROTOCOL:-iscsi}"
|
||||
MULTI_VOLUME_NVME_TRANSPORT="${SW_BLOCK_MULTI_VOLUME_NVME_TRANSPORT:-tcp}"
|
||||
MULTI_VOLUME_NODE_SELECTOR="${SW_BLOCK_MULTI_VOLUME_NODE_SELECTOR:-}"
|
||||
MULTI_VOLUME_STAGE2_MULTIPATH="${SW_BLOCK_MULTI_VOLUME_STAGE2_MULTIPATH:-0}"
|
||||
|
||||
@@ -136,6 +137,7 @@ render_storageclass() {
|
||||
if [[ "$MULTI_VOLUME_PROTOCOL" == "nvme" ]]; then
|
||||
echo " sw-block.seaweedfs.com/protocol: \"nvme\""
|
||||
echo " protocol: \"nvme\""
|
||||
echo " sw-block.seaweedfs.com/nvme-transport: \"${MULTI_VOLUME_NVME_TRANSPORT}\""
|
||||
fi
|
||||
if is_true "$MULTI_VOLUME_STAGE2_MULTIPATH"; then
|
||||
echo " stage2_multipath: \"true\""
|
||||
@@ -420,6 +422,7 @@ write_summary() {
|
||||
echo "namespace=$NAMESPACE"
|
||||
echo "storageclass=$STORAGECLASS_NAME"
|
||||
echo "protocol=$MULTI_VOLUME_PROTOCOL"
|
||||
echo "nvme_transport=$MULTI_VOLUME_NVME_TRANSPORT"
|
||||
echo "stage2_multipath=$MULTI_VOLUME_STAGE2_MULTIPATH"
|
||||
echo "app_node_selector=${MULTI_VOLUME_NODE_SELECTOR:-none}"
|
||||
echo "requested_volume_count=$VOLUME_COUNT"
|
||||
@@ -442,6 +445,14 @@ if [[ "$MULTI_VOLUME_PROTOCOL" != "iscsi" && "$MULTI_VOLUME_PROTOCOL" != "nvme"
|
||||
echo "SW_BLOCK_MULTI_VOLUME_PROTOCOL must be iscsi or nvme" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [[ "$MULTI_VOLUME_NVME_TRANSPORT" != "tcp" && "$MULTI_VOLUME_NVME_TRANSPORT" != "rdma" ]]; then
|
||||
echo "SW_BLOCK_MULTI_VOLUME_NVME_TRANSPORT must be tcp or rdma" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [[ "$MULTI_VOLUME_PROTOCOL" != "nvme" && "$MULTI_VOLUME_NVME_TRANSPORT" != "tcp" ]]; then
|
||||
echo "SW_BLOCK_MULTI_VOLUME_NVME_TRANSPORT=rdma requires SW_BLOCK_MULTI_VOLUME_PROTOCOL=nvme" >&2
|
||||
exit 2
|
||||
fi
|
||||
case "$VOLUME_COUNT" in
|
||||
''|*[!0-9]*|0)
|
||||
echo "SW_BLOCK_MULTI_VOLUME_COUNT must be a positive integer; got: $VOLUME_COUNT" >&2
|
||||
@@ -456,6 +467,7 @@ log "artifact_dir=$ARTIFACT_DIR"
|
||||
log "namespace=$NAMESPACE"
|
||||
log "volume_count=$VOLUME_COUNT"
|
||||
log "protocol=$MULTI_VOLUME_PROTOCOL"
|
||||
log "nvme_transport=$MULTI_VOLUME_NVME_TRANSPORT"
|
||||
log "stage2_multipath=$MULTI_VOLUME_STAGE2_MULTIPATH"
|
||||
log "app_node_selector=${MULTI_VOLUME_NODE_SELECTOR:-none}"
|
||||
log "master_port=$MASTER_PORT"
|
||||
|
||||
@@ -21,6 +21,21 @@ HOST_PATH_DISCONNECT="${SW_BLOCK_NVME_HOST_PATH_DISCONNECT:-0}"
|
||||
FORCE_STAGE2_MULTIPATH="${SW_BLOCK_NVME_FORCE_STAGE2_MULTIPATH:-0}"
|
||||
DESIRED_PATH_CHANGE="${SW_BLOCK_NVME_DESIRED_PATH_CHANGE:-0}"
|
||||
REQUIRE_STALE_PATH_PRUNE="${SW_BLOCK_NVME_REQUIRE_STALE_PATH_PRUNE:-0}"
|
||||
NVME_TRANSPORT="${SW_BLOCK_NVME_TRANSPORT:-tcp}"
|
||||
FRONTEND_IP_MAP="${SW_BLOCK_NVME_FRONTEND_IP_MAP:-}"
|
||||
FRONTEND_NETWORK_CLASS="${SW_BLOCK_NVME_FRONTEND_NETWORK_CLASS:-}"
|
||||
RESTART_PERSISTENCE="${SW_BLOCK_NVME_RESTART_PERSISTENCE:-ephemeral}"
|
||||
STATE_HOSTPATH="${SW_BLOCK_NVME_STATE_HOSTPATH:-/var/lib/sw-block}"
|
||||
CLEANUP_STATE_HOSTPATH="${SW_BLOCK_NVME_CLEANUP_STATE_HOSTPATH:-0}"
|
||||
REQUIRE_HOST_TRANSPORT="${SW_BLOCK_NVME_REQUIRE_HOST_TRANSPORT:-}"
|
||||
STRICT_CLEANUP_SCOPE="${SW_BLOCK_NVME_STRICT_CLEANUP_SCOPE:-0}"
|
||||
APP_NODE_OVERRIDE="${SW_BLOCK_NVME_APP_NODE_SELECTOR:-}"
|
||||
APP_HOST_SSH_ADDR="${SW_BLOCK_NVME_APP_HOST_SSH_ADDR:-}"
|
||||
APP_HOST_SSH_USER="${SW_BLOCK_NVME_APP_HOST_SSH_USER:-testdev}"
|
||||
APP_HOST_SSH_KEY="${SW_BLOCK_NVME_APP_HOST_SSH_KEY:-}"
|
||||
VOLUME_ID=""
|
||||
NQN=""
|
||||
BASELINE_CRDS="${ARTIFACT_DIR}/cleanup/baseline-crds.txt"
|
||||
|
||||
mkdir -p "${ARTIFACT_DIR}"/{bin,build,values,install,multi-volume,inject,surfaces,cleanup}
|
||||
: >"${SUMMARY}"
|
||||
@@ -29,12 +44,57 @@ write_summary() {
|
||||
echo "$*" | tee -a "${SUMMARY}" >/dev/null
|
||||
}
|
||||
|
||||
strict_cleanup_scope_enabled() {
|
||||
[[ "${STRICT_CLEANUP_SCOPE}" == "1" || "${STRICT_CLEANUP_SCOPE}" == "true" ]]
|
||||
}
|
||||
|
||||
record_and_require_clean_baseline() {
|
||||
: >"${BASELINE_CRDS}"
|
||||
kubectl get crd -o name 2>/dev/null | grep -E '^customresourcedefinition\.apiextensions\.k8s\.io/swblock' \
|
||||
| sed 's#^.*/##' >"${BASELINE_CRDS}" || true
|
||||
local residue
|
||||
residue="$({
|
||||
helm status "${HELM_RELEASE}" --namespace "${HELM_NAMESPACE}" 2>/dev/null && echo "helm/${HELM_RELEASE}"
|
||||
kubectl get deploy,daemonset,statefulset,pod,svc,pvc,pv,configmap,secret,serviceaccount -A -o name 2>/dev/null \
|
||||
| grep -E '(sw-block|seaweed-block|block\.csi\.seaweedfs\.com)' || true
|
||||
kubectl get storageclass,csidriver,clusterrole,clusterrolebinding -o name 2>/dev/null \
|
||||
| grep -E '(sw-block|seaweed-block|block\.csi\.seaweedfs\.com)' || true
|
||||
kubectl get volumeattachments.storage.k8s.io \
|
||||
-o custom-columns=NAME:.metadata.name,ATTACHER:.spec.attacher,PV:.spec.source.persistentVolumeName --no-headers 2>/dev/null \
|
||||
| grep 'block\.csi\.seaweedfs\.com' || true
|
||||
kubectl get validatingadmissionpolicy,validatingadmissionpolicybinding -o name 2>/dev/null \
|
||||
| grep -E '(sw-block|seaweed-block|block\.seaweedfs\.com)' || true
|
||||
kubectl get swblockclusters.block.seaweedfs.com,swblockvolumes.block.seaweedfs.com -A -o name 2>/dev/null || true
|
||||
sudo find /sys/kernel/config/nvmet/subsystems -mindepth 1 -maxdepth 1 -type d \
|
||||
-name '*io.seaweedfs*' -printf 'nvmet/%f\n' 2>/dev/null || true
|
||||
for pid_file in /sys/block/nbd*/pid; do
|
||||
[[ -s "${pid_file}" ]] && printf 'active-nbd/%s\n' "$(basename "$(dirname "${pid_file}")")"
|
||||
done
|
||||
} | awk 'NF')"
|
||||
if [[ -n "${residue}" ]]; then
|
||||
printf 'refusing to run NVMe path gate on a non-clean shared lab:\n%s\n' "${residue}" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
capture() {
|
||||
local out="$1"
|
||||
shift
|
||||
"$@" >"$out" 2>&1 || true
|
||||
}
|
||||
|
||||
run_on_app_host() {
|
||||
if [[ -z "${APP_HOST_SSH_ADDR}" ]]; then
|
||||
"$@"
|
||||
return
|
||||
fi
|
||||
local -a ssh_opts=(-o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new)
|
||||
if [[ -n "${APP_HOST_SSH_KEY}" ]]; then
|
||||
ssh_opts=(-i "${APP_HOST_SSH_KEY}" "${ssh_opts[@]}")
|
||||
fi
|
||||
ssh "${ssh_opts[@]}" "${APP_HOST_SSH_USER}@${APP_HOST_SSH_ADDR}" "$@"
|
||||
}
|
||||
|
||||
delete_pod_before_uninstall() {
|
||||
local pod="$1"
|
||||
local log="${ARTIFACT_DIR}/cleanup/delete-${pod}.txt"
|
||||
@@ -61,6 +121,8 @@ wait_for_no_sw_block_k8s() {
|
||||
{
|
||||
kubectl get deploy,daemonset,statefulset,pod,svc,pvc,pv,configmap,secret,serviceaccount -A -o name
|
||||
kubectl get storageclass,csidriver,clusterrole,clusterrolebinding -o name
|
||||
kubectl get volumeattachments.storage.k8s.io \
|
||||
-o custom-columns=NAME:.metadata.name,ATTACHER:.spec.attacher,PV:.spec.source.persistentVolumeName --no-headers
|
||||
} 2>/dev/null | grep -E '(sw-block|seaweed-block|block\.csi\.seaweedfs\.com)' || true
|
||||
)"
|
||||
if [[ -z "${residue}" ]]; then
|
||||
@@ -74,42 +136,135 @@ wait_for_no_sw_block_k8s() {
|
||||
return 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
set +e
|
||||
# Delete mounted consumers while CSI is still installed so normal detach/delete can run.
|
||||
delete_pod_before_uninstall "${MOUNTED_POD}"
|
||||
kubectl -n "${APP_NAMESPACE}" delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=120s >/dev/null 2>&1
|
||||
kubectl -n "${APP_NAMESPACE}" delete pod sw-block-multi-reader-1 sw-block-multi-writer-1 --ignore-not-found=true --wait=true --timeout=120s >/dev/null 2>&1
|
||||
kubectl -n "${APP_NAMESPACE}" delete pvc sw-block-multi-pvc-1 --ignore-not-found=true --wait=true --timeout=120s >/dev/null 2>&1
|
||||
kubectl delete storageclass sw-block-multi --ignore-not-found=true --wait=true --timeout=120s >/dev/null 2>&1
|
||||
sudo -n nvme disconnect-all >/dev/null 2>&1 || true
|
||||
helm status "${HELM_RELEASE}" --namespace "${HELM_NAMESPACE}" >/dev/null 2>&1 && \
|
||||
helm uninstall "${HELM_RELEASE}" --namespace "${HELM_NAMESPACE}" --wait --timeout 240s \
|
||||
>"${ARTIFACT_DIR}/cleanup/helm-uninstall.txt" 2>&1
|
||||
wait_for_no_sw_block_k8s "${ARTIFACT_DIR}/cleanup/wait-after-helm-uninstall.txt" || true
|
||||
kubectl -n "${APP_NAMESPACE}" delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=false >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=false >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" get swblockvolumes.block.seaweedfs.com -o name 2>/dev/null | \
|
||||
xargs -r -n1 kubectl -n "${HELM_NAMESPACE}" patch --type=merge -p '{"metadata":{"finalizers":[]}}' >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" delete swblockvolumes.block.seaweedfs.com --all --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" delete swblockclusters.block.seaweedfs.com --all --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1
|
||||
kubectl delete validatingadmissionpolicy,validatingadmissionpolicybinding -l "app.kubernetes.io/instance=${HELM_RELEASE}" --ignore-not-found=true >/dev/null 2>&1
|
||||
kubectl delete crd \
|
||||
wait_for_gate_volume_detached() {
|
||||
local volume_id="$1"
|
||||
local log="${ARTIFACT_DIR}/cleanup/wait-volume-detached.txt"
|
||||
local stable=0
|
||||
: >"${log}"
|
||||
[[ -n "${volume_id}" ]] || return 0
|
||||
for _ in $(seq 1 180); do
|
||||
local count
|
||||
count="$(kubectl get volumeattachments.storage.k8s.io \
|
||||
-o custom-columns=PV:.spec.source.persistentVolumeName --no-headers 2>/dev/null \
|
||||
| awk -v volume="${volume_id}" '$1 == volume {count++} END {print count + 0}')"
|
||||
printf 'attachment_count=%s\n' "${count}" >>"${log}"
|
||||
if [[ "${count}" == 0 ]]; then
|
||||
stable=$((stable + 1))
|
||||
[[ "${stable}" == 3 ]] && return 0
|
||||
else
|
||||
stable=0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
wait_for_gate_pv_deleted() {
|
||||
local volume_id="$1"
|
||||
local log="${ARTIFACT_DIR}/cleanup/wait-pv-deleted.txt"
|
||||
: >"${log}"
|
||||
[[ -n "${volume_id}" ]] || return 0
|
||||
for _ in $(seq 1 180); do
|
||||
if ! kubectl get pv "${volume_id}" >/dev/null 2>&1; then
|
||||
echo "pv_deleted=true" >>"${log}"
|
||||
return 0
|
||||
fi
|
||||
echo "pv_deleted=false" >>"${log}"
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
disconnect_gate_nvme_paths() {
|
||||
local nqn
|
||||
{
|
||||
[[ -n "${NQN}" ]] && printf '%s\n' "${NQN}"
|
||||
if strict_cleanup_scope_enabled; then
|
||||
kubectl -n "${HELM_NAMESPACE}" get swblockvolume sw-block-multi-pvc-1 -o jsonpath='{.status.nvme.nqn}{"\n"}' 2>/dev/null || true
|
||||
else
|
||||
kubectl -n "${HELM_NAMESPACE}" get swblockvolumes -o jsonpath='{range .items[*]}{.status.nvme.nqn}{"\n"}{end}' 2>/dev/null || true
|
||||
fi
|
||||
} | awk 'NF && !seen[$0]++' | while IFS= read -r nqn; do
|
||||
run_on_app_host sudo -n nvme disconnect -n "${nqn}" >/dev/null 2>&1 || true
|
||||
done
|
||||
}
|
||||
|
||||
delete_gate_created_crds() {
|
||||
local crd
|
||||
for crd in \
|
||||
swblockclusters.block.seaweedfs.com \
|
||||
swblockvolumes.block.seaweedfs.com \
|
||||
swblockreplicaeligibilities.block.seaweedfs.com \
|
||||
swblockreplicarebuilds.block.seaweedfs.com \
|
||||
swblockreplicafailbacks.block.seaweedfs.com \
|
||||
swblockfrontendpublications.block.seaweedfs.com \
|
||||
--ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1
|
||||
swblockfrontendpublications.block.seaweedfs.com; do
|
||||
if strict_cleanup_scope_enabled && grep -Fqx "${crd}" "${BASELINE_CRDS}"; then
|
||||
continue
|
||||
fi
|
||||
kubectl delete crd "${crd}" --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1
|
||||
done
|
||||
}
|
||||
|
||||
cleanup_gate_state_hostpath() {
|
||||
[[ "${CLEANUP_STATE_HOSTPATH}" == "1" || "${CLEANUP_STATE_HOSTPATH}" == "true" ]] || return 0
|
||||
case "${STATE_HOSTPATH}" in
|
||||
/var/lib/sw-block/testops-*) sudo -n rm -rf -- "${STATE_HOSTPATH}" ;;
|
||||
*) echo "refusing to remove non-testops state hostPath ${STATE_HOSTPATH}" >&2; return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
set +e
|
||||
local cleanup_volume_id="${VOLUME_ID}"
|
||||
if [[ -z "${cleanup_volume_id}" ]]; then
|
||||
cleanup_volume_id="$(kubectl -n "${APP_NAMESPACE}" get pvc sw-block-multi-pvc-1 \
|
||||
-o jsonpath='{.spec.volumeName}' 2>/dev/null || true)"
|
||||
fi
|
||||
# Delete mounted consumers while CSI is still installed so normal detach/delete can run.
|
||||
delete_pod_before_uninstall "${MOUNTED_POD}"
|
||||
if ! strict_cleanup_scope_enabled; then
|
||||
kubectl -n "${APP_NAMESPACE}" delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=120s >/dev/null 2>&1
|
||||
fi
|
||||
kubectl -n "${APP_NAMESPACE}" delete pod sw-block-multi-reader-1 sw-block-multi-writer-1 --ignore-not-found=true --wait=true --timeout=120s >/dev/null 2>&1
|
||||
wait_for_gate_volume_detached "${cleanup_volume_id}" || true
|
||||
kubectl -n "${APP_NAMESPACE}" delete pvc sw-block-multi-pvc-1 --ignore-not-found=true --wait=true --timeout=120s >/dev/null 2>&1
|
||||
kubectl delete storageclass sw-block-multi --ignore-not-found=true --wait=true --timeout=120s >/dev/null 2>&1
|
||||
wait_for_gate_pv_deleted "${cleanup_volume_id}" || true
|
||||
disconnect_gate_nvme_paths
|
||||
helm status "${HELM_RELEASE}" --namespace "${HELM_NAMESPACE}" >/dev/null 2>&1 && \
|
||||
helm uninstall "${HELM_RELEASE}" --namespace "${HELM_NAMESPACE}" --wait --timeout 240s \
|
||||
>"${ARTIFACT_DIR}/cleanup/helm-uninstall.txt" 2>&1
|
||||
wait_for_no_sw_block_k8s "${ARTIFACT_DIR}/cleanup/wait-after-helm-uninstall.txt" || true
|
||||
if strict_cleanup_scope_enabled; then
|
||||
if [[ -n "${VOLUME_ID}" ]]; then
|
||||
kubectl -n "${APP_NAMESPACE}" delete deploy -l "sw-block.seaweedfs.com/volume=${VOLUME_ID}" --ignore-not-found=true --wait=false >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" delete deploy -l "sw-block.seaweedfs.com/volume=${VOLUME_ID}" --ignore-not-found=true --wait=false >/dev/null 2>&1
|
||||
fi
|
||||
kubectl -n "${HELM_NAMESPACE}" patch swblockvolume sw-block-multi-pvc-1 --type=merge -p '{"metadata":{"finalizers":[]}}' >/dev/null 2>&1 || true
|
||||
kubectl -n "${HELM_NAMESPACE}" delete swblockvolume sw-block-multi-pvc-1 --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" delete swblockcluster sw-block --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1
|
||||
else
|
||||
kubectl -n "${APP_NAMESPACE}" delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=false >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=false >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" get swblockvolumes.block.seaweedfs.com -o name 2>/dev/null | \
|
||||
xargs -r -n1 kubectl -n "${HELM_NAMESPACE}" patch --type=merge -p '{"metadata":{"finalizers":[]}}' >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" delete swblockvolumes.block.seaweedfs.com --all --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1
|
||||
kubectl -n "${HELM_NAMESPACE}" delete swblockclusters.block.seaweedfs.com --all --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1
|
||||
fi
|
||||
kubectl delete validatingadmissionpolicy,validatingadmissionpolicybinding -l "app.kubernetes.io/instance=${HELM_RELEASE}" --ignore-not-found=true >/dev/null 2>&1
|
||||
delete_gate_created_crds
|
||||
kubectl get pv --no-headers 2>/dev/null | awk '/sw-block-multi/ {print $1}' | \
|
||||
xargs -r -n1 kubectl patch pv --type=merge -p '{"metadata":{"finalizers":[]}}' >/dev/null 2>&1
|
||||
kubectl -n "${APP_NAMESPACE}" get pvc sw-block-multi-pvc-1 >/dev/null 2>&1 && \
|
||||
kubectl -n "${APP_NAMESPACE}" patch pvc sw-block-multi-pvc-1 --type=merge -p '{"metadata":{"finalizers":[]}}' >/dev/null 2>&1
|
||||
kubectl get pv --no-headers 2>/dev/null | awk '/sw-block-multi/ {print $1}' | xargs -r kubectl delete pv --wait=false >/dev/null 2>&1
|
||||
sudo -n nvme disconnect-all >/dev/null 2>&1 || true
|
||||
disconnect_gate_nvme_paths
|
||||
cleanup_gate_state_hostpath >/dev/null 2>&1 || true
|
||||
set -e
|
||||
}
|
||||
if strict_cleanup_scope_enabled; then
|
||||
record_and_require_clean_baseline
|
||||
fi
|
||||
trap cleanup EXIT
|
||||
|
||||
wait_for_port() {
|
||||
@@ -133,8 +288,8 @@ with_master_port_forward() {
|
||||
wait "${pf_pid}" >/dev/null 2>&1 || true
|
||||
return 1
|
||||
fi
|
||||
"$@"
|
||||
local rc=$?
|
||||
local rc=0
|
||||
"$@" || rc=$?
|
||||
kill "${pf_pid}" >/dev/null 2>&1 || true
|
||||
wait "${pf_pid}" >/dev/null 2>&1 || true
|
||||
return "${rc}"
|
||||
@@ -172,7 +327,7 @@ wait_for_crd_status() {
|
||||
for _ in $(seq 1 90); do
|
||||
kubectl -n "${HELM_NAMESPACE}" get swblockvolumes -o json >"${out_json}" 2>/dev/null || true
|
||||
python3 - "${out_json}" "${want_status}" "${want_reason}" "${want_path_count}" <<'PY' && return 0 || true
|
||||
import json, sys
|
||||
import json, os, sys
|
||||
path, want_status, want_reason, want_path_count = sys.argv[1:]
|
||||
try:
|
||||
doc=json.load(open(path))
|
||||
@@ -183,10 +338,13 @@ if len(items) != 1:
|
||||
raise SystemExit(1)
|
||||
st=items[0].get("status") or {}
|
||||
nv=st.get("nvme") or {}
|
||||
required_transport=os.environ.get("SW_BLOCK_NVME_REQUIRE_HOST_TRANSPORT", "")
|
||||
if st.get("status") != want_status or st.get("reasonCode") != want_reason:
|
||||
raise SystemExit(1)
|
||||
if want_path_count != "-" and int(nv.get("pathCount", -1)) != int(want_path_count):
|
||||
raise SystemExit(1)
|
||||
if required_transport and nv.get("transport") != required_transport:
|
||||
raise SystemExit(1)
|
||||
conds={c.get("type"): c.get("status") for c in st.get("conditions") or []}
|
||||
if want_status == "blocked" and conds.get("Ready") == "True":
|
||||
raise SystemExit(1)
|
||||
@@ -203,9 +361,10 @@ write_host_nvme_path_info() {
|
||||
local nqn="$2"
|
||||
local json_path="${ARTIFACT_DIR}/inject/nvme-list-subsys.${label}.json"
|
||||
local env_path="${ARTIFACT_DIR}/inject/nvme-path-info.${label}.env"
|
||||
sudo -n nvme list-subsys -o json >"${json_path}"
|
||||
run_on_app_host sudo -n nvme list-subsys -o json >"${json_path}"
|
||||
python3 - "${json_path}" "${nqn}" >"${env_path}" <<'PY'
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
path, want_nqn = sys.argv[1:]
|
||||
@@ -236,8 +395,25 @@ paths = []
|
||||
for sub in walk(doc):
|
||||
paths.extend(sub.get("Paths") or [])
|
||||
|
||||
def field(path, name):
|
||||
return str(path.get(name) or path.get(name.lower()) or "").lower()
|
||||
|
||||
def controller(path):
|
||||
name = path.get("Name") or path.get("Controller") or path.get("Device") or ""
|
||||
if name and not str(name).startswith("/dev/"):
|
||||
name = "/dev/" + str(name)
|
||||
return str(name)
|
||||
|
||||
records = [(controller(p), field(p, "Transport"), field(p, "State"), addr(p.get("Address"))) for p in paths]
|
||||
required = __import__("os").environ.get("SW_BLOCK_NVME_REQUIRE_HOST_TRANSPORT", "").lower()
|
||||
print(f"path_count={len(paths)}")
|
||||
print("addrs=" + ",".join(a for a in [addr(p.get("Address")) for p in paths] if a))
|
||||
print("addrs=" + ",".join(a for _, _, _, a in records if a))
|
||||
print("path_records=" + ";".join(f"{c}|{t}|{s}|{a}" for c, t, s, a in records))
|
||||
if required:
|
||||
print(f"required_transport_path_count={sum(t == required for _, t, _, _ in records)}")
|
||||
print(f"required_transport_live_path_count={sum(t == required and s == 'live' for _, t, s, _ in records)}")
|
||||
print(f"unexpected_transport_path_count={sum(t != required for _, t, _, _ in records)}")
|
||||
print(f"non_live_path_count={sum(s != 'live' for _, _, s, _ in records)}")
|
||||
if paths:
|
||||
first = paths[0]
|
||||
name = first.get("Name") or first.get("Controller") or first.get("Device") or ""
|
||||
@@ -248,6 +424,64 @@ if paths:
|
||||
PY
|
||||
}
|
||||
|
||||
host_controller_for_addr() {
|
||||
local env_path="$1"
|
||||
local addr="$2"
|
||||
python3 - "${env_path}" "${addr}" <<'PY'
|
||||
import sys
|
||||
fields={}
|
||||
for line in open(sys.argv[1]):
|
||||
key, _, value=line.rstrip("\n").partition("=")
|
||||
fields[key]=value
|
||||
for record in fields.get("path_records", "").split(";"):
|
||||
parts=record.split("|", 3)
|
||||
if len(parts) == 4 and parts[3] == sys.argv[2]:
|
||||
print(parts[0])
|
||||
raise SystemExit(0)
|
||||
raise SystemExit(1)
|
||||
PY
|
||||
}
|
||||
|
||||
require_host_controller_live() {
|
||||
local env_path="$1"
|
||||
local controller="$2"
|
||||
local addr="$3"
|
||||
local transport="$4"
|
||||
python3 - "${env_path}" "${controller}" "${addr}" "${transport}" <<'PY'
|
||||
import sys
|
||||
fields={}
|
||||
for line in open(sys.argv[1]):
|
||||
key, _, value=line.rstrip("\n").partition("=")
|
||||
fields[key]=value
|
||||
want=(sys.argv[2], sys.argv[4], "live", sys.argv[3])
|
||||
records=[tuple(record.split("|", 3)) for record in fields.get("path_records", "").split(";") if record]
|
||||
raise SystemExit(0 if want in records else 1)
|
||||
PY
|
||||
}
|
||||
|
||||
wait_for_host_transport_live_path_count() {
|
||||
local label="$1"
|
||||
local nqn="$2"
|
||||
local want="$3"
|
||||
local allow_non_live="${4:-false}"
|
||||
[[ -n "${REQUIRE_HOST_TRANSPORT}" ]] || return 0
|
||||
for _ in $(seq 1 90); do
|
||||
write_host_nvme_path_info "${label}" "${nqn}" || true
|
||||
local total live unexpected non_live
|
||||
total="$(read_env_value "${ARTIFACT_DIR}/inject/nvme-path-info.${label}.env" path_count)"
|
||||
live="$(read_env_value "${ARTIFACT_DIR}/inject/nvme-path-info.${label}.env" required_transport_live_path_count)"
|
||||
unexpected="$(read_env_value "${ARTIFACT_DIR}/inject/nvme-path-info.${label}.env" unexpected_transport_path_count)"
|
||||
non_live="$(read_env_value "${ARTIFACT_DIR}/inject/nvme-path-info.${label}.env" non_live_path_count)"
|
||||
if [[ "${live}" == "${want}" && "${unexpected}" == "0" ]] && \
|
||||
{ [[ "${allow_non_live}" == "true" ]] || [[ "${total}" == "${want}" && "${non_live}" == "0" ]]; }; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "NVMe host paths did not reach ${want} live ${REQUIRE_HOST_TRANSPORT} controllers for ${nqn}" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
read_env_value() {
|
||||
local path="$1"
|
||||
local key="$2"
|
||||
@@ -398,9 +632,24 @@ PY
|
||||
}
|
||||
|
||||
write_summary "${PHASE_STATUS_KEY}=running"
|
||||
cleanup
|
||||
if ! strict_cleanup_scope_enabled; then
|
||||
cleanup
|
||||
fi
|
||||
|
||||
echo "[phase111] build sw-block CLI"
|
||||
GENERATE_NVME_ARGS=(
|
||||
--nvme-transport "${NVME_TRANSPORT}"
|
||||
--restart-persistence "${RESTART_PERSISTENCE}"
|
||||
)
|
||||
if [[ -n "${FRONTEND_IP_MAP}" ]]; then
|
||||
GENERATE_NVME_ARGS+=(
|
||||
--frontend-ip-map "${FRONTEND_IP_MAP}"
|
||||
--frontend-network-class "${FRONTEND_NETWORK_CLASS}"
|
||||
)
|
||||
fi
|
||||
if [[ "${RESTART_PERSISTENCE}" == "hostpath" ]]; then
|
||||
GENERATE_NVME_ARGS+=(--state-hostpath "${STATE_HOSTPATH}")
|
||||
fi
|
||||
(
|
||||
cd "${ROOT}"
|
||||
go build -o "${ARTIFACT_DIR}/bin/sw-block" ./cmd/sw-block
|
||||
@@ -411,7 +660,8 @@ echo "[phase111] build sw-block CLI"
|
||||
--csi-image "${CSI_IMAGE}" \
|
||||
--protocol nvme \
|
||||
--replication-factor 2 \
|
||||
--node-limit 2 >"${ARTIFACT_DIR}/values/generate.stdout.txt"
|
||||
--node-limit 2 \
|
||||
"${GENERATE_NVME_ARGS[@]}" >"${ARTIFACT_DIR}/values/generate.stdout.txt"
|
||||
)
|
||||
cat >>"${ARTIFACT_DIR}/values/values.nvme.yaml" <<'YAML'
|
||||
operatorStatus:
|
||||
@@ -444,6 +694,12 @@ python3 -c "${python_read_nodes}" "${ARTIFACT_DIR}"
|
||||
|
||||
grep -q '^network_mode=external-nvme$' "${ARTIFACT_DIR}/values/generate.stdout.txt"
|
||||
grep -q 'externalNVMe: true' "${ARTIFACT_DIR}/values/values.nvme.yaml"
|
||||
grep -q "^nvme_transport=${NVME_TRANSPORT}$" "${ARTIFACT_DIR}/values/generate.stdout.txt"
|
||||
write_summary "nvme_transport=${NVME_TRANSPORT}"
|
||||
write_summary "restart_persistence_mode=${RESTART_PERSISTENCE}"
|
||||
if [[ -n "${REQUIRE_HOST_TRANSPORT}" ]]; then
|
||||
write_summary "required_host_transport=${REQUIRE_HOST_TRANSPORT}"
|
||||
fi
|
||||
|
||||
echo "[phase111] install Helm stack"
|
||||
(
|
||||
@@ -457,12 +713,18 @@ echo "[phase111] install Helm stack"
|
||||
-f "${ARTIFACT_DIR}/values/values.nvme.yaml" --wait --timeout 10m >"${ARTIFACT_DIR}/install/helm-install.txt"
|
||||
)
|
||||
|
||||
APP_NODE="$(cat "${ARTIFACT_DIR}/values/app-node.txt")"
|
||||
APP_NODE="${APP_NODE_OVERRIDE:-$(cat "${ARTIFACT_DIR}/values/app-node.txt")}"
|
||||
kubectl get node "${APP_NODE}" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' | grep -q '^True$'
|
||||
if [[ -n "${APP_HOST_SSH_ADDR}" ]]; then
|
||||
run_on_app_host true
|
||||
fi
|
||||
write_summary "app_node=${APP_NODE}"
|
||||
echo "[phase111] create one RF2 NVMe PVC and verify data path"
|
||||
(
|
||||
cd "${ROOT}"
|
||||
SW_BLOCK_MULTI_VOLUME_NODE_SELECTOR="${APP_NODE}" \
|
||||
SW_BLOCK_MULTI_VOLUME_PROTOCOL=nvme \
|
||||
SW_BLOCK_MULTI_VOLUME_NVME_TRANSPORT="${NVME_TRANSPORT}" \
|
||||
SW_BLOCK_MULTI_VOLUME_RF=2 \
|
||||
SW_BLOCK_MULTI_VOLUME_COUNT=1 \
|
||||
SW_BLOCK_MULTI_VOLUME_CLEANUP=0 \
|
||||
@@ -473,8 +735,18 @@ echo "[phase111] create one RF2 NVMe PVC and verify data path"
|
||||
grep -q '^multi_volume_status=ok$' "${ARTIFACT_DIR}/multi-volume/multi-volume-summary.txt"
|
||||
grep -q '^writer_verified_count=1$' "${ARTIFACT_DIR}/multi-volume/multi-volume-summary.txt"
|
||||
grep -q '^reader_verified_count=1$' "${ARTIFACT_DIR}/multi-volume/multi-volume-summary.txt"
|
||||
grep -q "^nvme_transport=${NVME_TRANSPORT}$" "${ARTIFACT_DIR}/multi-volume/multi-volume-summary.txt"
|
||||
kubectl get storageclass sw-block-multi -o yaml >"${ARTIFACT_DIR}/multi-volume/storageclass.yaml"
|
||||
grep -q "sw-block.seaweedfs.com/nvme-transport: ${NVME_TRANSPORT}" "${ARTIFACT_DIR}/multi-volume/storageclass.yaml"
|
||||
|
||||
wait_for_crd_status "healthy" "ready" "first_volume_verified" "2"
|
||||
VOLUME_ID="$(volume_field_from_crd "${ARTIFACT_DIR}/surfaces/swblockvolumes.healthy.json" "status.volumeID")"
|
||||
NQN="$(volume_field_from_crd "${ARTIFACT_DIR}/surfaces/swblockvolumes.healthy.json" "status.nvme.nqn")"
|
||||
wait_for_host_transport_live_path_count "healthy" "${NQN}" "2"
|
||||
if [[ -n "${REQUIRE_HOST_TRANSPORT}" ]]; then
|
||||
write_summary "initial_live_${REQUIRE_HOST_TRANSPORT}_path_count=2"
|
||||
write_summary "initial_tcp_fallback_observed=false"
|
||||
fi
|
||||
|
||||
MOUNTED_POD_UID_BEFORE=""
|
||||
if [[ "${MOUNTED_IO}" == "1" || "${MOUNTED_IO}" == "true" ]]; then
|
||||
@@ -532,7 +804,7 @@ if len(desired) != 2:
|
||||
primary = st.get("primaryReplicaID") or ""
|
||||
volume_id = st.get("volumeID") or ""
|
||||
nqn = nv.get("nqn") or ""
|
||||
if not volume_id or not nqn:
|
||||
if not volume_id or not nqn or not primary:
|
||||
raise SystemExit(f"missing volume_id/nqn in status: {st}")
|
||||
|
||||
current_addrs = set(desired)
|
||||
@@ -551,13 +823,16 @@ for item in deploys.get("items") or []:
|
||||
if not str(arg).startswith("--nvme-listen="):
|
||||
continue
|
||||
old_addr = str(arg).split("=", 1)[1]
|
||||
if old_addr in current_addrs:
|
||||
candidates.append((replica == primary, replica, namespace, name, ci, ai, old_addr))
|
||||
if old_addr in current_addrs and replica and replica != primary:
|
||||
candidates.append((replica, namespace, name, ci, ai, old_addr))
|
||||
|
||||
if not candidates:
|
||||
raise SystemExit(f"no deployment --nvme-listen matched desired addrs {desired}")
|
||||
candidates.sort(key=lambda x: (x[0], x[1], x[3]))
|
||||
_, replica, namespace, name, ci, ai, old_addr = candidates[0]
|
||||
candidates.sort(key=lambda x: (x[0], x[2]))
|
||||
replica, namespace, name, ci, ai, old_addr = candidates[0]
|
||||
surviving_addr = next((addr for addr in desired if addr != old_addr), "")
|
||||
if not surviving_addr:
|
||||
raise SystemExit(f"no surviving desired path beside {old_addr}")
|
||||
host, port_text = old_addr.rsplit(":", 1)
|
||||
port = int(port_text)
|
||||
used = {int(a.rsplit(":", 1)[1]) for a in current_addrs if a.startswith(host + ":")}
|
||||
@@ -578,8 +853,10 @@ for key, value in {
|
||||
"target_namespace": namespace,
|
||||
"target_deployment": name,
|
||||
"target_replica": replica,
|
||||
"primary_replica": primary,
|
||||
"old_desired_path": old_addr,
|
||||
"new_desired_path": new_addr,
|
||||
"surviving_desired_path": surviving_addr,
|
||||
"initial_desired_paths": ",".join(desired),
|
||||
"initial_path_count": str(len(desired)),
|
||||
}.items():
|
||||
@@ -594,17 +871,45 @@ PY
|
||||
INITIAL_PATH_COUNT="$(read_env_value "${ARTIFACT_DIR}/inject/desired-path-change.env" initial_path_count)"
|
||||
INITIAL_DESIRED_PATHS="$(read_env_value "${ARTIFACT_DIR}/inject/desired-path-change.env" initial_desired_paths)"
|
||||
TARGET_REPLICA="$(read_env_value "${ARTIFACT_DIR}/inject/desired-path-change.env" target_replica)"
|
||||
PRIMARY_REPLICA="$(read_env_value "${ARTIFACT_DIR}/inject/desired-path-change.env" primary_replica)"
|
||||
SURVIVING_DESIRED_PATH="$(read_env_value "${ARTIFACT_DIR}/inject/desired-path-change.env" surviving_desired_path)"
|
||||
write_summary "volume_id=${VOLUME_ID}"
|
||||
write_summary "nvme_nqn=${NQN}"
|
||||
write_summary "initial_path_count=${INITIAL_PATH_COUNT}"
|
||||
write_summary "initial_desired_paths=${INITIAL_DESIRED_PATHS}"
|
||||
write_summary "target_deployment=${TARGET_NAMESPACE}/${TARGET_DEPLOY}"
|
||||
write_summary "target_replica=${TARGET_REPLICA}"
|
||||
write_summary "primary_replica=${PRIMARY_REPLICA}"
|
||||
write_summary "endpoint_change_is_non_primary=true"
|
||||
write_summary "old_desired_path=${OLD_DESIRED_PATH}"
|
||||
write_summary "new_desired_path=${NEW_DESIRED_PATH}"
|
||||
write_summary "surviving_desired_path=${SURVIVING_DESIRED_PATH}"
|
||||
|
||||
write_host_nvme_path_info "before-desired-path-change" "${NQN}"
|
||||
SURVIVING_CONTROLLER="$(host_controller_for_addr "${ARTIFACT_DIR}/inject/nvme-path-info.before-desired-path-change.env" "${SURVIVING_DESIRED_PATH}")"
|
||||
[[ -n "${SURVIVING_CONTROLLER}" ]]
|
||||
require_host_controller_live "${ARTIFACT_DIR}/inject/nvme-path-info.before-desired-path-change.env" \
|
||||
"${SURVIVING_CONTROLLER}" "${SURVIVING_DESIRED_PATH}" "${NVME_TRANSPORT}"
|
||||
write_summary "surviving_controller_before=${SURVIVING_CONTROLLER}"
|
||||
|
||||
TRANSITION_IO_PID=""
|
||||
if [[ "${MOUNTED_IO}" == "1" || "${MOUNTED_IO}" == "true" ]]; then
|
||||
kubectl -n "${APP_NAMESPACE}" exec "${MOUNTED_POD}" -- sh -c \
|
||||
'set -eu; rm -f /tmp/phase166-stop; i=0; while [ ! -e /tmp/phase166-stop ]; do i=$((i+1)); echo "transition-${i}" >> /data/phase166-transition.txt; sync; tail -n 1 /data/phase166-transition.txt; sleep 1; done' \
|
||||
>"${ARTIFACT_DIR}/inject/mounted-during-desired-path-change.log" 2>&1 &
|
||||
TRANSITION_IO_PID=$!
|
||||
for _ in $(seq 1 30); do
|
||||
[[ -s "${ARTIFACT_DIR}/inject/mounted-during-desired-path-change.log" ]] && break
|
||||
sleep 0.2
|
||||
done
|
||||
[[ -s "${ARTIFACT_DIR}/inject/mounted-during-desired-path-change.log" ]]
|
||||
fi
|
||||
|
||||
kubectl -n "${TARGET_NAMESPACE}" patch "deploy/${TARGET_DEPLOY}" --type=json --patch-file "${ARTIFACT_DIR}/inject/desired-path-change-patch.json" \
|
||||
>"${ARTIFACT_DIR}/inject/patch-desired-path.txt" 2>&1
|
||||
write_host_nvme_path_info "during-desired-path-change" "${NQN}"
|
||||
require_host_controller_live "${ARTIFACT_DIR}/inject/nvme-path-info.during-desired-path-change.env" \
|
||||
"${SURVIVING_CONTROLLER}" "${SURVIVING_DESIRED_PATH}" "${NVME_TRANSPORT}"
|
||||
kubectl -n "${TARGET_NAMESPACE}" rollout status "deploy/${TARGET_DEPLOY}" --timeout=240s \
|
||||
>"${ARTIFACT_DIR}/inject/rollout-desired-path-change.txt" 2>&1
|
||||
kubectl -n "${TARGET_NAMESPACE}" get deploy,pod -l app=sw-blockvolume -o wide >"${ARTIFACT_DIR}/inject/blockvolume.after-desired-change.txt"
|
||||
@@ -619,10 +924,18 @@ PY
|
||||
exit 1
|
||||
fi
|
||||
wait_for_host_nvme_addr "after-desired-path-change" "${NQN}" "${NEW_DESIRED_PATH}"
|
||||
wait_for_host_transport_live_path_count "after-desired-path-change" "${NQN}" "2"
|
||||
write_summary "reconnect_invoked=true"
|
||||
write_summary "new_desired_path_connected=true"
|
||||
if [[ -n "${REQUIRE_HOST_TRANSPORT}" ]]; then
|
||||
write_summary "desired_change_live_${REQUIRE_HOST_TRANSPORT}_path_count=2"
|
||||
write_summary "desired_change_tcp_fallback_observed=false"
|
||||
fi
|
||||
HOST_PATH_COUNT_AFTER_DESIRED_CHANGE="$(read_env_value "${ARTIFACT_DIR}/inject/nvme-path-info.after-desired-path-change.env" path_count)"
|
||||
HOST_PATHS_AFTER_DESIRED_CHANGE="$(read_env_value "${ARTIFACT_DIR}/inject/nvme-path-info.after-desired-path-change.env" addrs)"
|
||||
require_host_controller_live "${ARTIFACT_DIR}/inject/nvme-path-info.after-desired-path-change.env" \
|
||||
"${SURVIVING_CONTROLLER}" "${SURVIVING_DESIRED_PATH}" "${NVME_TRANSPORT}"
|
||||
write_summary "surviving_controller_during=${SURVIVING_CONTROLLER}"
|
||||
write_summary "host_path_count_after_desired_change=${HOST_PATH_COUNT_AFTER_DESIRED_CHANGE}"
|
||||
write_summary "host_paths_after_desired_change=${HOST_PATHS_AFTER_DESIRED_CHANGE}"
|
||||
if python3 - "${HOST_PATHS_AFTER_DESIRED_CHANGE}" "${OLD_DESIRED_PATH}" <<'PY'
|
||||
@@ -632,13 +945,18 @@ raise SystemExit(0 if sys.argv[2] in addrs else 1)
|
||||
PY
|
||||
then
|
||||
write_summary "stale_old_host_path_after_desired_change=true"
|
||||
STALE_OLD_PATH_DETECTED=true
|
||||
else
|
||||
write_summary "stale_old_host_path_after_desired_change=false"
|
||||
STALE_OLD_PATH_DETECTED=false
|
||||
fi
|
||||
|
||||
if [[ "${REQUIRE_STALE_PATH_PRUNE}" == "1" || "${REQUIRE_STALE_PATH_PRUNE}" == "true" ]]; then
|
||||
write_summary "stale_old_path_detected=true"
|
||||
write_summary "stale_old_path_detected=${STALE_OLD_PATH_DETECTED}"
|
||||
wait_for_host_nvme_addr_absent_count "after-stale-path-prune" "${NQN}" "${OLD_DESIRED_PATH}" "2"
|
||||
wait_for_host_transport_live_path_count "after-stale-path-prune" "${NQN}" "2"
|
||||
require_host_controller_live "${ARTIFACT_DIR}/inject/nvme-path-info.after-stale-path-prune.env" \
|
||||
"${SURVIVING_CONTROLLER}" "${SURVIVING_DESIRED_PATH}" "${NVME_TRANSPORT}"
|
||||
HOST_PATH_COUNT_AFTER_PRUNE="$(read_env_value "${ARTIFACT_DIR}/inject/nvme-path-info.after-stale-path-prune.env" path_count)"
|
||||
HOST_PATHS_AFTER_PRUNE="$(read_env_value "${ARTIFACT_DIR}/inject/nvme-path-info.after-stale-path-prune.env" addrs)"
|
||||
write_summary "stale_old_path_pruned=true"
|
||||
@@ -646,6 +964,15 @@ PY
|
||||
write_summary "host_paths_after_prune=${HOST_PATHS_AFTER_PRUNE}"
|
||||
fi
|
||||
|
||||
if [[ -n "${TRANSITION_IO_PID}" ]]; then
|
||||
kubectl -n "${APP_NAMESPACE}" exec "${MOUNTED_POD}" -- touch /tmp/phase166-stop
|
||||
wait "${TRANSITION_IO_PID}"
|
||||
TRANSITION_IO_PID=""
|
||||
[[ "$(wc -l <"${ARTIFACT_DIR}/inject/mounted-during-desired-path-change.log")" -ge 2 ]]
|
||||
write_summary "mounted_io_during_endpoint_change=ok"
|
||||
fi
|
||||
write_summary "surviving_controller_preserved=true"
|
||||
|
||||
if [[ "${MOUNTED_IO}" == "1" || "${MOUNTED_IO}" == "true" ]]; then
|
||||
MOUNTED_POD_UID_CHANGED="$(kubectl -n "${APP_NAMESPACE}" get pod "${MOUNTED_POD}" -o jsonpath='{.metadata.uid}')"
|
||||
if [[ "${MOUNTED_POD_UID_CHANGED}" != "${MOUNTED_POD_UID_BEFORE}" ]]; then
|
||||
@@ -663,6 +990,9 @@ PY
|
||||
--namespace "${APP_NAMESPACE}" \
|
||||
--out "${ARTIFACT_DIR}/surfaces/desired-change-report" \
|
||||
--timeout 30s >"${ARTIFACT_DIR}/surfaces/desired-change-report.stdout.txt" 2>"${ARTIFACT_DIR}/surfaces/desired-change-report.stderr.txt"
|
||||
"${ARTIFACT_DIR}/bin/sw-block" ops explain volume \
|
||||
--from-bundle "${ARTIFACT_DIR}/surfaces/desired-change-report" \
|
||||
"${VOLUME_ID}" >"${ARTIFACT_DIR}/surfaces/desired-change-explain.txt" 2>"${ARTIFACT_DIR}/surfaces/desired-change-explain.stderr.txt"
|
||||
DASHBOARD_PORT="$(python3 - <<'PY'
|
||||
import socket
|
||||
s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1]); s.close()
|
||||
@@ -682,6 +1012,7 @@ PY
|
||||
|
||||
python3 - "${ARTIFACT_DIR}" "${VOLUME_ID}" "${OLD_DESIRED_PATH}" "${NEW_DESIRED_PATH}" <<'PY'
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@@ -693,6 +1024,8 @@ nvme = status.get("nvme") or {}
|
||||
summary = (base/"surfaces/desired-change-report/summary.txt").read_text()
|
||||
snapshot = json.load(open(base/"surfaces/desired-change-report/operator-snapshot.json"))
|
||||
dashboard = json.load(open(base/"surfaces/desired-change-dashboard-operator-snapshot.json"))
|
||||
explain = (base/"surfaces/desired-change-explain.txt").read_text()
|
||||
required_transport = os.environ.get("SW_BLOCK_NVME_REQUIRE_HOST_TRANSPORT", "")
|
||||
|
||||
def assert_status(name, st):
|
||||
nv = st.get("nvme") or {}
|
||||
@@ -701,6 +1034,8 @@ def assert_status(name, st):
|
||||
raise SystemExit(f"{name} status mismatch: {st}")
|
||||
if nv.get("path_count") != 2 and nv.get("pathCount") != 2:
|
||||
raise SystemExit(f"{name} path count mismatch: {nv}")
|
||||
if required_transport and nv.get("transport") != required_transport:
|
||||
raise SystemExit(f"{name} transport mismatch: {nv}")
|
||||
if new_addr not in addrs or old_addr in addrs:
|
||||
raise SystemExit(f"{name} desired addrs mismatch: {addrs}")
|
||||
|
||||
@@ -708,6 +1043,8 @@ if status.get("status") != "ready" or status.get("reasonCode") != "first_volume_
|
||||
raise SystemExit(f"CRD status mismatch: {status}")
|
||||
if nvme.get("pathCount") != 2:
|
||||
raise SystemExit(f"CRD path count mismatch: {nvme}")
|
||||
if required_transport and nvme.get("transport") != required_transport:
|
||||
raise SystemExit(f"CRD transport mismatch: {nvme}")
|
||||
if new_addr not in (nvme.get("nvmeAddrs") or []) or old_addr in (nvme.get("nvmeAddrs") or []):
|
||||
raise SystemExit(f"CRD desired addrs mismatch: {nvme}")
|
||||
if f"managed_volume={volume_id} status=ready reason=first_volume_verified" not in summary:
|
||||
@@ -717,6 +1054,13 @@ if len(nvme_lines) != 1:
|
||||
raise SystemExit("report missing managed_volume_nvme line")
|
||||
if new_addr not in nvme_lines[0] or old_addr in nvme_lines[0] or "path_count=2" not in nvme_lines[0]:
|
||||
raise SystemExit("report did not reflect desired path replacement")
|
||||
if required_transport and f"transport={required_transport}" not in nvme_lines[0]:
|
||||
raise SystemExit("report did not retain the required NVMe transport")
|
||||
explain_nvme = next((line for line in explain.splitlines() if line.startswith("managed_volume_nvme ")), "")
|
||||
if new_addr not in explain_nvme or old_addr in explain_nvme or "path_count=2" not in explain_nvme:
|
||||
raise SystemExit(f"explain did not reflect desired path replacement: {explain_nvme}")
|
||||
if required_transport and f"transport={required_transport}" not in explain_nvme:
|
||||
raise SystemExit("explain did not retain the required NVMe transport")
|
||||
for name, doc in (("operator_snapshot", snapshot), ("dashboard", dashboard)):
|
||||
vols = doc.get("volumes") or []
|
||||
if len(vols) != 1:
|
||||
@@ -725,6 +1069,7 @@ for name, doc in (("operator_snapshot", snapshot), ("dashboard", dashboard)):
|
||||
(base/"nvme-k8s-desired-path-change-asserts.txt").write_text("\n".join([
|
||||
"crd_status_agrees=true",
|
||||
"report_dashboard_agree=true",
|
||||
"explain_agrees=true",
|
||||
"surface_ready_reason=first_volume_verified",
|
||||
]) + "\n")
|
||||
PY
|
||||
@@ -766,7 +1111,7 @@ if [[ "${HOST_PATH_DISCONNECT}" == "1" || "${HOST_PATH_DISCONNECT}" == "true" ]]
|
||||
echo "need exactly two host NVMe paths and a target controller, got count=${INITIAL_PATH_COUNT} controller=${TARGET_CONTROLLER}" >&2
|
||||
exit 1
|
||||
fi
|
||||
sudo -n nvme disconnect -d "${TARGET_CONTROLLER}" >"${ARTIFACT_DIR}/inject/nvme-disconnect-one-path.txt" 2>&1
|
||||
run_on_app_host sudo -n nvme disconnect -d "${TARGET_CONTROLLER}" >"${ARTIFACT_DIR}/inject/nvme-disconnect-one-path.txt" 2>&1
|
||||
wait_for_host_nvme_path_count "after-host-disconnect" "${NQN}" "1"
|
||||
write_summary "path_loss_detected=true"
|
||||
write_summary "after_disconnect_path_count=1"
|
||||
@@ -775,6 +1120,7 @@ if [[ "${HOST_PATH_DISCONNECT}" == "1" || "${HOST_PATH_DISCONNECT}" == "true" ]]
|
||||
exit 1
|
||||
fi
|
||||
wait_for_host_nvme_path_count "after-owner-reconnect" "${NQN}" "2"
|
||||
wait_for_host_transport_live_path_count "after-owner-reconnect" "${NQN}" "2"
|
||||
write_summary "reconnect_invoked=true"
|
||||
write_summary "replacement_path_connected=true"
|
||||
write_summary "reconnected_path_count=2"
|
||||
@@ -872,17 +1218,41 @@ fi
|
||||
|
||||
echo "[phase111] scale one blockvolume deployment to zero to remove one NVMe path"
|
||||
kubectl -n "${APP_NAMESPACE}" get deploy -l app=sw-blockvolume -o json >"${ARTIFACT_DIR}/inject/blockvolume-deployments.before.json"
|
||||
TARGET_DEPLOY="$(python3 - "${ARTIFACT_DIR}/inject/blockvolume-deployments.before.json" <<'PY'
|
||||
python3 - "${ARTIFACT_DIR}/inject/blockvolume-deployments.before.json" "${ARTIFACT_DIR}/surfaces/swblockvolumes.healthy.json" \
|
||||
>"${ARTIFACT_DIR}/inject/path-loss-target.env" <<'PY'
|
||||
import json, sys
|
||||
doc=json.load(open(sys.argv[1]))
|
||||
crd=json.load(open(sys.argv[2]))
|
||||
items=doc.get("items") or []
|
||||
if len(items) < 2:
|
||||
raise SystemExit(f"need at least two blockvolume deployments, got {len(items)}")
|
||||
items=sorted(items, key=lambda i: i["metadata"]["name"])
|
||||
print(items[0]["metadata"]["name"])
|
||||
volumes=crd.get("items") or []
|
||||
if len(volumes) != 1:
|
||||
raise SystemExit(f"need one SwBlockVolume, got {len(volumes)}")
|
||||
primary=(volumes[0].get("status") or {}).get("primaryReplicaID") or ""
|
||||
if not primary:
|
||||
raise SystemExit("missing primaryReplicaID")
|
||||
candidates=[]
|
||||
for item in items:
|
||||
meta=item.get("metadata") or {}
|
||||
replica=(meta.get("labels") or {}).get("sw-block.seaweedfs.com/replica") or ""
|
||||
if replica and replica != primary:
|
||||
candidates.append((replica, meta.get("name") or ""))
|
||||
if not candidates:
|
||||
raise SystemExit(f"no non-primary deployment found for primary {primary}")
|
||||
replica, name=sorted(candidates)[0]
|
||||
print(f"primary_replica={primary}")
|
||||
print(f"target_replica={replica}")
|
||||
print(f"target_deployment={name}")
|
||||
PY
|
||||
)"
|
||||
TARGET_DEPLOY="$(read_env_value "${ARTIFACT_DIR}/inject/path-loss-target.env" target_deployment)"
|
||||
PRIMARY_REPLICA="$(read_env_value "${ARTIFACT_DIR}/inject/path-loss-target.env" primary_replica)"
|
||||
TARGET_REPLICA="$(read_env_value "${ARTIFACT_DIR}/inject/path-loss-target.env" target_replica)"
|
||||
[[ -n "${TARGET_DEPLOY}" && -n "${PRIMARY_REPLICA}" && -n "${TARGET_REPLICA}" && "${TARGET_REPLICA}" != "${PRIMARY_REPLICA}" ]]
|
||||
write_summary "target_deployment=${TARGET_DEPLOY}"
|
||||
write_summary "primary_replica=${PRIMARY_REPLICA}"
|
||||
write_summary "outage_replica=${TARGET_REPLICA}"
|
||||
write_summary "outage_is_non_primary=true"
|
||||
kubectl -n "${APP_NAMESPACE}" scale "deploy/${TARGET_DEPLOY}" --replicas=0 >"${ARTIFACT_DIR}/inject/scale-target.txt"
|
||||
kubectl -n "${APP_NAMESPACE}" rollout status "deploy/${TARGET_DEPLOY}" --timeout=120s >"${ARTIFACT_DIR}/inject/rollout-target-zero.txt" 2>&1 || true
|
||||
for _ in $(seq 1 60); do
|
||||
@@ -893,6 +1263,7 @@ done
|
||||
kubectl -n "${APP_NAMESPACE}" get deploy,pod -l app=sw-blockvolume -o wide >"${ARTIFACT_DIR}/inject/blockvolume.after-scale.txt"
|
||||
|
||||
wait_for_crd_status "pathloss" "blocked" "nvme_multipath_path_missing" "1"
|
||||
wait_for_host_transport_live_path_count "pathloss" "${NQN}" "1" "true"
|
||||
VOLUME_ID="$(python3 - "${ARTIFACT_DIR}/surfaces/swblockvolumes.pathloss.json" <<'PY'
|
||||
import json, sys
|
||||
doc=json.load(open(sys.argv[1]))
|
||||
@@ -900,6 +1271,10 @@ print(doc["items"][0]["status"]["volumeID"])
|
||||
PY
|
||||
)"
|
||||
write_summary "volume_id=${VOLUME_ID}"
|
||||
if [[ -n "${REQUIRE_HOST_TRANSPORT}" ]]; then
|
||||
write_summary "degraded_live_${REQUIRE_HOST_TRANSPORT}_path_count=1"
|
||||
write_summary "degraded_tcp_fallback_observed=false"
|
||||
fi
|
||||
|
||||
if [[ "${MOUNTED_IO}" == "1" || "${MOUNTED_IO}" == "true" ]]; then
|
||||
echo "[phase111] verify mounted pod survives and writes after one path loss"
|
||||
@@ -944,7 +1319,7 @@ kill "${DASH_PID}" >/dev/null 2>&1 || true
|
||||
wait "${DASH_PID}" >/dev/null 2>&1 || true
|
||||
|
||||
SW_BLOCK_NVME_PATH_LOSS_PHASE_STATUS_KEY="${PHASE_STATUS_KEY}" python3 - "${ARTIFACT_DIR}" <<'PY'
|
||||
import json, re, sys
|
||||
import json, os, re, sys
|
||||
from pathlib import Path
|
||||
base=Path(sys.argv[1])
|
||||
crd=json.load(open(base/"surfaces/swblockvolumes.pathloss.json"))
|
||||
@@ -956,11 +1331,14 @@ summary=(base/"surfaces/report/summary.txt").read_text()
|
||||
snapshot=json.load(open(base/"surfaces/report/operator-snapshot.json"))
|
||||
dashboard=json.load(open(base/"surfaces/dashboard-operator-snapshot.json"))
|
||||
explain=(base/"surfaces/explain.txt").read_text()
|
||||
required_transport=os.environ.get("SW_BLOCK_NVME_REQUIRE_HOST_TRANSPORT", "")
|
||||
docs=[("report", snapshot), ("dashboard", dashboard)]
|
||||
if st.get("status") != "blocked" or st.get("reasonCode") != "nvme_multipath_path_missing":
|
||||
raise SystemExit(f"crd mismatch: {st}")
|
||||
if nv.get("pathCount") != 1:
|
||||
raise SystemExit(f"crd nvme path count mismatch: {nv}")
|
||||
if required_transport and nv.get("transport") != required_transport:
|
||||
raise SystemExit(f"crd nvme transport mismatch: {nv}")
|
||||
if any(c.get("type") == "Ready" and c.get("status") == "True" for c in st.get("conditions") or []):
|
||||
raise SystemExit("CRD contains Ready=True")
|
||||
if f"managed_volume={volume_id} status=blocked reason=nvme_multipath_path_missing" not in summary:
|
||||
@@ -969,6 +1347,8 @@ if "Ready=True" in summary:
|
||||
raise SystemExit("report summary contains Ready=True")
|
||||
if f"managed_volume_nvme={volume_id}" not in summary or "path_count=1" not in summary:
|
||||
raise SystemExit("report summary missing nvme path_count=1")
|
||||
if required_transport and f"transport={required_transport}" not in summary:
|
||||
raise SystemExit("report summary missing required NVMe transport")
|
||||
for name, doc in docs:
|
||||
vols=doc.get("volumes") or []
|
||||
if len(vols) != 1:
|
||||
@@ -979,6 +1359,8 @@ for name, doc in docs:
|
||||
raise SystemExit(f"{name} status mismatch: {s}")
|
||||
if n.get("path_count") != 1:
|
||||
raise SystemExit(f"{name} nvme mismatch: {n}")
|
||||
if required_transport and n.get("transport") != required_transport:
|
||||
raise SystemExit(f"{name} nvme transport mismatch: {n}")
|
||||
if any(c.get("type") == "Ready" and c.get("status") == "True" for c in s.get("conditions") or []):
|
||||
raise SystemExit(f"{name} contains Ready=True")
|
||||
if "status=blocked reason=nvme_multipath_path_missing" not in explain:
|
||||
@@ -1006,6 +1388,11 @@ if [[ "${RESTORE_PATH}" == "1" || "${RESTORE_PATH}" == "true" ]]; then
|
||||
kubectl -n "${APP_NAMESPACE}" rollout status "deploy/${TARGET_DEPLOY}" --timeout=240s >"${ARTIFACT_DIR}/inject/rollout-target-restore.txt" 2>&1
|
||||
|
||||
wait_for_crd_status "restored" "ready" "first_volume_verified" "2"
|
||||
wait_for_host_transport_live_path_count "restored" "${NQN}" "2"
|
||||
if [[ -n "${REQUIRE_HOST_TRANSPORT}" ]]; then
|
||||
write_summary "restored_live_${REQUIRE_HOST_TRANSPORT}_path_count=2"
|
||||
write_summary "restored_tcp_fallback_observed=false"
|
||||
fi
|
||||
if [[ "${MOUNTED_IO}" == "1" || "${MOUNTED_IO}" == "true" ]]; then
|
||||
MOUNTED_POD_UID_RESTORED="$(kubectl -n "${APP_NAMESPACE}" get pod "${MOUNTED_POD}" -o jsonpath='{.metadata.uid}')"
|
||||
if [[ "${MOUNTED_POD_UID_RESTORED}" != "${MOUNTED_POD_UID_BEFORE}" ]]; then
|
||||
@@ -1030,7 +1417,7 @@ if [[ "${RESTORE_PATH}" == "1" || "${RESTORE_PATH}" == "true" ]]; then
|
||||
"${VOLUME_ID}" >"${ARTIFACT_DIR}/surfaces/restore-explain.txt" 2>"${ARTIFACT_DIR}/surfaces/restore-explain.stderr.txt"
|
||||
|
||||
python3 - "${ARTIFACT_DIR}" "${VOLUME_ID}" <<'PY'
|
||||
import json, sys
|
||||
import json, os, sys
|
||||
from pathlib import Path
|
||||
base=Path(sys.argv[1])
|
||||
volume_id=sys.argv[2]
|
||||
@@ -1041,14 +1428,19 @@ nv=st.get("nvme") or {}
|
||||
summary=(base/"surfaces/restore-report/summary.txt").read_text()
|
||||
snapshot=json.load(open(base/"surfaces/restore-report/operator-snapshot.json"))
|
||||
explain=(base/"surfaces/restore-explain.txt").read_text()
|
||||
required_transport=os.environ.get("SW_BLOCK_NVME_REQUIRE_HOST_TRANSPORT", "")
|
||||
if st.get("status") != "ready" or st.get("reasonCode") != "first_volume_verified":
|
||||
raise SystemExit(f"restored CRD mismatch: {st}")
|
||||
if nv.get("pathCount") != 2:
|
||||
raise SystemExit(f"restored CRD path count mismatch: {nv}")
|
||||
if required_transport and nv.get("transport") != required_transport:
|
||||
raise SystemExit(f"restored CRD transport mismatch: {nv}")
|
||||
if f"managed_volume={volume_id} status=ready reason=first_volume_verified" not in summary:
|
||||
raise SystemExit("restore report summary missing ready/first_volume_verified")
|
||||
if f"managed_volume_nvme={volume_id}" not in summary or "path_count=2" not in summary:
|
||||
raise SystemExit("restore report missing nvme path_count=2")
|
||||
if required_transport and f"transport={required_transport}" not in summary:
|
||||
raise SystemExit("restore report missing required NVMe transport")
|
||||
vols=snapshot.get("volumes") or []
|
||||
if len(vols) != 1:
|
||||
raise SystemExit(f"restore snapshot volume count={len(vols)}")
|
||||
@@ -1058,6 +1450,8 @@ if s.get("status") != "ready" or s.get("reason_code") != "first_volume_verified"
|
||||
raise SystemExit(f"restore snapshot mismatch: {s}")
|
||||
if n.get("path_count") != 2:
|
||||
raise SystemExit(f"restore snapshot nvme mismatch: {n}")
|
||||
if required_transport and n.get("transport") != required_transport:
|
||||
raise SystemExit(f"restore snapshot transport mismatch: {n}")
|
||||
if "status=ready reason=first_volume_verified" not in explain:
|
||||
raise SystemExit("restore explain missing ready/first_volume_verified")
|
||||
(base/"nvme-k8s-path-restore-asserts.txt").write_text("\n".join([
|
||||
|
||||
@@ -99,10 +99,21 @@ if kubectl get pods,pvc,pv -A -o name 2>/dev/null | grep -Eq '(sw-block|seaweed-
|
||||
echo "existing Seaweed Block Kubernetes resources; refusing unscoped cleanup" >&2
|
||||
exit 1
|
||||
fi
|
||||
if kubectl get volumeattachments.storage.k8s.io \
|
||||
-o custom-columns=ATTACHER:.spec.attacher --no-headers 2>/dev/null \
|
||||
| grep -q '^block\.csi\.seaweedfs\.com$'; then
|
||||
echo "existing Seaweed Block VolumeAttachment; refusing contaminated lab" >&2
|
||||
exit 1
|
||||
fi
|
||||
if app_ssh "sudo nvme list-subsys -o json 2>/dev/null" | grep -q 'nqn.2026-05.io.seaweedfs'; then
|
||||
echo "existing Seaweed Block NVMe controller on app host; refusing unscoped cleanup" >&2
|
||||
exit 1
|
||||
fi
|
||||
if sudo find /sys/kernel/config/nvmet/subsystems -mindepth 1 -maxdepth 1 -type d \
|
||||
-name '*io.seaweedfs*' -print -quit 2>/dev/null | grep -q .; then
|
||||
echo "existing Seaweed Block NVMe target; refusing contaminated lab" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kubectl get node "${TARGET_NODE}" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' | grep -q '^True$'
|
||||
kubectl get node "${APP_NODE}" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' | grep -q '^True$'
|
||||
@@ -112,6 +123,10 @@ app_ssh "ip -4 -o addr show | grep -q ' ${APP_RDMA_IP}/'; rdma link show | grep
|
||||
sudo modprobe nvmet-rdma
|
||||
sudo modprobe nbd
|
||||
NBD_BASELINE="$(active_nbd_count)"
|
||||
if [[ "${NBD_BASELINE}" != 0 ]]; then
|
||||
echo "existing active NBD device; refusing contaminated lab" >&2
|
||||
exit 1
|
||||
fi
|
||||
write_summary "rdma_host_preflight=ok"
|
||||
write_summary "nbd_baseline=${NBD_BASELINE}"
|
||||
|
||||
@@ -269,6 +284,26 @@ write_summary "tcp_fallback_observed=false"
|
||||
|
||||
kubectl -n "${APP_NAMESPACE}" delete pod phase165-rdma-hold sw-block-example-reader sw-block-example-writer \
|
||||
--ignore-not-found=true --wait=true --timeout=120s
|
||||
detached_samples=0
|
||||
for _ in $(seq 1 120); do
|
||||
attachment_count="$(kubectl get volumeattachments.storage.k8s.io \
|
||||
-o custom-columns=PV:.spec.source.persistentVolumeName --no-headers 2>/dev/null \
|
||||
| awk -v volume="${VOLUME_ID}" '$1 == volume {count++} END {print count + 0}')"
|
||||
if [[ "${attachment_count}" == 0 ]]; then
|
||||
detached_samples=$((detached_samples + 1))
|
||||
[[ "${detached_samples}" == 3 ]] && break
|
||||
else
|
||||
detached_samples=0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
if [[ "${detached_samples}" != 3 ]]; then
|
||||
kubectl get volumeattachments.storage.k8s.io -o yaml \
|
||||
>"${ARTIFACT_DIR}/cleanup/volumeattachments-detach-timeout.yaml" 2>&1 || true
|
||||
echo "VolumeAttachment for ${VOLUME_ID} did not detach before PVC deletion" >&2
|
||||
exit 1
|
||||
fi
|
||||
write_summary "volume_detached_before_pvc_delete=true"
|
||||
kubectl -n "${APP_NAMESPACE}" delete pvc "${APP_PVC}" --wait=true --timeout=180s
|
||||
kubectl delete storageclass sw-block-example --ignore-not-found=true --wait=true --timeout=60s
|
||||
for _ in $(seq 1 60); do
|
||||
@@ -276,6 +311,19 @@ for _ in $(seq 1 60); do
|
||||
sleep 2
|
||||
done
|
||||
if kubectl get pv "${VOLUME_ID}" >/dev/null 2>&1; then
|
||||
kubectl get pv "${VOLUME_ID}" -o yaml >"${ARTIFACT_DIR}/cleanup/pv-stuck.yaml" 2>&1 || true
|
||||
kubectl get volumeattachments.storage.k8s.io -o yaml \
|
||||
>"${ARTIFACT_DIR}/cleanup/volumeattachments-stuck.yaml" 2>&1 || true
|
||||
kubectl -n "${APP_NAMESPACE}" get events --sort-by=.lastTimestamp \
|
||||
>"${ARTIFACT_DIR}/cleanup/events-stuck.txt" 2>&1 || true
|
||||
controller_pod="$(kubectl -n "${HELM_NAMESPACE}" get pod -l app=sw-block-csi-controller \
|
||||
-o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
|
||||
if [[ -n "${controller_pod}" ]]; then
|
||||
for container in block-csi csi-attacher csi-provisioner; do
|
||||
kubectl -n "${HELM_NAMESPACE}" logs "${controller_pod}" -c "${container}" --since=15m \
|
||||
>"${ARTIFACT_DIR}/cleanup/${container}-stuck.log" 2>&1 || true
|
||||
done
|
||||
fi
|
||||
echo "PV ${VOLUME_ID} still exists before Helm uninstall" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${1:-$(pwd)}"
|
||||
RUN_ID="${SW_BLOCK_PHASE166_RUN_ID:-$(date -u +%Y%m%dT%H%M%SZ)}"
|
||||
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${ROOT}/results/phase166-nvme-rdma-k8s-multipath-reconnect}"
|
||||
SUMMARY="${ARTIFACT_DIR}/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
APP_NODE="${SW_BLOCK_PHASE166_APP_NODE:-}"
|
||||
APP_SSH_ADDR="${SW_BLOCK_PHASE166_APP_SSH_ADDR:-}"
|
||||
APP_SSH_USER="${SW_BLOCK_PHASE166_APP_SSH_USER:-testdev}"
|
||||
APP_SSH_KEY="${SW_BLOCK_PHASE166_APP_SSH_KEY:-/opt/work/testdev_key}"
|
||||
TARGET_REMOTE_SSH_ADDR="${SW_BLOCK_PHASE166_TARGET_REMOTE_SSH_ADDR:-192.168.1.181}"
|
||||
TARGET_REMOTE_SSH_USER="${SW_BLOCK_PHASE166_TARGET_REMOTE_SSH_USER:-testdev}"
|
||||
TARGET_REMOTE_SSH_KEY="${SW_BLOCK_PHASE166_TARGET_REMOTE_SSH_KEY:-${APP_SSH_KEY}}"
|
||||
FRONTEND_IP_MAP="${SW_BLOCK_PHASE166_FRONTEND_IP_MAP:-m01=10.0.0.1,m02=10.0.0.3}"
|
||||
OUTAGE_STATE_HOSTPATH="/var/lib/sw-block/testops-${RUN_ID}-phase166-outage"
|
||||
ENDPOINT_STATE_HOSTPATH="/var/lib/sw-block/testops-${RUN_ID}-phase166-endpoint"
|
||||
|
||||
mkdir -p "${ARTIFACT_DIR}"/{build,local,outage,endpoint-change}
|
||||
: >"${SUMMARY}"
|
||||
|
||||
write_summary() {
|
||||
echo "$*" | tee -a "${SUMMARY}" >/dev/null
|
||||
}
|
||||
|
||||
require_line() {
|
||||
local file="$1"
|
||||
local line="$2"
|
||||
grep -Fqx "${line}" "${file}"
|
||||
}
|
||||
|
||||
cleanup_phase166_hostpaths() {
|
||||
local root
|
||||
for root in "${OUTAGE_STATE_HOSTPATH}" "${ENDPOINT_STATE_HOSTPATH}"; do
|
||||
case "${root}" in
|
||||
/var/lib/sw-block/testops-*phase166-*) ;;
|
||||
*) echo "refusing unsafe Phase 166 hostPath cleanup ${root}" >&2; return 1 ;;
|
||||
esac
|
||||
sudo -n rm -rf -- "${root}"
|
||||
ssh -i "${TARGET_REMOTE_SSH_KEY}" -o BatchMode=yes -o ConnectTimeout=10 \
|
||||
"${TARGET_REMOTE_SSH_USER}@${TARGET_REMOTE_SSH_ADDR}" "sudo rm -rf -- '${root}'"
|
||||
done
|
||||
}
|
||||
|
||||
verify_phase166_hostpaths_removed() {
|
||||
local root
|
||||
for root in "${OUTAGE_STATE_HOSTPATH}" "${ENDPOINT_STATE_HOSTPATH}"; do
|
||||
sudo -n test ! -e "${root}"
|
||||
ssh -i "${TARGET_REMOTE_SSH_KEY}" -o BatchMode=yes -o ConnectTimeout=10 \
|
||||
"${TARGET_REMOTE_SSH_USER}@${TARGET_REMOTE_SSH_ADDR}" "sudo test ! -e '${root}'"
|
||||
done
|
||||
}
|
||||
|
||||
require_disjoint_rdma_initiator() {
|
||||
[[ -n "${APP_NODE}" ]] || {
|
||||
echo "SW_BLOCK_PHASE166_APP_NODE must name a third RoCE-capable Kubernetes initiator" >&2
|
||||
return 1
|
||||
}
|
||||
[[ -n "${APP_SSH_ADDR}" ]] || {
|
||||
echo "SW_BLOCK_PHASE166_APP_SSH_ADDR must reach the third RoCE initiator" >&2
|
||||
return 1
|
||||
}
|
||||
local target_node
|
||||
IFS=',' read -r -a frontend_entries <<<"${FRONTEND_IP_MAP}"
|
||||
for target_node in "${frontend_entries[@]}"; do
|
||||
target_node="${target_node%%=*}"
|
||||
if [[ "${APP_NODE}" == "${target_node}" ]]; then
|
||||
echo "Phase 166 initiator ${APP_NODE} must be disjoint from RDMA target ${target_node}" >&2
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
kubectl get node "${APP_NODE}" -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' | grep -q '^True$'
|
||||
ssh -i "${APP_SSH_KEY}" -o BatchMode=yes -o ConnectTimeout=10 \
|
||||
"${APP_SSH_USER}@${APP_SSH_ADDR}" \
|
||||
"ip -4 -o addr show | grep -q '/'; rdma link show | grep -q .; sudo -n nvme list-subsys -o json >/dev/null"
|
||||
}
|
||||
|
||||
require_clean_shared_lab() {
|
||||
local residue
|
||||
residue="$({
|
||||
helm status sw-block --namespace kube-system 2>/dev/null && echo "helm/sw-block"
|
||||
kubectl get deploy,daemonset,statefulset,pod,svc,pvc,pv,configmap,secret,serviceaccount -A -o name 2>/dev/null \
|
||||
| grep -E '(sw-block|seaweed-block|block\.csi\.seaweedfs\.com)' || true
|
||||
kubectl get storageclass,csidriver,clusterrole,clusterrolebinding -o name 2>/dev/null \
|
||||
| grep -E '(sw-block|seaweed-block|block\.csi\.seaweedfs\.com)' || true
|
||||
kubectl get volumeattachments.storage.k8s.io \
|
||||
-o custom-columns=NAME:.metadata.name,ATTACHER:.spec.attacher,PV:.spec.source.persistentVolumeName --no-headers 2>/dev/null \
|
||||
| grep 'block\.csi\.seaweedfs\.com' || true
|
||||
kubectl get validatingadmissionpolicy,validatingadmissionpolicybinding -o name 2>/dev/null \
|
||||
| grep -E '(sw-block|seaweed-block|block\.seaweedfs\.com)' || true
|
||||
kubectl get swblockclusters.block.seaweedfs.com,swblockvolumes.block.seaweedfs.com -A -o name 2>/dev/null || true
|
||||
sudo find /sys/kernel/config/nvmet/subsystems -mindepth 1 -maxdepth 1 -type d \
|
||||
-name '*io.seaweedfs*' -printf 'nvmet/%f\n' 2>/dev/null || true
|
||||
for pid_file in /sys/block/nbd*/pid; do
|
||||
[[ -s "${pid_file}" ]] && printf 'active-nbd/%s\n' "$(basename "$(dirname "${pid_file}")")"
|
||||
done
|
||||
} | awk 'NF')"
|
||||
if [[ -n "${residue}" ]]; then
|
||||
printf 'refusing to replace images on a non-clean shared lab:\n%s\n' "${residue}" >&2
|
||||
return 1
|
||||
fi
|
||||
ssh -i "${TARGET_REMOTE_SSH_KEY}" -o BatchMode=yes -o ConnectTimeout=10 \
|
||||
"${TARGET_REMOTE_SSH_USER}@${TARGET_REMOTE_SSH_ADDR}" \
|
||||
"test -z \"\$(sudo find /sys/kernel/config/nvmet/subsystems -mindepth 1 -maxdepth 1 -type d -name '*io.seaweedfs*' -print -quit 2>/dev/null)\"; ! grep -qs . /sys/block/nbd*/pid"
|
||||
ssh -i "${APP_SSH_KEY}" -o BatchMode=yes -o ConnectTimeout=10 \
|
||||
"${APP_SSH_USER}@${APP_SSH_ADDR}" \
|
||||
"! sudo -n nvme list-subsys -o json 2>/dev/null | grep -q 'nqn.*io.seaweedfs'"
|
||||
}
|
||||
|
||||
trap cleanup_phase166_hostpaths EXIT
|
||||
|
||||
require_disjoint_rdma_initiator
|
||||
require_clean_shared_lab
|
||||
|
||||
write_summary "phase166_nvme_rdma_k8s_multipath_reconnect_status=running"
|
||||
|
||||
(
|
||||
cd "${ROOT}"
|
||||
go test ./core/csi ./cmd/blockcsi -count=1
|
||||
) >"${ARTIFACT_DIR}/local/go-test-csi.txt" 2>&1
|
||||
write_summary "source_contract_tests=ok"
|
||||
|
||||
(
|
||||
cd "${ROOT}"
|
||||
SW_BLOCK_ARTIFACT_DIR="${ARTIFACT_DIR}/build" \
|
||||
SW_BLOCK_IMPORT_K3S=1 \
|
||||
SW_BLOCK_IMPORT_K3S_NODES="${TARGET_REMOTE_SSH_ADDR},${APP_SSH_ADDR}" \
|
||||
SW_BLOCK_IMPORT_K3S_SSH_USER="${APP_SSH_USER}" \
|
||||
SW_BLOCK_IMPORT_K3S_SSH_KEY="${APP_SSH_KEY}" \
|
||||
bash scripts/build-alpha-images.sh "${ROOT}"
|
||||
) >"${ARTIFACT_DIR}/build/build.log" 2>&1
|
||||
require_line "${ARTIFACT_DIR}/build/alpha-images.env" "SW_BLOCK_IMAGE=sw-block:local"
|
||||
require_line "${ARTIFACT_DIR}/build/alpha-images.env" "SW_BLOCK_CSI_IMAGE=sw-block-csi:local"
|
||||
write_summary "fresh_matching_images=ok"
|
||||
|
||||
export SW_BLOCK_NVME_TRANSPORT=rdma
|
||||
export SW_BLOCK_NVME_FRONTEND_IP_MAP="${FRONTEND_IP_MAP}"
|
||||
export SW_BLOCK_NVME_FRONTEND_NETWORK_CLASS=100gbe_roce
|
||||
export SW_BLOCK_NVME_RESTART_PERSISTENCE=hostpath
|
||||
export SW_BLOCK_NVME_CLEANUP_STATE_HOSTPATH=1
|
||||
export SW_BLOCK_NVME_REQUIRE_HOST_TRANSPORT=rdma
|
||||
export SW_BLOCK_NVME_STRICT_CLEANUP_SCOPE=1
|
||||
export SW_BLOCK_NVME_APP_NODE_SELECTOR="${APP_NODE}"
|
||||
export SW_BLOCK_NVME_APP_HOST_SSH_ADDR="${APP_SSH_ADDR}"
|
||||
export SW_BLOCK_NVME_APP_HOST_SSH_USER="${APP_SSH_USER}"
|
||||
export SW_BLOCK_NVME_APP_HOST_SSH_KEY="${APP_SSH_KEY}"
|
||||
export SW_BLOCK_NVME_MOUNTED_IO=1
|
||||
export SW_BLOCK_NVME_RECONNECT_OWNER=1
|
||||
export SW_BLOCK_NVME_RECONNECT_INTERVAL=1s
|
||||
export SW_BLOCK_NVME_FORCE_STAGE2_MULTIPATH=1
|
||||
|
||||
OUTAGE_SUMMARY="${ARTIFACT_DIR}/outage/phase166-rdma-multipath-outage-summary.txt"
|
||||
SW_BLOCK_ARTIFACT_DIR="${ARTIFACT_DIR}/outage" \
|
||||
SW_BLOCK_NVME_PATH_LOSS_SUMMARY_NAME="$(basename "${OUTAGE_SUMMARY}")" \
|
||||
SW_BLOCK_NVME_PATH_LOSS_PHASE_STATUS_KEY=phase166_rdma_multipath_outage_status \
|
||||
SW_BLOCK_NVME_MOUNTED_POD=sw-block-phase166-rdma-outage \
|
||||
SW_BLOCK_NVME_RESTORE_PATH=1 \
|
||||
SW_BLOCK_NVME_HOST_PATH_DISCONNECT=0 \
|
||||
SW_BLOCK_NVME_DESIRED_PATH_CHANGE=0 \
|
||||
SW_BLOCK_NVME_STATE_HOSTPATH="${OUTAGE_STATE_HOSTPATH}" \
|
||||
SW_BLOCK_MASTER_PORT_FORWARD_PORT=29661 \
|
||||
bash "${ROOT}/scripts/run-phase111-nvme-k8s-path-loss-crd-gate.sh" "${ROOT}"
|
||||
|
||||
require_line "${OUTAGE_SUMMARY}" "phase166_rdma_multipath_outage_status=ok"
|
||||
require_line "${OUTAGE_SUMMARY}" "initial_live_rdma_path_count=2"
|
||||
require_line "${OUTAGE_SUMMARY}" "degraded_live_rdma_path_count=1"
|
||||
require_line "${OUTAGE_SUMMARY}" "outage_is_non_primary=true"
|
||||
require_line "${OUTAGE_SUMMARY}" "mounted_pod_uid_preserved=true"
|
||||
require_line "${OUTAGE_SUMMARY}" "mounted_io_after_path_loss=ok"
|
||||
require_line "${OUTAGE_SUMMARY}" "restored_live_rdma_path_count=2"
|
||||
require_line "${OUTAGE_SUMMARY}" "mounted_pod_uid_preserved_after_restore=true"
|
||||
require_line "${OUTAGE_SUMMARY}" "mounted_io_after_restore=ok"
|
||||
require_line "${OUTAGE_SUMMARY}" "crd_reason=nvme_multipath_path_missing"
|
||||
require_line "${OUTAGE_SUMMARY}" "cleanup_status=ok"
|
||||
cleanup_phase166_hostpaths
|
||||
verify_phase166_hostpaths_removed
|
||||
require_clean_shared_lab
|
||||
write_summary "outage_initial_live_rdma_path_count=2"
|
||||
write_summary "outage_degraded_live_rdma_path_count=1"
|
||||
write_summary "outage_mounted_io=ok"
|
||||
write_summary "outage_pod_uid_preserved=true"
|
||||
write_summary "outage_is_non_primary=true"
|
||||
write_summary "outage_negative_surface_reason=nvme_multipath_path_missing"
|
||||
write_summary "outage_restored_live_rdma_path_count=2"
|
||||
write_summary "outage_restore_mounted_io=ok"
|
||||
write_summary "outage_tcp_fallback_observed=false"
|
||||
write_summary "outage_cleanup_status=ok"
|
||||
|
||||
ENDPOINT_SUMMARY="${ARTIFACT_DIR}/endpoint-change/phase166-rdma-endpoint-change-summary.txt"
|
||||
SW_BLOCK_ARTIFACT_DIR="${ARTIFACT_DIR}/endpoint-change" \
|
||||
SW_BLOCK_NVME_PATH_LOSS_SUMMARY_NAME="$(basename "${ENDPOINT_SUMMARY}")" \
|
||||
SW_BLOCK_NVME_PATH_LOSS_PHASE_STATUS_KEY=phase166_rdma_endpoint_change_status \
|
||||
SW_BLOCK_NVME_MOUNTED_POD=sw-block-phase166-rdma-endpoint \
|
||||
SW_BLOCK_NVME_RESTORE_PATH=0 \
|
||||
SW_BLOCK_NVME_HOST_PATH_DISCONNECT=0 \
|
||||
SW_BLOCK_NVME_DESIRED_PATH_CHANGE=1 \
|
||||
SW_BLOCK_NVME_REQUIRE_STALE_PATH_PRUNE=1 \
|
||||
SW_BLOCK_NVME_STATE_HOSTPATH="${ENDPOINT_STATE_HOSTPATH}" \
|
||||
SW_BLOCK_MASTER_PORT_FORWARD_PORT=29662 \
|
||||
bash "${ROOT}/scripts/run-phase111-nvme-k8s-path-loss-crd-gate.sh" "${ROOT}"
|
||||
|
||||
require_line "${ENDPOINT_SUMMARY}" "phase166_rdma_endpoint_change_status=ok"
|
||||
require_line "${ENDPOINT_SUMMARY}" "initial_live_rdma_path_count=2"
|
||||
require_line "${ENDPOINT_SUMMARY}" "desired_path_set_changed=true"
|
||||
require_line "${ENDPOINT_SUMMARY}" "endpoint_change_is_non_primary=true"
|
||||
require_line "${ENDPOINT_SUMMARY}" "new_desired_path_connected=true"
|
||||
require_line "${ENDPOINT_SUMMARY}" "desired_change_live_rdma_path_count=2"
|
||||
require_line "${ENDPOINT_SUMMARY}" "stale_old_path_pruned=true"
|
||||
require_line "${ENDPOINT_SUMMARY}" "pod_uid_preserved=true"
|
||||
require_line "${ENDPOINT_SUMMARY}" "mounted_io_during_endpoint_change=ok"
|
||||
require_line "${ENDPOINT_SUMMARY}" "mounted_io_after_reconnect=ok"
|
||||
require_line "${ENDPOINT_SUMMARY}" "surviving_controller_preserved=true"
|
||||
require_line "${ENDPOINT_SUMMARY}" "crd_status_agrees=true"
|
||||
require_line "${ENDPOINT_SUMMARY}" "report_dashboard_agree=true"
|
||||
require_line "${ENDPOINT_SUMMARY}" "explain_agrees=true"
|
||||
require_line "${ENDPOINT_SUMMARY}" "cleanup_status=ok"
|
||||
cleanup_phase166_hostpaths
|
||||
verify_phase166_hostpaths_removed
|
||||
require_clean_shared_lab
|
||||
write_summary "endpoint_initial_live_rdma_path_count=2"
|
||||
write_summary "desired_rdma_endpoint_changed=true"
|
||||
write_summary "new_rdma_endpoint_connected=true"
|
||||
write_summary "stale_rdma_endpoint_pruned=true"
|
||||
write_summary "endpoint_live_rdma_path_count=2"
|
||||
write_summary "endpoint_pod_uid_preserved=true"
|
||||
write_summary "endpoint_change_is_non_primary=true"
|
||||
write_summary "endpoint_surviving_controller_preserved=true"
|
||||
write_summary "endpoint_transition_io=ok"
|
||||
write_summary "endpoint_mounted_io=ok"
|
||||
write_summary "endpoint_surfaces_agree=true"
|
||||
write_summary "endpoint_tcp_fallback_observed=false"
|
||||
write_summary "endpoint_cleanup_status=ok"
|
||||
write_summary "hostpath_cleanup_nodes=m01,m02"
|
||||
|
||||
write_summary "cleanup_status=ok"
|
||||
write_summary "phase166_nvme_rdma_k8s_multipath_reconnect_status=ok"
|
||||
cat "${SUMMARY}"
|
||||
@@ -134,6 +134,7 @@ func TestVerifyHelmCleanupReportsAllResidueDimensions(t *testing.T) {
|
||||
"cleanup_status=ok",
|
||||
"cleanup_status=failed",
|
||||
"k8s_residue_count=",
|
||||
"nvme_target_residue_count=",
|
||||
"iscsi_residue_count=",
|
||||
"process_residue_count=",
|
||||
"multipath_residue_count=",
|
||||
@@ -141,6 +142,8 @@ func TestVerifyHelmCleanupReportsAllResidueDimensions(t *testing.T) {
|
||||
"failure_count=",
|
||||
"helm_release_still_present",
|
||||
"kubernetes_sw_block_resources_present",
|
||||
"volumeattachments.storage.k8s.io",
|
||||
"nvme_target_subsystems_present",
|
||||
"iscsi_sessions_present",
|
||||
"iscsi_node_records_present",
|
||||
"multipath_maps_present",
|
||||
@@ -278,6 +281,44 @@ func TestPhase106NVMETCPCrossNodePublishGateIsClaimBounded(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPhase166NVMERDMAGateRequiresDisjointInitiator(t *testing.T) {
|
||||
root := repoRoot(t)
|
||||
phase166Raw, err := os.ReadFile(filepath.Join(root, "scripts", "run-phase166-nvme-rdma-k8s-multipath-reconnect-gate.sh"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
phase166 := string(phase166Raw)
|
||||
for _, want := range []string{
|
||||
"require_disjoint_rdma_initiator",
|
||||
"SW_BLOCK_PHASE166_APP_NODE must name a third RoCE-capable Kubernetes initiator",
|
||||
"must be disjoint from RDMA target",
|
||||
`SW_BLOCK_NVME_APP_NODE_SELECTOR="${APP_NODE}"`,
|
||||
`SW_BLOCK_NVME_APP_HOST_SSH_ADDR="${APP_SSH_ADDR}"`,
|
||||
`SW_BLOCK_IMPORT_K3S_NODES="${TARGET_REMOTE_SSH_ADDR},${APP_SSH_ADDR}"`,
|
||||
} {
|
||||
if !strings.Contains(phase166, want) {
|
||||
t.Fatalf("phase166 gate missing %q", want)
|
||||
}
|
||||
}
|
||||
|
||||
phase111Raw, err := os.ReadFile(filepath.Join(root, "scripts", "run-phase111-nvme-k8s-path-loss-crd-gate.sh"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
phase111 := string(phase111Raw)
|
||||
for _, want := range []string{
|
||||
"APP_NODE_OVERRIDE=",
|
||||
"APP_HOST_SSH_ADDR=",
|
||||
"run_on_app_host sudo -n nvme list-subsys",
|
||||
"run_on_app_host sudo -n nvme disconnect",
|
||||
`APP_NODE="${APP_NODE_OVERRIDE:-`,
|
||||
} {
|
||||
if !strings.Contains(phase111, want) {
|
||||
t.Fatalf("phase111 gate missing remote initiator support %q", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func repoRoot(t *testing.T) string {
|
||||
t.Helper()
|
||||
dir, err := os.Getwd()
|
||||
|
||||
@@ -71,6 +71,8 @@ wait_for_k8s_cleanup() {
|
||||
{
|
||||
kubectl get deploy,daemonset,statefulset,pod,svc,pvc,pv,configmap,secret,serviceaccount -A -o name
|
||||
kubectl get storageclass,csidriver,clusterrole,clusterrolebinding -o name
|
||||
kubectl get volumeattachments.storage.k8s.io \
|
||||
-o custom-columns=NAME:.metadata.name,ATTACHER:.spec.attacher,PV:.spec.source.persistentVolumeName --no-headers
|
||||
} 2>/dev/null | grep -E '(sw-block|seaweed-block|block\.csi\.seaweedfs\.com)' || true
|
||||
)"
|
||||
if [[ -z "$residue" ]]; then
|
||||
@@ -95,6 +97,8 @@ fi
|
||||
capture "k8s-resources.after-cleanup.txt" bash -c '
|
||||
kubectl get deploy,daemonset,statefulset,pod,svc,pvc,pv,configmap,secret,serviceaccount -A -o name
|
||||
kubectl get storageclass,csidriver,clusterrole,clusterrolebinding -o name
|
||||
kubectl get volumeattachments.storage.k8s.io \
|
||||
-o custom-columns=NAME:.metadata.name,ATTACHER:.spec.attacher,PV:.spec.source.persistentVolumeName --no-headers
|
||||
'
|
||||
if grep -E '(sw-block|seaweed-block|block\.csi\.seaweedfs\.com)' "$ARTIFACT_DIR/k8s-resources.after-cleanup.txt" >"$ARTIFACT_DIR/k8s-residue.after-cleanup.txt"; then
|
||||
mark_fail "kubernetes_sw_block_resources_present"
|
||||
@@ -102,6 +106,21 @@ else
|
||||
: >"$ARTIFACT_DIR/k8s-residue.after-cleanup.txt"
|
||||
fi
|
||||
|
||||
if [[ -d /sys/kernel/config/nvmet/subsystems ]]; then
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
sudo -n find /sys/kernel/config/nvmet/subsystems -mindepth 1 -maxdepth 1 -type d \
|
||||
-name '*io.seaweedfs*' -printf '%f\n' >"$ARTIFACT_DIR/nvme-target-residue.after-cleanup.txt" 2>/dev/null || true
|
||||
else
|
||||
find /sys/kernel/config/nvmet/subsystems -mindepth 1 -maxdepth 1 -type d \
|
||||
-name '*io.seaweedfs*' -printf '%f\n' >"$ARTIFACT_DIR/nvme-target-residue.after-cleanup.txt" 2>/dev/null || true
|
||||
fi
|
||||
else
|
||||
: >"$ARTIFACT_DIR/nvme-target-residue.after-cleanup.txt"
|
||||
fi
|
||||
if [[ -s "$ARTIFACT_DIR/nvme-target-residue.after-cleanup.txt" ]]; then
|
||||
mark_fail "nvme_target_subsystems_present"
|
||||
fi
|
||||
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
capture "iscsi-sessions.after-cleanup.txt" sudo -n iscsiadm -m session
|
||||
capture "iscsi-nodes.after-cleanup.txt" sudo -n iscsiadm -m node
|
||||
@@ -229,6 +248,7 @@ fi
|
||||
echo "helm_namespace=$HELM_NAMESPACE"
|
||||
echo "iqn_substr=$IQN_SUBSTR"
|
||||
echo "k8s_residue_count=$(wc -l <"$ARTIFACT_DIR/k8s-residue.after-cleanup.txt")"
|
||||
echo "nvme_target_residue_count=$(wc -l <"$ARTIFACT_DIR/nvme-target-residue.after-cleanup.txt")"
|
||||
echo "iscsi_residue_count=$ISCSI_RESIDUE_COUNT"
|
||||
echo "process_residue_count=$(wc -l <"$ARTIFACT_DIR/process-residue.after-cleanup.txt")"
|
||||
echo "multipath_residue_count=$(wc -l <"$ARTIFACT_DIR/multipath-residue.after-cleanup.txt")"
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
name: nvme-rdma-k8s-multipath-reconnect-chain
|
||||
timeout: 130m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
app_node: ""
|
||||
app_ssh_addr: ""
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: run_close_gate
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 125m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-phase166-nvme-rdma-k8s-multipath-reconnect-gate.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath"
|
||||
env.SW_BLOCK_PHASE166_RUN_ID: "{{ run_id }}"
|
||||
env.SW_BLOCK_PHASE166_APP_NODE: "{{ app_node }}"
|
||||
env.SW_BLOCK_PHASE166_APP_SSH_ADDR: "{{ app_ssh_addr }}"
|
||||
env.SW_BLOCK_PHASE166_APP_SSH_KEY: "/opt/work/testdev_key"
|
||||
|
||||
- name: assert_terminal_evidence
|
||||
actions:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^phase166_nvme_rdma_k8s_multipath_reconnect_status=ok$"
|
||||
save_as: gate_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ gate_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^outage_initial_live_rdma_path_count=2$"
|
||||
save_as: outage_baseline
|
||||
- action: assert_greater
|
||||
actual: "{{ outage_baseline }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^outage_degraded_live_rdma_path_count=1$"
|
||||
save_as: outage_degraded
|
||||
- action: assert_greater
|
||||
actual: "{{ outage_degraded }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^outage_mounted_io=ok$"
|
||||
save_as: outage_io
|
||||
- action: assert_greater
|
||||
actual: "{{ outage_io }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^outage_negative_surface_reason=nvme_multipath_path_missing$"
|
||||
save_as: outage_negative
|
||||
- action: assert_greater
|
||||
actual: "{{ outage_negative }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^outage_restored_live_rdma_path_count=2$"
|
||||
save_as: outage_restored
|
||||
- action: assert_greater
|
||||
actual: "{{ outage_restored }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^outage_restore_mounted_io=ok$"
|
||||
save_as: restore_io
|
||||
- action: assert_greater
|
||||
actual: "{{ restore_io }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^desired_rdma_endpoint_changed=true$"
|
||||
save_as: endpoint_changed
|
||||
- action: assert_greater
|
||||
actual: "{{ endpoint_changed }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^new_rdma_endpoint_connected=true$"
|
||||
save_as: endpoint_connected
|
||||
- action: assert_greater
|
||||
actual: "{{ endpoint_connected }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^stale_rdma_endpoint_pruned=true$"
|
||||
save_as: stale_pruned
|
||||
- action: assert_greater
|
||||
actual: "{{ stale_pruned }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^endpoint_live_rdma_path_count=2$"
|
||||
save_as: endpoint_paths
|
||||
- action: assert_greater
|
||||
actual: "{{ endpoint_paths }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^endpoint_pod_uid_preserved=true$"
|
||||
save_as: endpoint_uid
|
||||
- action: assert_greater
|
||||
actual: "{{ endpoint_uid }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^endpoint_mounted_io=ok$"
|
||||
save_as: endpoint_io
|
||||
- action: assert_greater
|
||||
actual: "{{ endpoint_io }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^endpoint_surfaces_agree=true$"
|
||||
save_as: surfaces
|
||||
- action: assert_greater
|
||||
actual: "{{ surfaces }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^outage_tcp_fallback_observed=false$"
|
||||
save_as: outage_no_tcp
|
||||
- action: assert_greater
|
||||
actual: "{{ outage_no_tcp }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^endpoint_tcp_fallback_observed=false$"
|
||||
save_as: endpoint_no_tcp
|
||||
- action: assert_greater
|
||||
actual: "{{ endpoint_no_tcp }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^outage_is_non_primary=true$"
|
||||
save_as: non_primary_outage
|
||||
- action: assert_greater
|
||||
actual: "{{ non_primary_outage }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^endpoint_transition_io=ok$"
|
||||
save_as: transition_io
|
||||
- action: assert_greater
|
||||
actual: "{{ transition_io }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^hostpath_cleanup_nodes=m01,m02$"
|
||||
save_as: hostpath_cleanup
|
||||
- action: assert_greater
|
||||
actual: "{{ hostpath_cleanup }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath/phase166-nvme-rdma-k8s-multipath-reconnect-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: cleanup_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ cleanup_ok }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: collect
|
||||
always: true
|
||||
actions:
|
||||
- action: collect_path
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase166-nvme-rdma-multipath"
|
||||
name: remote-phases
|
||||
ignore_error: true
|
||||
@@ -106,10 +106,10 @@ phases:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase133-nvme-stale-path-prune/gate/phase133-nvme-k8s-stale-path-prune-summary.txt"
|
||||
pattern: "^stale_old_path_detected=true$"
|
||||
save_as: stale_detected
|
||||
pattern: "^stale_old_host_path_after_desired_change=false$"
|
||||
save_as: stale_absent
|
||||
- action: assert_greater
|
||||
actual: "{{ stale_detected }}"
|
||||
actual: "{{ stale_absent }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
|
||||
Reference in new issue
Block a user