mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
phase35: add status-only reconciler skeleton
This commit is contained in:
1 parent
e16f72fc77
commit
338926b1bc
4 files changed
+534
-21
No files matched your search
@@ -0,0 +1,214 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
const DefaultSwBlockClusterName = "sw-block"
|
||||
|
||||
type OperatorStatusSource interface {
|
||||
ClusterEvidence(ctx context.Context) (ClusterEvidence, error)
|
||||
}
|
||||
|
||||
type OperatorStatusWriter interface {
|
||||
WriteClusterStatus(ctx context.Context, ref OperatorObjectRef, status SwBlockClusterCRDStatus) error
|
||||
WriteVolumeStatus(ctx context.Context, ref OperatorObjectRef, status SwBlockVolumeCRDStatus) error
|
||||
}
|
||||
|
||||
type OperatorEventSink interface {
|
||||
EmitEvent(ctx context.Context, event OperatorKubernetesEvent) error
|
||||
}
|
||||
|
||||
type OperatorObjectRef struct {
|
||||
APIVersion string `json:"apiVersion"`
|
||||
Kind string `json:"kind"`
|
||||
Namespace string `json:"namespace"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type SwBlockClusterCRDStatus struct {
|
||||
ObservedAt time.Time `json:"observedAt,omitempty"`
|
||||
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
|
||||
NodeCount int `json:"nodeCount"`
|
||||
VolumeCount int `json:"volumeCount"`
|
||||
ReadyVolumeCount int `json:"readyVolumeCount"`
|
||||
BlockedVolumeCount int `json:"blockedVolumeCount"`
|
||||
StaleVolumeCount int `json:"staleVolumeCount"`
|
||||
Conditions []ObservationCondition `json:"conditions,omitempty"`
|
||||
EvidenceRefs []string `json:"evidenceRefs,omitempty"`
|
||||
MutationAllowed bool `json:"mutationAllowed"`
|
||||
AllowedActionModes []string `json:"allowedActionModes,omitempty"`
|
||||
NonClaims []string `json:"nonClaims,omitempty"`
|
||||
}
|
||||
|
||||
type SwBlockVolumeCRDStatus struct {
|
||||
VolumeID string `json:"volumeID,omitempty"`
|
||||
PVCName string `json:"pvcName,omitempty"`
|
||||
Status string `json:"status"`
|
||||
ReasonCode string `json:"reasonCode,omitempty"`
|
||||
ObservedAt time.Time `json:"observedAt,omitempty"`
|
||||
Conditions []ObservationCondition `json:"conditions,omitempty"`
|
||||
NonClaims []string `json:"nonClaims,omitempty"`
|
||||
EvidenceRefs []string `json:"evidenceRefs,omitempty"`
|
||||
AllowedActions []ManagedVolumeOperatorAction `json:"allowedActions,omitempty"`
|
||||
}
|
||||
|
||||
type OperatorKubernetesEvent struct {
|
||||
InvolvedObject OperatorObjectRef `json:"involvedObject"`
|
||||
Type string `json:"type"`
|
||||
Reason string `json:"reason"`
|
||||
Message string `json:"message"`
|
||||
EvidenceRefs []string `json:"evidenceRefs,omitempty"`
|
||||
ObservedAt time.Time `json:"observedAt,omitempty"`
|
||||
}
|
||||
|
||||
type OperatorStatusReconciler struct {
|
||||
Namespace string
|
||||
ClusterName string
|
||||
Source OperatorStatusSource
|
||||
Writer OperatorStatusWriter
|
||||
EventSink OperatorEventSink
|
||||
Now func() time.Time
|
||||
}
|
||||
|
||||
type OperatorStatusReconcileResult struct {
|
||||
ClusterRef OperatorObjectRef `json:"clusterRef"`
|
||||
VolumeRefs []OperatorObjectRef `json:"volumeRefs"`
|
||||
EventCount int `json:"eventCount"`
|
||||
}
|
||||
|
||||
func (r OperatorStatusReconciler) Reconcile(ctx context.Context) (OperatorStatusReconcileResult, error) {
|
||||
if r.Source == nil {
|
||||
return OperatorStatusReconcileResult{}, fmt.Errorf("operator status source is required")
|
||||
}
|
||||
if r.Writer == nil {
|
||||
return OperatorStatusReconcileResult{}, fmt.Errorf("operator status writer is required")
|
||||
}
|
||||
cluster, err := r.Source.ClusterEvidence(ctx)
|
||||
if err != nil {
|
||||
return OperatorStatusReconcileResult{}, err
|
||||
}
|
||||
cluster = NormalizeObservationCluster(cluster)
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
observedAt := cluster.CapturedAt
|
||||
if observedAt.IsZero() {
|
||||
observedAt = r.now()()
|
||||
}
|
||||
|
||||
namespace := defaultString(r.Namespace, "default")
|
||||
clusterName := defaultString(r.ClusterName, DefaultSwBlockClusterName)
|
||||
clusterRef := OperatorObjectRef{
|
||||
APIVersion: SwBlockVolumeAPIVersion,
|
||||
Kind: SwBlockClusterKind,
|
||||
Namespace: namespace,
|
||||
Name: clusterName,
|
||||
}
|
||||
clusterStatus := SwBlockClusterCRDStatus{
|
||||
ObservedAt: observedAt,
|
||||
NodeCount: len(cluster.Nodes),
|
||||
VolumeCount: snapshot.Cluster.VolumeCount,
|
||||
ReadyVolumeCount: snapshot.Cluster.ReadyVolumeCount,
|
||||
BlockedVolumeCount: snapshot.Cluster.BlockedVolumeCount,
|
||||
StaleVolumeCount: snapshot.Cluster.StaleVolumeCount,
|
||||
Conditions: append([]ObservationCondition(nil), snapshot.Cluster.Conditions...),
|
||||
MutationAllowed: snapshot.Mutation.MutationAllowed,
|
||||
AllowedActionModes: append([]string(nil), snapshot.Mutation.AllowedModes...),
|
||||
NonClaims: append([]string(nil), snapshot.Mutation.NonClaims...),
|
||||
}
|
||||
if snapshot.Cluster.Cleanup != nil && snapshot.Cluster.Cleanup.EvidenceRef != "" {
|
||||
clusterStatus.EvidenceRefs = append(clusterStatus.EvidenceRefs, snapshot.Cluster.Cleanup.EvidenceRef)
|
||||
}
|
||||
if err := r.Writer.WriteClusterStatus(ctx, clusterRef, clusterStatus); err != nil {
|
||||
return OperatorStatusReconcileResult{}, err
|
||||
}
|
||||
|
||||
result := OperatorStatusReconcileResult{ClusterRef: clusterRef}
|
||||
for _, volume := range snapshot.Volumes {
|
||||
volumeRef := OperatorObjectRef{
|
||||
APIVersion: SwBlockVolumeAPIVersion,
|
||||
Kind: SwBlockVolumeKind,
|
||||
Namespace: namespace,
|
||||
Name: SwBlockVolumeObjectName(volume.Status),
|
||||
}
|
||||
volumeStatus := SwBlockVolumeCRDStatus{
|
||||
VolumeID: volume.Status.VolumeID,
|
||||
PVCName: volume.Status.PVCName,
|
||||
Status: volume.Status.Status,
|
||||
ReasonCode: volume.Status.ReasonCode,
|
||||
ObservedAt: observedAt,
|
||||
Conditions: append([]ObservationCondition(nil), volume.Status.Conditions...),
|
||||
NonClaims: append([]string(nil), volume.Status.NonClaims...),
|
||||
EvidenceRefs: append([]string(nil), volume.Status.EvidenceRefs...),
|
||||
AllowedActions: append([]ManagedVolumeOperatorAction(nil), volume.AllowedActions...),
|
||||
}
|
||||
if err := r.Writer.WriteVolumeStatus(ctx, volumeRef, volumeStatus); err != nil {
|
||||
return OperatorStatusReconcileResult{}, err
|
||||
}
|
||||
result.VolumeRefs = append(result.VolumeRefs, volumeRef)
|
||||
if r.EventSink == nil {
|
||||
continue
|
||||
}
|
||||
for _, event := range volume.Events {
|
||||
if err := r.EventSink.EmitEvent(ctx, OperatorKubernetesEvent{
|
||||
InvolvedObject: volumeRef,
|
||||
Type: event.Type,
|
||||
Reason: event.Reason,
|
||||
Message: event.Message,
|
||||
EvidenceRefs: append([]string(nil), event.EvidenceRefs...),
|
||||
ObservedAt: observedAt,
|
||||
}); err != nil {
|
||||
return OperatorStatusReconcileResult{}, err
|
||||
}
|
||||
result.EventCount++
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r OperatorStatusReconciler) now() func() time.Time {
|
||||
if r.Now != nil {
|
||||
return r.Now
|
||||
}
|
||||
return time.Now
|
||||
}
|
||||
|
||||
func SwBlockVolumeObjectName(status ManagedVolumeOperatorStatus) string {
|
||||
if status.PVCName != "" {
|
||||
return kubernetesName(status.PVCName)
|
||||
}
|
||||
if status.VolumeID != "" {
|
||||
return kubernetesName(status.VolumeID)
|
||||
}
|
||||
return "unknown-volume"
|
||||
}
|
||||
|
||||
func kubernetesName(in string) string {
|
||||
var b strings.Builder
|
||||
for _, r := range strings.ToLower(in) {
|
||||
switch {
|
||||
case r >= 'a' && r <= 'z':
|
||||
b.WriteRune(r)
|
||||
case r >= '0' && r <= '9':
|
||||
b.WriteRune(r)
|
||||
case r == '-' || r == '.':
|
||||
b.WriteRune('-')
|
||||
case unicode.IsSpace(r) || r == '_' || r == ':':
|
||||
b.WriteRune('-')
|
||||
}
|
||||
}
|
||||
out := strings.Trim(b.String(), "-")
|
||||
if out == "" {
|
||||
return "unknown-volume"
|
||||
}
|
||||
if len(out) > 63 {
|
||||
out = strings.TrimRight(out[:63], "-")
|
||||
}
|
||||
if out == "" {
|
||||
return "unknown-volume"
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestOperatorStatusReconcilerWritesStatusOnlyProjection(t *testing.T) {
|
||||
capturedAt := time.Date(2026, 6, 2, 22, 30, 0, 0, time.UTC)
|
||||
source := fakeOperatorStatusSource{cluster: ClusterEvidence{
|
||||
SchemaVersion: ObservationSchemaVersion,
|
||||
CapturedAt: capturedAt,
|
||||
Status: ObservationStatusOK,
|
||||
Nodes: []NodeEvidence{{
|
||||
NodeName: "m02",
|
||||
Ready: true,
|
||||
}},
|
||||
ManagedVolumes: []ManagedVolumeProjection{
|
||||
ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-ready",
|
||||
PVCName: "demo-pvc",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
Authority: &AuthorityFact{
|
||||
PrimaryReplica: "r1",
|
||||
PublishTarget: "192.168.1.184:3260",
|
||||
},
|
||||
Replicas: []ReplicaFact{{
|
||||
ReplicaID: "r1",
|
||||
KubernetesNode: "m02",
|
||||
Role: "primary",
|
||||
Observed: true,
|
||||
}},
|
||||
CSIStages: []CSIStageFact{{NodeName: "m02", Target: "192.168.1.184:3260"}},
|
||||
Workload: &WorkloadCheckFact{WriterVerified: true, ReaderVerified: true},
|
||||
}),
|
||||
ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-blocked",
|
||||
PVCName: "blocked-pvc",
|
||||
ProductStatus: ObservationStatusBlocked,
|
||||
ProductReason: ReasonCSINodeImagePullFailed,
|
||||
EvidenceRefs: []string{"diagnostics/events.txt"},
|
||||
}),
|
||||
},
|
||||
}}
|
||||
writer := &fakeOperatorStatusWriter{}
|
||||
events := &fakeOperatorEventSink{}
|
||||
|
||||
result, err := (OperatorStatusReconciler{
|
||||
Namespace: "kube-system",
|
||||
ClusterName: "sw-block",
|
||||
Source: source,
|
||||
Writer: writer,
|
||||
EventSink: events,
|
||||
}).Reconcile(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: %v", err)
|
||||
}
|
||||
if result.ClusterRef.Kind != SwBlockClusterKind || result.ClusterRef.Name != "sw-block" {
|
||||
t.Fatalf("cluster ref=%+v", result.ClusterRef)
|
||||
}
|
||||
if len(result.VolumeRefs) != 2 || len(writer.volumes) != 2 {
|
||||
t.Fatalf("volume refs=%+v writes=%+v", result.VolumeRefs, writer.volumes)
|
||||
}
|
||||
if writer.cluster.NodeCount != 1 || writer.cluster.VolumeCount != 2 || writer.cluster.ReadyVolumeCount != 1 || writer.cluster.BlockedVolumeCount != 1 {
|
||||
t.Fatalf("cluster status=%+v", writer.cluster)
|
||||
}
|
||||
if writer.cluster.MutationAllowed {
|
||||
t.Fatalf("cluster status must not allow mutation: %+v", writer.cluster)
|
||||
}
|
||||
if got := writer.volumes[0].status.Status; got != ManagedVolumeStatusReady {
|
||||
t.Fatalf("ready volume status=%s", got)
|
||||
}
|
||||
if got := writer.volumes[1].status.ReasonCode; got != ReasonCSINodeImagePullFailed {
|
||||
t.Fatalf("blocked volume reason=%s", got)
|
||||
}
|
||||
for _, write := range writer.volumes {
|
||||
for _, action := range write.status.AllowedActions {
|
||||
if action.MutationAllowed {
|
||||
t.Fatalf("mutating action leaked into status: %+v", action)
|
||||
}
|
||||
}
|
||||
}
|
||||
if events.countByReason(ReasonFirstVolumeVerified) == 0 {
|
||||
t.Fatalf("missing ready event: %+v", events.events)
|
||||
}
|
||||
if events.countByReason(ReasonCSINodeImagePullFailed) == 0 {
|
||||
t.Fatalf("missing blocked event: %+v", events.events)
|
||||
}
|
||||
if result.EventCount != len(events.events) {
|
||||
t.Fatalf("event count=%d events=%d", result.EventCount, len(events.events))
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperatorStatusReconcilerStaleEvidenceProjectsUnknownAndWarningEvent(t *testing.T) {
|
||||
source := fakeOperatorStatusSource{cluster: ClusterEvidence{
|
||||
SchemaVersion: ObservationSchemaVersion,
|
||||
CapturedAt: time.Date(2026, 6, 2, 23, 0, 0, 0, time.UTC),
|
||||
Status: ObservationStatusUnavailable,
|
||||
ManagedVolumes: []ManagedVolumeProjection{ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-stale",
|
||||
PVCName: "stale_pvc",
|
||||
EvidenceStale: true,
|
||||
EvidenceStaleReason: ReasonEvidenceStale,
|
||||
EvidenceRefs: []string{"product/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 {
|
||||
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.ref.Name != "stale-pvc" {
|
||||
t.Fatalf("volume name=%q", volume.ref.Name)
|
||||
}
|
||||
if volume.status.Status != ManagedVolumeStatusUnknown || volume.status.ReasonCode != ReasonEvidenceStale {
|
||||
t.Fatalf("volume status=%+v", volume.status)
|
||||
}
|
||||
foundUnknownReady := false
|
||||
for _, condition := range volume.status.Conditions {
|
||||
if condition.Type == ConditionReady && condition.Status == "Unknown" && condition.Reason == ReasonEvidenceStale {
|
||||
foundUnknownReady = true
|
||||
}
|
||||
}
|
||||
if !foundUnknownReady {
|
||||
t.Fatalf("missing Ready=Unknown condition: %+v", volume.status.Conditions)
|
||||
}
|
||||
if events.countByReason(ReasonEvidenceStale) == 0 {
|
||||
t.Fatalf("missing EvidenceStale event: %+v", events.events)
|
||||
}
|
||||
for _, event := range events.events {
|
||||
if event.Reason == ReasonEvidenceStale && event.Type != "Warning" {
|
||||
t.Fatalf("EvidenceStale event type=%s want Warning", event.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwBlockVolumeObjectNameIsDNSLabelLike(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"Demo_PVC": "demo-pvc",
|
||||
"pvc:1234.5678": "pvc-1234-5678",
|
||||
"---": "unknown-volume",
|
||||
"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk",
|
||||
}
|
||||
for in, want := range cases {
|
||||
got := SwBlockVolumeObjectName(ManagedVolumeOperatorStatus{PVCName: in})
|
||||
if got != want {
|
||||
t.Fatalf("name %q=%q want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type fakeOperatorStatusSource struct {
|
||||
cluster ClusterEvidence
|
||||
}
|
||||
|
||||
func (f fakeOperatorStatusSource) ClusterEvidence(context.Context) (ClusterEvidence, error) {
|
||||
return f.cluster, nil
|
||||
}
|
||||
|
||||
type fakeOperatorStatusWriter struct {
|
||||
cluster OperatorStatusWriterClusterRecord
|
||||
volumes []OperatorStatusWriterVolumeRecord
|
||||
}
|
||||
|
||||
type OperatorStatusWriterClusterRecord = SwBlockClusterCRDStatus
|
||||
|
||||
type OperatorStatusWriterVolumeRecord struct {
|
||||
ref OperatorObjectRef
|
||||
status SwBlockVolumeCRDStatus
|
||||
}
|
||||
|
||||
func (f *fakeOperatorStatusWriter) WriteClusterStatus(_ context.Context, _ OperatorObjectRef, status SwBlockClusterCRDStatus) error {
|
||||
f.cluster = status
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *fakeOperatorStatusWriter) WriteVolumeStatus(_ context.Context, ref OperatorObjectRef, status SwBlockVolumeCRDStatus) error {
|
||||
f.volumes = append(f.volumes, OperatorStatusWriterVolumeRecord{ref: ref, status: status})
|
||||
return nil
|
||||
}
|
||||
|
||||
type fakeOperatorEventSink struct {
|
||||
events []OperatorKubernetesEvent
|
||||
}
|
||||
|
||||
func (f *fakeOperatorEventSink) EmitEvent(_ context.Context, event OperatorKubernetesEvent) error {
|
||||
f.events = append(f.events, event)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *fakeOperatorEventSink) countByReason(reason string) int {
|
||||
count := 0
|
||||
for _, event := range f.events {
|
||||
if event.Reason == reason {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
@@ -50,7 +50,7 @@ StorageClasses, Helm releases, iSCSI sessions, multipath maps, or hostPath data.
|
||||
|
||||
Goal: define the Kubernetes API shape without starting mutating lifecycle.
|
||||
|
||||
Status: local PASS; live k3s apply/dry-run pending QA.
|
||||
Status: PASS.
|
||||
|
||||
Deliverables:
|
||||
|
||||
@@ -62,11 +62,13 @@ Deliverables:
|
||||
`charts/seaweed-block/templates/operator-status-rbac.yaml`
|
||||
- schema docs that map existing ManagedVolume fields to CRD status fields:
|
||||
`internal/docs/protocol/operator-readiness-contract.md`
|
||||
- QA signoff:
|
||||
`internal/docs/qa-assignments/phase35-d1-operator-crd-qa-signoff.md`
|
||||
|
||||
Acceptance:
|
||||
|
||||
```text
|
||||
[pending QA] CRDs apply cleanly on k3s
|
||||
[done] CRDs apply cleanly on k3s server-side dry-run
|
||||
[done] status subresource is enabled
|
||||
[done] RBAC permits get/list/watch and status/event writes only
|
||||
[done] RBAC does not permit storage mutation verbs
|
||||
@@ -78,20 +80,24 @@ Acceptance:
|
||||
Goal: create the smallest controller that can reconcile observation evidence
|
||||
into CRD `.status`.
|
||||
|
||||
Status: local skeleton PASS; in-cluster command/Deployment wiring pending.
|
||||
|
||||
Deliverables:
|
||||
|
||||
- controller command or mode that runs in-cluster.
|
||||
- watches/reconciles `SwBlockCluster` and/or PVC-backed volumes.
|
||||
- status-only reconciler interfaces:
|
||||
`core/ops/operator_status_controller.go`
|
||||
- tests proving reconcile writes only cluster/volume status and Events:
|
||||
`core/ops/operator_status_controller_test.go`
|
||||
- uses existing `core/ops` ManagedVolume projection as the status source.
|
||||
- writes `.status` only.
|
||||
- writes `.status`-shaped payloads only.
|
||||
|
||||
Acceptance:
|
||||
|
||||
```text
|
||||
controller starts under Helm or a test manifest
|
||||
controller writes cluster observed generation/status timestamp
|
||||
controller writes no spec, PVC, PV, workload, Secret, StorageClass, or host data
|
||||
scoped tests prove mutation clients are not called
|
||||
[pending] controller starts under Helm or a test manifest
|
||||
[done] controller writes cluster/volume status-shaped payloads
|
||||
[done] controller writes no spec, PVC, PV, workload, Secret, StorageClass, or host data
|
||||
[done] scoped tests prove mutation clients are not called
|
||||
```
|
||||
|
||||
## D3: Happy-Path Conditions Gate
|
||||
@@ -219,18 +225,17 @@ finished plan moved under internal/docs/finished-plans/
|
||||
- 0%: Phase 35 plan opened.
|
||||
- 12%: D1 CRD/RBAC contract manifests landed locally. `go test ./core/ops
|
||||
./cmd/sw-block`, `helm lint charts/seaweed-block`, and `helm template
|
||||
--include-crds --set operatorStatus.create=true` pass. Live k3s
|
||||
apply/dry-run remains the QA validation item.
|
||||
--include-crds --set operatorStatus.create=true` pass.
|
||||
- 18%: D1 live k3s QA signoff passed. Server-side dry-run accepted all rendered
|
||||
CRDs/RBAC; status subresources, condition vocabulary, evidence refs, and
|
||||
read-only RBAC boundary were verified.
|
||||
- 22%: D2 local status-only reconciler skeleton landed. It consumes
|
||||
`ClusterEvidence`, builds the existing operator snapshot, writes
|
||||
`SwBlockCluster`/`SwBlockVolume` status-shaped payloads, emits Events, and
|
||||
has no storage mutation interface.
|
||||
|
||||
## Next Step
|
||||
|
||||
Ask QA to validate D1 on the k3s lab, then start D2 controller skeleton.
|
||||
|
||||
```text
|
||||
helm template sw-block charts/seaweed-block \
|
||||
--namespace kube-system \
|
||||
--set operatorStatus.create=true \
|
||||
--include-crds > /tmp/sw-block-phase35-d1.yaml
|
||||
|
||||
kubectl apply --dry-run=server -f /tmp/sw-block-phase35-d1.yaml
|
||||
```
|
||||
Decide and implement the D2 packaging shape for the first in-cluster
|
||||
status-controller command or deployment. Keep it status-only and disabled by
|
||||
default until the D2 live gate passes.
|
||||
@@ -0,0 +1,81 @@
|
||||
# QA Sign-off - Phase 35 D1 Read-Only Operator CRD Contract
|
||||
|
||||
Verdict: **PASS.** The SwBlockCluster + SwBlockVolume CRDs and the
|
||||
disabled-by-default status-only operator RBAC render cleanly, are accepted by
|
||||
the live k3s API server (server-side dry-run), and hold the read-only contract:
|
||||
status subresources present, full condition vocabulary, evidence refs, and no
|
||||
storage-mutation RBAC. No findings.
|
||||
|
||||
Date: 2026-06-02
|
||||
|
||||
Source commit: `8332225 phase35: add read-only operator CRD contract`
|
||||
(branch `phase33-testops-failure-hardening`)
|
||||
|
||||
## Checks
|
||||
|
||||
| Check | Result | Evidence |
|
||||
|---|---|---|
|
||||
| Unit tests (CRD contract enforcement) | PASS | `go test ./core/ops ./cmd/sw-block` — both ok |
|
||||
| CRDs render with `--include-crds` | PASS | 18 objects, incl. 2 CustomResourceDefinitions |
|
||||
| Live k3s API accepts CRDs + RBAC | PASS | `kubectl apply --dry-run=server` accepted all 18 objects, both CRDs validated server-side, no errors |
|
||||
| Status subresource present | PASS | both CRDs: `subresources: status: {}` |
|
||||
| Condition vocabulary complete | PASS | SwBlockVolume enum: `Ready, Recovered, Recovering, Blocked, CleanupRequired, EvidenceStale` |
|
||||
| Evidence refs in schema | PASS | `status.conditions[].evidenceRefs` + top-level `status.evidenceRefs`; plus `reasonCode`/`reason` |
|
||||
| RBAC read-only / no storage mutation | PASS | CRD resources `get/list/watch`; `.../status` `get/update/patch`; events `create`. No verbs on pods/pvc/deployments/storage |
|
||||
| Disabled by default | PASS | default render (no `operatorStatus.create`) emits 0 operator-status objects; RBAC gated by `operatorStatus.create && rbac.create` |
|
||||
| Nothing persisted (dry-run only) | PASS | post-run: no swblock CRDs, no operator-status ClusterRole on the cluster |
|
||||
|
||||
## Contract Detail
|
||||
|
||||
### CRDs (`charts/seaweed-block/crds/`)
|
||||
|
||||
```text
|
||||
group: block.seaweedfs.com (matches operator-snapshot.json crd_contract.group)
|
||||
scope: Namespaced
|
||||
version: v1alpha1 (served + storage)
|
||||
subresources: status: {}
|
||||
```
|
||||
|
||||
SwBlockVolume status: `status` enum (`ready/recovered/recovering/blocked/...`),
|
||||
`reasonCode`, per-condition `type` (the 6-value vocabulary), `status`, `reason`,
|
||||
`evidenceRefs`. This is the Kubernetes-native projection of the same
|
||||
ManagedVolume model the operator-snapshot already exposes.
|
||||
|
||||
### RBAC (`templates/operator-status-rbac.yaml`)
|
||||
|
||||
```yaml
|
||||
{{- if and .Values.operatorStatus.create .Values.operatorStatus.rbac.create }}
|
||||
resources: ["swblockclusters", "swblockvolumes"] verbs: [get, list, watch]
|
||||
resources: ["swblockclusters/status", "swblockvolumes/status"] verbs: [get, update, patch]
|
||||
resources: ["events"] verbs: [create]
|
||||
```
|
||||
|
||||
The only writes are to the `/status` subresource (status publication) and
|
||||
`events` (event emission). There are NO mutating verbs on storage resources
|
||||
(pods, pvc, deployments) and NO `create/delete` on the CRDs themselves. This is
|
||||
consistent with the read-only operator foundation: a status operator publishes
|
||||
status + events, it does not mutate storage or lifecycle.
|
||||
|
||||
## Non-Claims Held
|
||||
|
||||
D1 adds the CRD shape and status RBAC only. It does NOT install a running
|
||||
controller-manager, does not reconcile, and does not mutate storage. The
|
||||
contract is the same read-only boundary the `operator-snapshot.json` already
|
||||
honors, now expressed as Kubernetes-native CRDs. The CRDs are
|
||||
disabled-by-default and require explicit `operatorStatus.create=true` to render.
|
||||
|
||||
## Lab State
|
||||
|
||||
Clean — the validation was server-side dry-run only; nothing was applied. No
|
||||
swblock CRDs or operator-status RBAC persisted on the cluster.
|
||||
|
||||
## Bottom Line
|
||||
|
||||
- D1 read-only operator CRD contract: **PASS, no findings.**
|
||||
- CRDs are schema-valid (k3s server accepts them), carry status subresource +
|
||||
full condition vocabulary + evidence refs, and the RBAC is read-only with no
|
||||
storage mutation.
|
||||
- Disabled-by-default; opt-in via `operatorStatus.create=true`.
|
||||
- D1 can close. Recommend QA re-validate live status publication (a running
|
||||
status reconciler writing real SwBlockVolume.status) when D2+ wires it — this
|
||||
D1 slice is contract + RBAC shape only, which is correct for the foundation.
|
||||
Reference in new issue
Block a user