mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
phase35: cover stale operator status projections
This commit is contained in:
1 parent
82926fbc23
commit
7028ff142a
2 files changed
+161
-5
No files matched your search
@@ -167,6 +167,99 @@ func TestOperatorStatusReconcilerStaleEvidenceProjectsUnknownAndWarningEvent(t *
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperatorStatusReconcilerStatusEndpointUnreachableIsUnknownNotBlocked(t *testing.T) {
|
||||
source := fakeOperatorStatusSource{cluster: ClusterEvidence{
|
||||
SchemaVersion: ObservationSchemaVersion,
|
||||
CapturedAt: time.Date(2026, 6, 4, 2, 0, 0, 0, time.UTC),
|
||||
Status: ObservationStatusUnavailable,
|
||||
ManagedVolumes: []ManagedVolumeProjection{ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-unreachable",
|
||||
PVCName: "status-unreachable-pvc",
|
||||
ProductStatus: ObservationStatusUnavailable,
|
||||
ProductReason: ReasonStatusEndpointUnreachable,
|
||||
EvidenceRefs: []string{"diagnostics/status-endpoint-unreachable.txt"},
|
||||
})},
|
||||
}}
|
||||
writer := &fakeOperatorStatusWriter{}
|
||||
events := &fakeOperatorEventSink{}
|
||||
|
||||
_, err := (OperatorStatusReconciler{
|
||||
Source: source,
|
||||
Writer: writer,
|
||||
EventSink: events,
|
||||
}).Reconcile(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: %v", err)
|
||||
}
|
||||
if writer.cluster.StaleVolumeCount != 1 || writer.cluster.BlockedVolumeCount != 0 {
|
||||
t.Fatalf("cluster status=%+v", writer.cluster)
|
||||
}
|
||||
if len(writer.volumes) != 1 {
|
||||
t.Fatalf("volume writes=%+v", writer.volumes)
|
||||
}
|
||||
volume := writer.volumes[0]
|
||||
if volume.status.Status != ManagedVolumeStatusUnknown || volume.status.ReasonCode != ReasonStatusEndpointUnreachable {
|
||||
t.Fatalf("volume status=%+v", volume.status)
|
||||
}
|
||||
assertCondition(t, volume.status.Conditions, ConditionReady, "Unknown", ReasonStatusEndpointUnreachable)
|
||||
assertCondition(t, volume.status.Conditions, ConditionEvidenceStale, "True", ReasonStatusEndpointUnreachable)
|
||||
if condition := findObservationCondition(volume.status.Conditions, ConditionBlocked); condition != nil && condition.Status == "True" {
|
||||
t.Fatalf("pure unreachable status must not become Blocked=True: %+v", volume.status.Conditions)
|
||||
}
|
||||
if events.countByReason(ReasonStatusEndpointUnreachable) == 0 {
|
||||
t.Fatalf("missing status_endpoint_unreachable event: %+v", events.events)
|
||||
}
|
||||
for _, event := range events.events {
|
||||
if event.Reason == ReasonStatusEndpointUnreachable && event.Type != "Warning" {
|
||||
t.Fatalf("status endpoint event type=%s want Warning", event.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperatorStatusReconcilerWALIntegrityFaultIsNeverReady(t *testing.T) {
|
||||
source := fakeOperatorStatusSource{cluster: ClusterEvidence{
|
||||
SchemaVersion: ObservationSchemaVersion,
|
||||
CapturedAt: time.Date(2026, 6, 4, 2, 15, 0, 0, time.UTC),
|
||||
Status: ObservationStatusBlocked,
|
||||
ManagedVolumes: []ManagedVolumeProjection{ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-corrupt",
|
||||
PVCName: "wal-corrupt-pvc",
|
||||
ProductStatus: ObservationStatusBlocked,
|
||||
ProductReason: ReasonWALIntegrityFault,
|
||||
EvidenceRefs: []string{"status/report/cluster-evidence.json", "blockvolume.log"},
|
||||
})},
|
||||
}}
|
||||
writer := &fakeOperatorStatusWriter{}
|
||||
events := &fakeOperatorEventSink{}
|
||||
|
||||
_, err := (OperatorStatusReconciler{
|
||||
Source: source,
|
||||
Writer: writer,
|
||||
EventSink: events,
|
||||
}).Reconcile(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: %v", err)
|
||||
}
|
||||
if writer.cluster.ReadyVolumeCount != 0 || writer.cluster.BlockedVolumeCount != 1 {
|
||||
t.Fatalf("cluster status=%+v", writer.cluster)
|
||||
}
|
||||
if len(writer.volumes) != 1 {
|
||||
t.Fatalf("volume writes=%+v", writer.volumes)
|
||||
}
|
||||
volume := writer.volumes[0]
|
||||
if volume.status.Status == ManagedVolumeStatusReady {
|
||||
t.Fatalf("wal integrity fault must never be Ready: %+v", volume.status)
|
||||
}
|
||||
if volume.status.ReasonCode != ReasonWALIntegrityFault {
|
||||
t.Fatalf("volume status=%+v", volume.status)
|
||||
}
|
||||
assertCondition(t, volume.status.Conditions, ConditionReady, "False", ReasonWALIntegrityFault)
|
||||
assertCondition(t, volume.status.Conditions, ConditionBlocked, "True", ReasonWALIntegrityFault)
|
||||
if events.countByReason(ReasonWALIntegrityFault) == 0 {
|
||||
t.Fatalf("missing wal_integrity_fault event: %+v", events.events)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperatorStatusReconcilerEventFailureDoesNotBlockLaterStatusWrites(t *testing.T) {
|
||||
source := fakeOperatorStatusSource{cluster: ClusterEvidence{
|
||||
SchemaVersion: ObservationSchemaVersion,
|
||||
@@ -302,3 +395,14 @@ func (f *fakeOperatorEventSink) countByReason(reason string) int {
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func assertCondition(t *testing.T, conditions []ObservationCondition, typ, status, reason string) {
|
||||
t.Helper()
|
||||
condition := findObservationCondition(conditions, typ)
|
||||
if condition == nil {
|
||||
t.Fatalf("missing %s condition: %+v", typ, conditions)
|
||||
}
|
||||
if condition.Status != status || condition.Reason != reason {
|
||||
t.Fatalf("%s condition=%+v want status=%s reason=%s", typ, *condition, status, reason)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# Current Plan: Phase 35 - Kubernetes-Native Read-Only Operator Foundation
|
||||
|
||||
Status: active, 66% complete. Started on 2026-06-02.
|
||||
Status: active, 72% complete. Started on 2026-06-02.
|
||||
|
||||
Branch: `phase33-testops-failure-hardening`
|
||||
|
||||
@@ -198,6 +198,8 @@ Non-blocking follow-ups:
|
||||
|
||||
Goal: preserve the negative-first rule for unreachable or incomplete evidence.
|
||||
|
||||
Status: local contract PASS; live QA pending.
|
||||
|
||||
Scenarios:
|
||||
|
||||
- live status endpoint unreachable.
|
||||
@@ -213,6 +215,53 @@ SmartWAL corruption never becomes Ready=True
|
||||
preferred follow-up: reason=wal_integrity_fault when that reason is surfaced
|
||||
```
|
||||
|
||||
Local verification:
|
||||
|
||||
```text
|
||||
[done] operator-status projects evidence_stale as Ready=Unknown +
|
||||
EvidenceStale=True and emits a Warning Event.
|
||||
[done] operator-status projects status_endpoint_unreachable as Ready=Unknown +
|
||||
EvidenceStale=True, not Blocked=True, and emits a Warning Event.
|
||||
[done] operator-status projects wal_integrity_fault as non-Ready
|
||||
(Blocked/Ready=False) with reason=wal_integrity_fault.
|
||||
[done] go test ./core/ops ./cmd/sw-block ./cmd/blockcsi
|
||||
[done] helm lint charts/seaweed-block
|
||||
[done] helm template with operatorStatus.create=true,dryRun=false renders
|
||||
status/events-only RBAC and no --dry-run arg.
|
||||
```
|
||||
|
||||
QA assignment:
|
||||
|
||||
```text
|
||||
Run a live D5 status-surface gate in write mode.
|
||||
|
||||
Required checks:
|
||||
1. Pure status endpoint unreachable:
|
||||
- SwBlockVolume.status.status=unknown
|
||||
- Ready=Unknown
|
||||
- EvidenceStale=True
|
||||
- reasonCode=status_endpoint_unreachable
|
||||
- Kubernetes Warning Event reason=status_endpoint_unreachable
|
||||
- no Blocked=True and no Ready=True on CRD/report/dashboard/operator-snapshot
|
||||
|
||||
2. Evidence stale replay/bundle:
|
||||
- SwBlockVolume.status.status=unknown
|
||||
- Ready=Unknown
|
||||
- EvidenceStale=True
|
||||
- reasonCode=evidence_stale
|
||||
- Kubernetes Warning Event reason=evidence_stale
|
||||
|
||||
3. Phase 34 SmartWAL corruption projection:
|
||||
- no Ready=True anywhere
|
||||
- preferred: reasonCode=wal_integrity_fault when the fact is surfaced
|
||||
- accepted for D5 only: any non-ready projection if the live evidence still
|
||||
lacks the specific reason
|
||||
|
||||
4. Read-only boundary:
|
||||
- operator SA can patch only CRD status and create Events
|
||||
- no storage/workload mutation verbs are granted
|
||||
```
|
||||
|
||||
## D6: Kubernetes Events Gate
|
||||
|
||||
Goal: make important transitions visible through standard Kubernetes Events.
|
||||
@@ -315,13 +364,16 @@ finished plan moved under internal/docs/finished-plans/
|
||||
0 even with duplicate/already-existing Events, Warning Event exists,
|
||||
`SwBlockVolume.status` is blocked with Ready=False and Blocked=True, no
|
||||
Ready=True appears on blocked surfaces, and RBAC remains status/events only.
|
||||
- 72%: D5 local contract coverage landed. Operator-status tests now lock
|
||||
`evidence_stale`, `status_endpoint_unreachable`, and `wal_integrity_fault`
|
||||
projections through the CRD-status/Event layer. Scoped Go tests, Helm lint,
|
||||
and write-mode Helm render pass. Live QA is pending.
|
||||
|
||||
## Next Step
|
||||
|
||||
Implement and validate D5 Unknown/EvidenceStale publication: unreachable or
|
||||
incomplete evidence must become Ready=Unknown/EvidenceStale=True, not Blocked
|
||||
and never Ready=True. Reuse the Phase 34 SmartWAL corruption projection to prove
|
||||
the status surface remains negative-first.
|
||||
Ask QA to run the D5 live status-surface gate in write mode. D5 closes only
|
||||
when unreachable/stale evidence is visible through Kubernetes CRD status and
|
||||
Events without any false Ready=True or inappropriate Blocked=True projection.
|
||||
|
||||
```text
|
||||
Condition Ready=Unknown
|
||||
|
||||
Reference in new issue
Block a user