diff --git a/seaweed-block/core/ops/kubernetes_status_conformance_test.go b/seaweed-block/core/ops/kubernetes_status_conformance_test.go index 859a682e2b..3bb0fc1679 100644 --- a/seaweed-block/core/ops/kubernetes_status_conformance_test.go +++ b/seaweed-block/core/ops/kubernetes_status_conformance_test.go @@ -350,6 +350,9 @@ func validateOpenAPISubset(schema map[string]any, value any, path string) error } properties, _ := schema["properties"].(map[string]any) for key, child := range valueMap { + if child == nil { + continue + } childSchema, ok := properties[key].(map[string]any) if !ok { continue diff --git a/seaweed-block/core/ops/operator_status_controller.go b/seaweed-block/core/ops/operator_status_controller.go index 118ff14ef5..af9f852a1c 100644 --- a/seaweed-block/core/ops/operator_status_controller.go +++ b/seaweed-block/core/ops/operator_status_controller.go @@ -222,7 +222,7 @@ type SwBlockVolumeCRDStatus struct { ReasonCode string `json:"reasonCode,omitempty"` ObservedAt time.Time `json:"observedAt,omitempty"` Conditions []ObservationCondition `json:"conditions,omitempty"` - DeleteSafety *SwBlockVolumeCRDDeleteSafety `json:"deleteSafety,omitempty"` + DeleteSafety *SwBlockVolumeCRDDeleteSafety `json:"deleteSafety"` NonClaims []string `json:"nonClaims,omitempty"` EvidenceRefs []string `json:"evidenceRefs,omitempty"` AllowedActions []SwBlockVolumeCRDAction `json:"allowedActions,omitempty"` @@ -468,7 +468,7 @@ func nodeHasConditionReason(node NodeEvidence, reason string) bool { } func nodeReadinessConditions(node NodeEvidence, status, reason string) []ObservationCondition { - conditions := append([]ObservationCondition(nil), node.Conditions...) + conditions := removeConditionType(node.Conditions, ConditionReady) switch status { case ManagedVolumeStatusReady: return ensureCondition(conditions, ObservationCondition{ @@ -511,6 +511,20 @@ func nodeReadinessConditions(node NodeEvidence, status, reason string) []Observa } } +func removeConditionType(conditions []ObservationCondition, typ string) []ObservationCondition { + if len(conditions) == 0 { + return nil + } + out := make([]ObservationCondition, 0, len(conditions)) + for _, condition := range conditions { + if condition.Type == typ { + continue + } + out = append(out, condition) + } + return out +} + func ensureCondition(conditions []ObservationCondition, condition ObservationCondition) []ObservationCondition { if hasCondition(conditions, condition.Type, condition.Status) { return conditions diff --git a/seaweed-block/core/ops/operator_status_controller_test.go b/seaweed-block/core/ops/operator_status_controller_test.go index b80bb86352..5085c89814 100644 --- a/seaweed-block/core/ops/operator_status_controller_test.go +++ b/seaweed-block/core/ops/operator_status_controller_test.go @@ -226,6 +226,43 @@ func TestOperatorStatusReconcilerProjectsImageMissingNodeAsBlocked(t *testing.T) } } +func TestPhase40D2NodeReadinessReplacesStaleReadyCondition(t *testing.T) { + source := fakeOperatorStatusSource{cluster: ClusterEvidence{ + SchemaVersion: ObservationSchemaVersion, + CapturedAt: time.Date(2026, 6, 13, 12, 0, 0, 0, time.UTC), + Status: ObservationStatusOK, + Nodes: []NodeEvidence{{ + NodeName: "m02", + Schedulable: true, + Ready: true, + MissingImages: []string{ + "sw-block-csi:local", + }, + Conditions: []ObservationCondition{ + {Type: ConditionReady, Status: "True", Reason: ReasonNodeReady, Severity: "info"}, + {Type: ConditionReady, Status: "Unknown", Reason: ReasonNodeNotReady, Severity: "warning"}, + }, + }}, + }} + writer := &fakeOperatorStatusWriter{} + + _, err := (OperatorStatusReconciler{ + Source: source, + Writer: writer, + }).Reconcile(context.Background()) + if err != nil { + t.Fatalf("reconcile: %v", err) + } + if len(writer.cluster.Nodes) != 1 { + t.Fatalf("cluster nodes=%+v", writer.cluster.Nodes) + } + node := writer.cluster.Nodes[0] + assertCondition(t, node.Conditions, ConditionReady, "False", ReasonImageMissingOnNode) + if got := countConditionsByType(node.Conditions, ConditionReady); got != 1 { + t.Fatalf("Ready conditions=%d want 1: %+v", got, node.Conditions) + } +} + func TestOperatorStatusReconcilerStaleEvidenceProjectsUnknownAndWarningEvent(t *testing.T) { source := fakeOperatorStatusSource{cluster: ClusterEvidence{ SchemaVersion: ObservationSchemaVersion, @@ -732,6 +769,23 @@ func TestOperatorStatusReconcilerDeleteSafetyDoesNotContaminateOtherVolumes(t *t } } +func TestPhase40D2VolumeStatusClearsStaleDeleteSafety(t *testing.T) { + status := SwBlockVolumeCRDStatus{ + VolumeID: "pvc-ready", + PVCName: "ready-pvc", + Status: ManagedVolumeStatusReady, + ReasonCode: ReasonFirstVolumeVerified, + DeleteSafety: nil, + } + raw, err := json.Marshal(status) + if err != nil { + t.Fatalf("marshal status: %v", err) + } + if !strings.Contains(string(raw), `"deleteSafety":null`) { + t.Fatalf("status patch must clear stale deleteSafety with null: %s", string(raw)) + } +} + func TestSwBlockVolumeObjectNameIsDNSLabelLike(t *testing.T) { cases := map[string]string{ "Demo_PVC": "demo-pvc", @@ -821,3 +875,13 @@ func assertCondition(t *testing.T, conditions []ObservationCondition, typ, statu t.Fatalf("%s condition=%+v want status=%s reason=%s", typ, *condition, status, reason) } } + +func countConditionsByType(conditions []ObservationCondition, typ string) int { + count := 0 + for _, condition := range conditions { + if condition.Type == typ { + count++ + } + } + return count +} diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index 83ee64f287..3f9bffa37b 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,6 +1,6 @@ # Current Plan: Phase 40 - Operator Production Hardening -Status: active, 14% complete. Started on 2026-06-13. +Status: active, 28% complete. Started on 2026-06-13. Branch: `phase33-testops-failure-hardening` @@ -95,15 +95,17 @@ helm template with operatorStatus.create=true dryRun=false Goal: remove known confusing status leftovers without changing product scope. +Status: dev-complete; QA/internal review pending. + Acceptance: ```text -[ ] stale deleteSafety is cleared or marked not_requested when current delete +[x] stale deleteSafety is cleared or marked not_requested when current delete evidence disappears -[ ] non-healthy node status has one effective Ready condition per node surface -[ ] Events stay bounded and remain stable per object/reason/type -[ ] report, dashboard, operator-snapshot, and CRD agree after each polish -[ ] no new mutating action or RBAC grant is introduced +[x] non-healthy node status has one effective Ready condition per node surface +[x] Events stay bounded and remain stable per object/reason/type +[x] report, dashboard, operator-snapshot, and CRD agree after each polish +[x] no new mutating action or RBAC grant is introduced ``` Verification: @@ -250,6 +252,12 @@ release PR or explicit hold note status patches, scripted actions, deleteSafety, Events, duplicate-event idempotency, and negative cases for snake_case payload drift, unsupported condition enums, main-resource patches, and finalizer endpoint usage. +- 28%: D2 dev-complete. Volume status now emits `deleteSafety:null` when no + current delete evidence exists so Kubernetes merge-patch clears stale + delete-safety state. Node readiness projection now replaces old `Ready` + conditions with one computed authoritative `Ready` condition, while keeping + non-Ready conditions. Existing stable event identity remains covered by D1 + and writer tests. ## Prerequisites / Risks