From 272b6a1154ffe2204cd1622df043702dcff0a0ef Mon Sep 17 00:00:00 2001 From: pingqiu Date: Thu, 25 Jun 2026 10:43:40 -0700 Subject: [PATCH] phase70: add frontend publication executor boundary --- .../frontend-publication-executor-rbac.yaml | 32 ++++ .../frontend-publication-executor.yaml | 37 +++++ .../charts/seaweed-block/values.yaml | 12 ++ seaweed-block/cmd/sw-block/main.go | 71 ++++++++- seaweed-block/cmd/sw-block/main_test.go | 141 ++++++++++++++-- ...rontend_publication_executor_controller.go | 107 +++++++++++++ ...nd_publication_executor_controller_test.go | 148 +++++++++++++++++ .../core/ops/kubernetes_crd_manifests_test.go | 55 +++++++ .../core/ops/kubernetes_status_writer.go | 4 + .../core/ops/kubernetes_status_writer_test.go | 48 +++++- seaweed-block/internal/docs/current-plan.md | 150 ++++++++---------- ..._frontend_publication_executor_boundary.md | 95 +++++++++++ .../internal/docs/product-roadmap.md | 12 +- ...ublication-executor-boundary-qa-signoff.md | 76 +++++++++ ...tend-publication-executor-boundary-gate.sh | 74 +++++++++ ...d-publication-executor-boundary-chain.yaml | 96 +++++++++++ 16 files changed, 1056 insertions(+), 102 deletions(-) create mode 100644 seaweed-block/charts/seaweed-block/templates/frontend-publication-executor-rbac.yaml create mode 100644 seaweed-block/charts/seaweed-block/templates/frontend-publication-executor.yaml create mode 100644 seaweed-block/core/ops/frontend_publication_executor_controller.go create mode 100644 seaweed-block/core/ops/frontend_publication_executor_controller_test.go create mode 100644 seaweed-block/internal/docs/finished-plans/phase70_finishedplan_frontend_publication_executor_boundary.md create mode 100644 seaweed-block/internal/docs/qa-assignments/phase70-frontend-publication-executor-boundary-qa-signoff.md create mode 100644 seaweed-block/scripts/run-phase70-frontend-publication-executor-boundary-gate.sh create mode 100644 seaweed-block/testops/scenarios/frontend-publication-executor-boundary-chain.yaml diff --git a/seaweed-block/charts/seaweed-block/templates/frontend-publication-executor-rbac.yaml b/seaweed-block/charts/seaweed-block/templates/frontend-publication-executor-rbac.yaml new file mode 100644 index 0000000000..f8251fbeb3 --- /dev/null +++ b/seaweed-block/charts/seaweed-block/templates/frontend-publication-executor-rbac.yaml @@ -0,0 +1,32 @@ +{{- if and .Values.frontendPublicationExecutor.create .Values.frontendPublicationExecutor.rbac.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "seaweed-block.fullname" . }}-frontend-publication-executor + namespace: {{ .Release.Namespace }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "seaweed-block.fullname" . }}-frontend-publication-executor +rules: + - apiGroups: ["block.seaweedfs.com"] + resources: ["swblockfrontendpublications"] + verbs: ["get", "list", "watch"] + - apiGroups: ["block.seaweedfs.com"] + resources: ["swblockfrontendpublications/status"] + verbs: ["get", "update", "patch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "seaweed-block.fullname" . }}-frontend-publication-executor +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "seaweed-block.fullname" . }}-frontend-publication-executor +subjects: + - kind: ServiceAccount + name: {{ include "seaweed-block.fullname" . }}-frontend-publication-executor + namespace: {{ .Release.Namespace }} +{{- end }} diff --git a/seaweed-block/charts/seaweed-block/templates/frontend-publication-executor.yaml b/seaweed-block/charts/seaweed-block/templates/frontend-publication-executor.yaml new file mode 100644 index 0000000000..e28d123882 --- /dev/null +++ b/seaweed-block/charts/seaweed-block/templates/frontend-publication-executor.yaml @@ -0,0 +1,37 @@ +{{- if .Values.frontendPublicationExecutor.create }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sw-block-frontend-publication-executor + namespace: {{ .Release.Namespace }} + labels: + app: sw-block-frontend-publication-executor +spec: + replicas: 1 + selector: + matchLabels: + app: sw-block-frontend-publication-executor + template: + metadata: + labels: + app: sw-block-frontend-publication-executor + spec: + serviceAccountName: {{ include "seaweed-block.fullname" . }}-frontend-publication-executor + {{- with .Values.frontendPublicationExecutor.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + containers: + - name: frontend-publication-executor + image: {{ include "seaweed-block.image" . }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["/usr/local/bin/sw-block"] + args: + - "ops" + - "frontend-publication-executor" + - "--namespace={{ .Release.Namespace }}" + {{- if .Values.frontendPublicationExecutor.dryRun }} + - "--dry-run" + {{- end }} + - "--interval={{ .Values.frontendPublicationExecutor.interval }}" +{{- end }} diff --git a/seaweed-block/charts/seaweed-block/values.yaml b/seaweed-block/charts/seaweed-block/values.yaml index 6c59e373cc..50aeb90aaa 100644 --- a/seaweed-block/charts/seaweed-block/values.yaml +++ b/seaweed-block/charts/seaweed-block/values.yaml @@ -180,6 +180,18 @@ frontendPublicationTargetOwner: create: true nodeSelector: {} +frontendPublicationExecutor: + # Frontend publication executor boundary. Disabled by default. This phase + # writes disabled/blocked SwBlockFrontendPublication.status only. It does not + # publish frontend targets, fail back authority, create targets, or mutate + # storage. + create: false + dryRun: true + interval: 30s + rbac: + create: true + nodeSelector: {} + csiController: replicas: 1 diff --git a/seaweed-block/cmd/sw-block/main.go b/seaweed-block/cmd/sw-block/main.go index 8b51c760e8..397a2523cd 100644 --- a/seaweed-block/cmd/sw-block/main.go +++ b/seaweed-block/cmd/sw-block/main.go @@ -57,6 +57,9 @@ var ( opsFrontendPublicationTargetOwnerClientFactory = func() (ops.FrontendPublicationTargetOwnerClient, error) { return ops.NewInClusterKubernetesStatusClient() } + opsFrontendPublicationExecutorClientFactory = func() (ops.FrontendPublicationExecutorClient, error) { + return ops.NewInClusterKubernetesStatusClient() + } ) func run(args []string, stdout, stderr io.Writer) int { @@ -74,7 +77,7 @@ func run(args []string, stdout, stderr io.Writer) int { return ops.VolumeStatusExitInvalid } if len(args) < 2 { - fmt.Fprintln(stderr, "sw-block: expected subcommand ops status|inventory|list|cluster|volumes|describe|timeline|explain|report|dashboard|generate-helm-values|operator-status|lifecycle-owner|authority-executor|rebuild-target-owner|frontend-publication-target-owner") + fmt.Fprintln(stderr, "sw-block: expected subcommand ops status|inventory|list|cluster|volumes|describe|timeline|explain|report|dashboard|generate-helm-values|operator-status|lifecycle-owner|authority-executor|rebuild-target-owner|frontend-publication-target-owner|frontend-publication-executor") usage(stderr) return ops.VolumeStatusExitInvalid } @@ -109,6 +112,8 @@ func run(args []string, stdout, stderr io.Writer) int { return runOpsRebuildTargetOwner(args[2:], stdout, stderr) case "frontend-publication-target-owner": return runOpsFrontendPublicationTargetOwner(args[2:], stdout, stderr) + case "frontend-publication-executor": + return runOpsFrontendPublicationExecutor(args[2:], stdout, stderr) default: fmt.Fprintf(stderr, "sw-block: unknown ops subcommand %q\n", args[1]) usage(stderr) @@ -116,6 +121,69 @@ func run(args []string, stdout, stderr io.Writer) int { } } +func runOpsFrontendPublicationExecutor(args []string, stdout, stderr io.Writer) int { + fs := flag.NewFlagSet("sw-block ops frontend-publication-executor", flag.ContinueOnError) + fs.SetOutput(stderr) + var ( + dryRun bool + namespace string + interval time.Duration + ) + fs.BoolVar(&dryRun, "dry-run", false, "evaluate frontend publication targets without writing status") + fs.StringVar(&namespace, "namespace", "default", "Kubernetes namespace containing SwBlockFrontendPublication objects") + fs.DurationVar(&interval, "interval", 0, "repeat frontend-publication-executor reconciliation at this interval; 0 runs once") + if err := fs.Parse(args); err != nil { + return ops.VolumeStatusExitInvalid + } + if fs.NArg() != 0 { + fmt.Fprintf(stderr, "sw-block ops frontend-publication-executor: unexpected args %s\n", strings.Join(fs.Args(), " ")) + return ops.VolumeStatusExitInvalid + } + runOnce := func() int { + client, err := opsFrontendPublicationExecutorClientFactory() + if err != nil { + fmt.Fprintf(stderr, "sw-block ops frontend-publication-executor: %v\n", err) + return ops.VolumeStatusExitInvalid + } + result, err := (ops.FrontendPublicationExecutorReconciler{ + Namespace: namespace, + Client: client, + DryRun: dryRun, + }).Reconcile(context.Background()) + if err != nil { + fmt.Fprintf(stderr, "sw-block ops frontend-publication-executor: %v\n", err) + return ops.VolumeStatusExitInvalid + } + mode := "write_status" + if dryRun { + mode = "dry_run" + } + statusMutationAllowed := !dryRun && result.StatusWriteCount > 0 + fmt.Fprintf(stdout, "frontend_publication_executor=%s namespace=%s targets=%d status_writes=%d invalid_targets=%d frontend_publication_attempts=%d failback_attempts=%d status_mutation_allowed=%t frontend_publication_mutation_allowed=false mutation_allowed=%t storage_mutation_allowed=%t\n", + mode, + namespace, + result.TargetCount, + result.StatusWriteCount, + result.InvalidTargetCount, + result.FrontendPublicationAttempts, + result.FailbackAttempts, + statusMutationAllowed, + statusMutationAllowed, + result.StorageMutationAllowed) + return ops.VolumeStatusExitOK + } + if interval <= 0 { + return runOnce() + } + for { + code := runOnce() + if code != ops.VolumeStatusExitOK { + fmt.Fprintf(stderr, "sw-block ops frontend-publication-executor: iteration failed exit=%d; retrying in %s\n", code, interval) + } + time.Sleep(interval) + } +} + func runOpsFrontendPublicationTargetOwner(args []string, stdout, stderr io.Writer) int { fs := flag.NewFlagSet("sw-block ops frontend-publication-target-owner", flag.ContinueOnError) fs.SetOutput(stderr) @@ -1868,6 +1936,7 @@ func usage(w io.Writer) { fmt.Fprintln(w, " sw-block ops authority-executor [--namespace ] [--allowed-mutation-class ack_eligibility|rebuild_traffic] [--interval 30s]") fmt.Fprintln(w, " sw-block ops rebuild-target-owner [--dry-run] [--namespace ] [--interval 30s]") fmt.Fprintln(w, " sw-block ops frontend-publication-target-owner [--dry-run] [--namespace ] [--interval 30s]") + fmt.Fprintln(w, " sw-block ops frontend-publication-executor [--dry-run] [--namespace ] [--interval 30s]") } func emptyCLI(value string) string { diff --git a/seaweed-block/cmd/sw-block/main_test.go b/seaweed-block/cmd/sw-block/main_test.go index 7d86402aa4..90b58a203a 100644 --- a/seaweed-block/cmd/sw-block/main_test.go +++ b/seaweed-block/cmd/sw-block/main_test.go @@ -1139,6 +1139,89 @@ func TestOpsFrontendPublicationTargetOwnerDryRunDoesNotCreateTarget(t *testing.T } } +func TestOpsFrontendPublicationExecutorWritesDisabledStatus(t *testing.T) { + client := &lifecycleOwnerTestClient{ + frontendTargets: []ops.SwBlockFrontendPublicationObject{cmdFrontendPublicationTarget()}, + } + oldFactory := opsFrontendPublicationExecutorClientFactory + opsFrontendPublicationExecutorClientFactory = func() (ops.FrontendPublicationExecutorClient, error) { + return client, nil + } + t.Cleanup(func() { opsFrontendPublicationExecutorClientFactory = oldFactory }) + + var stdout, stderr bytes.Buffer + code := run([]string{"ops", "frontend-publication-executor", "--namespace", "kube-system"}, &stdout, &stderr) + if code != ops.VolumeStatusExitOK { + t.Fatalf("exit=%d stderr=%s stdout=%s", code, stderr.String(), stdout.String()) + } + if len(client.frontendPublicationStatusWrites) != 1 { + t.Fatalf("frontendPublicationStatusWrites=%+v", client.frontendPublicationStatusWrites) + } + status := client.frontendPublicationStatusWrites[0].status + if status.State != ops.FrontendPublicationStateBlocked || + status.ReasonCode != ops.AuthorityExecutorFrontendPublicationReasonDisabled || + status.PublicationMutationAllowed || + status.FrontendPublished || + status.FailbackStarted || + !status.NoStorageMutation { + t.Fatalf("status=%+v", status) + } + out := stdout.String() + for _, want := range []string{ + "frontend_publication_executor=write_status", + "namespace=kube-system", + "targets=1", + "status_writes=1", + "invalid_targets=0", + "frontend_publication_attempts=0", + "failback_attempts=0", + "status_mutation_allowed=true", + "frontend_publication_mutation_allowed=false", + "mutation_allowed=true", + "storage_mutation_allowed=false", + } { + if !strings.Contains(out, want) { + t.Fatalf("stdout missing %q:\n%s", want, out) + } + } +} + +func TestOpsFrontendPublicationExecutorDryRunDoesNotWriteStatus(t *testing.T) { + client := &lifecycleOwnerTestClient{ + frontendTargets: []ops.SwBlockFrontendPublicationObject{cmdFrontendPublicationTarget()}, + } + oldFactory := opsFrontendPublicationExecutorClientFactory + opsFrontendPublicationExecutorClientFactory = func() (ops.FrontendPublicationExecutorClient, error) { + return client, nil + } + t.Cleanup(func() { opsFrontendPublicationExecutorClientFactory = oldFactory }) + + var stdout, stderr bytes.Buffer + code := run([]string{"ops", "frontend-publication-executor", "--dry-run", "--namespace", "kube-system"}, &stdout, &stderr) + if code != ops.VolumeStatusExitOK { + t.Fatalf("exit=%d stderr=%s stdout=%s", code, stderr.String(), stdout.String()) + } + if len(client.frontendPublicationStatusWrites) != 0 { + t.Fatalf("dry-run writes=%+v", client.frontendPublicationStatusWrites) + } + out := stdout.String() + for _, want := range []string{ + "frontend_publication_executor=dry_run", + "targets=1", + "status_writes=0", + "frontend_publication_attempts=0", + "failback_attempts=0", + "status_mutation_allowed=false", + "frontend_publication_mutation_allowed=false", + "mutation_allowed=false", + "storage_mutation_allowed=false", + } { + if !strings.Contains(out, want) { + t.Fatalf("stdout missing %q:\n%s", want, out) + } + } +} + func TestOpsAuthorityExecutorExecutionPolicyBlocksWhenAckTargetMissing(t *testing.T) { client := &lifecycleOwnerTestClient{ volumes: []ops.SwBlockVolumeObject{{ @@ -1525,6 +1608,33 @@ func cmdFrontendPublicationEligibility() ops.SwBlockReplicaEligibilityObject { } } +func cmdFrontendPublicationTarget() ops.SwBlockFrontendPublicationObject { + return ops.SwBlockFrontendPublicationObject{ + Ref: ops.OperatorObjectRef{ + APIVersion: ops.SwBlockVolumeAPIVersion, + Kind: ops.SwBlockFrontendPublicationKind, + Namespace: "kube-system", + Name: "demo-pvc-r2-frontend-publication", + }, + Spec: ops.SwBlockFrontendPublicationSpec{ + VolumeName: "demo-pvc", + VolumeID: "pvc-demo", + PVCName: "demo-pvc", + ReplicaID: "r2", + SourceEligibilityName: "demo-pvc-r2-ack", + AckEligibilityKnown: true, + AckEligible: true, + FrontendFencedAfterExecution: true, + PrimaryUnchanged: true, + DurableFrontierCovered: true, + NoCrossVolumeIdentityChange: true, + FrontendPublicationDecision: ops.AuthorityExecutorPublicationDecisionDisabled, + FrontendPublicationReason: ops.AuthorityExecutorFrontendPublicationReasonDisabled, + FrontendPublicationMutationAllowed: false, + }, + } +} + func (w *operatorStatusTestWriter) WriteClusterStatus(_ context.Context, _ ops.OperatorObjectRef, status ops.SwBlockClusterCRDStatus) error { w.cluster = status return nil @@ -1536,16 +1646,17 @@ func (w *operatorStatusTestWriter) WriteVolumeStatus(_ context.Context, ref ops. } type lifecycleOwnerTestClient struct { - volumes []ops.SwBlockVolumeObject - eligibilities []ops.SwBlockReplicaEligibilityObject - rebuilds []ops.SwBlockReplicaRebuildObject - frontendTargets []ops.SwBlockFrontendPublicationObject - patches []lifecycleOwnerTestPatch - events []ops.OperatorKubernetesEvent - eligibilityWrites []lifecycleOwnerTestEligibilityWrite - rebuildWrites []lifecycleOwnerTestRebuildWrite - rebuildCreates []ops.SwBlockReplicaRebuildObject - frontendPublicationCreates []ops.SwBlockFrontendPublicationObject + volumes []ops.SwBlockVolumeObject + eligibilities []ops.SwBlockReplicaEligibilityObject + rebuilds []ops.SwBlockReplicaRebuildObject + frontendTargets []ops.SwBlockFrontendPublicationObject + patches []lifecycleOwnerTestPatch + events []ops.OperatorKubernetesEvent + eligibilityWrites []lifecycleOwnerTestEligibilityWrite + rebuildWrites []lifecycleOwnerTestRebuildWrite + rebuildCreates []ops.SwBlockReplicaRebuildObject + frontendPublicationCreates []ops.SwBlockFrontendPublicationObject + frontendPublicationStatusWrites []lifecycleOwnerTestFrontendPublicationWrite } type lifecycleOwnerTestPatch struct { @@ -1563,6 +1674,11 @@ type lifecycleOwnerTestRebuildWrite struct { status ops.SwBlockReplicaRebuildCRDStatus } +type lifecycleOwnerTestFrontendPublicationWrite struct { + ref ops.OperatorObjectRef + status ops.SwBlockFrontendPublicationCRDStatus +} + func (c *lifecycleOwnerTestClient) ListSwBlockVolumes(_ context.Context, _ string) ([]ops.SwBlockVolumeObject, error) { return append([]ops.SwBlockVolumeObject(nil), c.volumes...), nil } @@ -1589,6 +1705,11 @@ func (c *lifecycleOwnerTestClient) WriteReplicaRebuildStatus(_ context.Context, return nil } +func (c *lifecycleOwnerTestClient) WriteFrontendPublicationStatus(_ context.Context, ref ops.OperatorObjectRef, status ops.SwBlockFrontendPublicationCRDStatus) error { + c.frontendPublicationStatusWrites = append(c.frontendPublicationStatusWrites, lifecycleOwnerTestFrontendPublicationWrite{ref: ref, status: status}) + return nil +} + func (c *lifecycleOwnerTestClient) CreateSwBlockReplicaRebuild(_ context.Context, _ string, obj ops.SwBlockReplicaRebuildObject) error { c.rebuildCreates = append(c.rebuildCreates, obj) return nil diff --git a/seaweed-block/core/ops/frontend_publication_executor_controller.go b/seaweed-block/core/ops/frontend_publication_executor_controller.go new file mode 100644 index 0000000000..d00222a451 --- /dev/null +++ b/seaweed-block/core/ops/frontend_publication_executor_controller.go @@ -0,0 +1,107 @@ +package ops + +import ( + "context" + "fmt" + "time" +) + +const ( + FrontendPublicationStateBlocked = "blocked" +) + +type FrontendPublicationExecutorClient interface { + ListSwBlockFrontendPublications(ctx context.Context, namespace string) ([]SwBlockFrontendPublicationObject, error) + WriteFrontendPublicationStatus(ctx context.Context, ref OperatorObjectRef, status SwBlockFrontendPublicationCRDStatus) error +} + +type FrontendPublicationExecutorReconciler struct { + Namespace string + Client FrontendPublicationExecutorClient + DryRun bool + Now func() time.Time +} + +type FrontendPublicationExecutorReconcileResult struct { + TargetCount int `json:"targetCount"` + StatusWriteCount int `json:"statusWriteCount"` + InvalidTargetCount int `json:"invalidTargetCount"` + FrontendPublicationAttempts int `json:"frontendPublicationAttempts"` + FailbackAttempts int `json:"failbackAttempts"` + StorageMutationAllowed bool `json:"storageMutationAllowed"` +} + +func (r FrontendPublicationExecutorReconciler) Reconcile(ctx context.Context) (FrontendPublicationExecutorReconcileResult, error) { + if r.Client == nil { + return FrontendPublicationExecutorReconcileResult{}, fmt.Errorf("frontend publication executor client is required") + } + namespace := defaultString(r.Namespace, "default") + targets, err := r.Client.ListSwBlockFrontendPublications(ctx, namespace) + if err != nil { + return FrontendPublicationExecutorReconcileResult{}, err + } + result := FrontendPublicationExecutorReconcileResult{TargetCount: len(targets)} + for _, target := range targets { + status := frontendPublicationExecutorDisabledStatus(r.now()(), target) + if !frontendPublicationExecutorTargetValid(target) { + result.InvalidTargetCount++ + status.ReasonCode = "missing_required_facts" + } + if r.DryRun { + continue + } + if err := r.Client.WriteFrontendPublicationStatus(ctx, target.Ref, status); err != nil { + return result, err + } + result.StatusWriteCount++ + } + return result, nil +} + +func frontendPublicationExecutorTargetValid(target SwBlockFrontendPublicationObject) bool { + spec := target.Spec + return spec.VolumeName != "" && + spec.ReplicaID != "" && + spec.AckEligibilityKnown && + spec.AckEligible && + spec.FrontendFencedAfterExecution && + spec.PrimaryUnchanged && + spec.DurableFrontierCovered && + spec.NoCrossVolumeIdentityChange && + spec.FrontendPublicationDecision == AuthorityExecutorPublicationDecisionDisabled && + spec.FrontendPublicationReason == AuthorityExecutorFrontendPublicationReasonDisabled && + !spec.FrontendPublicationMutationAllowed +} + +func frontendPublicationExecutorDisabledStatus(now time.Time, target SwBlockFrontendPublicationObject) SwBlockFrontendPublicationCRDStatus { + return SwBlockFrontendPublicationCRDStatus{ + ObservedAt: now, + Executor: "frontend-publication-executor", + State: FrontendPublicationStateBlocked, + ReasonCode: AuthorityExecutorFrontendPublicationReasonDisabled, + PublicationMutationAllowed: false, + FrontendPublished: false, + FailbackStarted: false, + NoStorageMutation: true, + NoCrossVolumeIdentityChange: target.Spec.NoCrossVolumeIdentityChange, + Conditions: []ObservationCondition{{ + Type: ConditionBlocked, + Status: "True", + Reason: AuthorityExecutorFrontendPublicationReasonDisabled, + Severity: "warning", + Message: "frontend publication executor is disabled by product policy", + }}, + NonClaims: []string{ + "no_frontend_publication", + "no_failback", + "no_storage_mutation", + }, + } +} + +func (r FrontendPublicationExecutorReconciler) now() func() time.Time { + if r.Now != nil { + return r.Now + } + return time.Now +} diff --git a/seaweed-block/core/ops/frontend_publication_executor_controller_test.go b/seaweed-block/core/ops/frontend_publication_executor_controller_test.go new file mode 100644 index 0000000000..03fb021036 --- /dev/null +++ b/seaweed-block/core/ops/frontend_publication_executor_controller_test.go @@ -0,0 +1,148 @@ +package ops + +import ( + "context" + "testing" + "time" +) + +func TestFrontendPublicationExecutorWritesDisabledStatus(t *testing.T) { + client := &fakeFrontendPublicationExecutorClient{ + targets: []SwBlockFrontendPublicationObject{frontendPublicationExecutorTestTarget()}, + } + result, err := (FrontendPublicationExecutorReconciler{ + Namespace: "kube-system", + Client: client, + Now: func() time.Time { return time.Date(2026, 6, 25, 11, 0, 0, 0, time.UTC) }, + }).Reconcile(context.Background()) + if err != nil { + t.Fatalf("reconcile: %v", err) + } + if result.TargetCount != 1 || + result.StatusWriteCount != 1 || + result.InvalidTargetCount != 0 || + result.FrontendPublicationAttempts != 0 || + result.FailbackAttempts != 0 || + result.StorageMutationAllowed { + t.Fatalf("result=%+v", result) + } + if len(client.writes) != 1 { + t.Fatalf("writes=%+v", client.writes) + } + write := client.writes[0] + if write.status.State != FrontendPublicationStateBlocked || + write.status.ReasonCode != AuthorityExecutorFrontendPublicationReasonDisabled || + write.status.PublicationMutationAllowed || + write.status.FrontendPublished || + write.status.FailbackStarted || + !write.status.NoStorageMutation || + !write.status.NoCrossVolumeIdentityChange { + t.Fatalf("status=%+v", write.status) + } + if len(write.status.Conditions) != 1 || + write.status.Conditions[0].Type != ConditionBlocked || + write.status.Conditions[0].Status != "True" { + t.Fatalf("conditions=%+v", write.status.Conditions) + } + for _, want := range []string{"no_frontend_publication", "no_failback", "no_storage_mutation"} { + if !frontendPublicationExecutorStringSliceContains(write.status.NonClaims, want) { + t.Fatalf("nonClaims=%+v missing %s", write.status.NonClaims, want) + } + } +} + +func TestFrontendPublicationExecutorDryRunDoesNotWriteStatus(t *testing.T) { + client := &fakeFrontendPublicationExecutorClient{ + targets: []SwBlockFrontendPublicationObject{frontendPublicationExecutorTestTarget()}, + } + result, err := (FrontendPublicationExecutorReconciler{ + Namespace: "kube-system", + Client: client, + DryRun: true, + }).Reconcile(context.Background()) + if err != nil { + t.Fatalf("reconcile: %v", err) + } + if result.TargetCount != 1 || result.StatusWriteCount != 0 { + t.Fatalf("result=%+v", result) + } + if len(client.writes) != 0 { + t.Fatalf("dry-run wrote status: %+v", client.writes) + } +} + +func TestFrontendPublicationExecutorMarksInvalidTargets(t *testing.T) { + target := frontendPublicationExecutorTestTarget() + target.Spec.FrontendPublicationMutationAllowed = true + client := &fakeFrontendPublicationExecutorClient{ + targets: []SwBlockFrontendPublicationObject{target}, + } + result, err := (FrontendPublicationExecutorReconciler{ + Namespace: "kube-system", + Client: client, + }).Reconcile(context.Background()) + if err != nil { + t.Fatalf("reconcile: %v", err) + } + if result.InvalidTargetCount != 1 || result.StatusWriteCount != 1 { + t.Fatalf("result=%+v", result) + } + if got := client.writes[0].status.ReasonCode; got != "missing_required_facts" { + t.Fatalf("reason=%s", got) + } +} + +func frontendPublicationExecutorTestTarget() SwBlockFrontendPublicationObject { + return SwBlockFrontendPublicationObject{ + Ref: OperatorObjectRef{ + APIVersion: SwBlockVolumeAPIVersion, + Kind: SwBlockFrontendPublicationKind, + Namespace: "kube-system", + Name: "demo-pvc-r2-frontend-publication", + }, + Spec: SwBlockFrontendPublicationSpec{ + VolumeName: "demo-pvc", + VolumeID: "pvc-demo", + PVCName: "demo-pvc", + ReplicaID: "r2", + SourceEligibilityName: "demo-pvc-r2-ack", + AckEligibilityKnown: true, + AckEligible: true, + FrontendFencedAfterExecution: true, + PrimaryUnchanged: true, + DurableFrontierCovered: true, + NoCrossVolumeIdentityChange: true, + FrontendPublicationDecision: AuthorityExecutorPublicationDecisionDisabled, + FrontendPublicationReason: AuthorityExecutorFrontendPublicationReasonDisabled, + FrontendPublicationMutationAllowed: false, + }, + } +} + +type fakeFrontendPublicationExecutorClient struct { + targets []SwBlockFrontendPublicationObject + writes []fakeFrontendPublicationStatusWrite +} + +type fakeFrontendPublicationStatusWrite struct { + ref OperatorObjectRef + status SwBlockFrontendPublicationCRDStatus +} + +func (f *fakeFrontendPublicationExecutorClient) ListSwBlockFrontendPublications(context.Context, string) ([]SwBlockFrontendPublicationObject, error) { + return append([]SwBlockFrontendPublicationObject(nil), f.targets...), nil +} + +func (f *fakeFrontendPublicationExecutorClient) WriteFrontendPublicationStatus(_ context.Context, ref OperatorObjectRef, status SwBlockFrontendPublicationCRDStatus) error { + f.writes = append(f.writes, fakeFrontendPublicationStatusWrite{ref: ref, status: status}) + return nil +} + +func frontendPublicationExecutorStringSliceContains(values []string, want string) bool { + for _, value := range values { + if value == want { + return true + } + } + return false +} diff --git a/seaweed-block/core/ops/kubernetes_crd_manifests_test.go b/seaweed-block/core/ops/kubernetes_crd_manifests_test.go index 624d31918c..6f2b51f840 100644 --- a/seaweed-block/core/ops/kubernetes_crd_manifests_test.go +++ b/seaweed-block/core/ops/kubernetes_crd_manifests_test.go @@ -813,6 +813,61 @@ func TestPhase69FrontendPublicationTargetOwnerPackagingIsNarrow(t *testing.T) { } } +func TestPhase70FrontendPublicationExecutorPackagingIsStatusOnly(t *testing.T) { + values := readYAMLMap(t, "charts/seaweed-block/values.yaml") + executor := yamlMap(t, values, "frontendPublicationExecutor") + assertYAMLBool(t, executor, "create", false) + assertYAMLBool(t, executor, "dryRun", true) + rbacValues := yamlMap(t, executor, "rbac") + assertYAMLBool(t, rbacValues, "create", true) + + deploy := readRepoFile(t, "charts/seaweed-block/templates/frontend-publication-executor.yaml") + for _, want := range []string{ + `kind: Deployment`, + `name: sw-block-frontend-publication-executor`, + `serviceAccountName: {{ include "seaweed-block.fullname" . }}-frontend-publication-executor`, + `command: ["/usr/local/bin/sw-block"]`, + `- "frontend-publication-executor"`, + `- "--namespace={{ .Release.Namespace }}"`, + `{{- if .Values.frontendPublicationExecutor.dryRun }}`, + `- "--dry-run"`, + `- "--interval={{ .Values.frontendPublicationExecutor.interval }}"`, + } { + if !strings.Contains(deploy, want) { + t.Fatalf("frontend-publication-executor deployment missing %q\n%s", want, deploy) + } + } + + rbac := readRepoFile(t, "charts/seaweed-block/templates/frontend-publication-executor-rbac.yaml") + for _, want := range []string{ + `resources: ["swblockfrontendpublications"]`, + `verbs: ["get", "list", "watch"]`, + `resources: ["swblockfrontendpublications/status"]`, + `verbs: ["get", "update", "patch"]`, + } { + if !strings.Contains(rbac, want) { + t.Fatalf("frontend-publication-executor RBAC missing %q\n%s", want, rbac) + } + } + for _, forbidden := range []string{ + `resources: ["swblockvolumes"]`, + `resources: ["swblockreplicaeligibilities"]`, + `resources: ["swblockfrontendpublications/finalizers"]`, + `resources: ["events"]`, + `resources: ["pods"]`, + `resources: ["persistentvolumes"]`, + `resources: ["persistentvolumeclaims"]`, + `resources: ["storageclasses"]`, + `resources: ["secrets"]`, + `"create"`, + `"delete"`, + } { + if strings.Contains(rbac, forbidden) { + t.Fatalf("frontend-publication-executor RBAC contains forbidden fragment %q\n%s", forbidden, rbac) + } + } +} + func readRepoFile(t *testing.T, repoPath string) string { t.Helper() raw, err := os.ReadFile(filepath.Join("..", "..", filepath.FromSlash(repoPath))) diff --git a/seaweed-block/core/ops/kubernetes_status_writer.go b/seaweed-block/core/ops/kubernetes_status_writer.go index bf7805391c..76cd640c73 100644 --- a/seaweed-block/core/ops/kubernetes_status_writer.go +++ b/seaweed-block/core/ops/kubernetes_status_writer.go @@ -77,6 +77,10 @@ func (c *KubernetesStatusClient) WriteReplicaRebuildStatus(ctx context.Context, return c.patchStatus(ctx, ref.Namespace, SwBlockReplicaRebuildPlural, ref.Name, status) } +func (c *KubernetesStatusClient) WriteFrontendPublicationStatus(ctx context.Context, ref OperatorObjectRef, status SwBlockFrontendPublicationCRDStatus) error { + return c.patchStatus(ctx, ref.Namespace, SwBlockFrontendPublicationPlural, ref.Name, status) +} + func IsKubernetesStatusNotFound(err error) bool { return err != nil && strings.Contains(err.Error(), "http 404") } diff --git a/seaweed-block/core/ops/kubernetes_status_writer_test.go b/seaweed-block/core/ops/kubernetes_status_writer_test.go index a765d38472..acdaa173c8 100644 --- a/seaweed-block/core/ops/kubernetes_status_writer_test.go +++ b/seaweed-block/core/ops/kubernetes_status_writer_test.go @@ -178,15 +178,36 @@ func TestKubernetesStatusClientPatchesOnlyStatusSubresources(t *testing.T) { }); err != nil { t.Fatalf("write replica rebuild status: %v", err) } + if err := client.WriteFrontendPublicationStatus(context.Background(), OperatorObjectRef{ + Namespace: "kube-system", + Name: "demo-pvc-r1-frontend-publication", + }, SwBlockFrontendPublicationCRDStatus{ + ObservedAt: observedAt, + ObservedGeneration: 9, + Executor: "frontend-publication-executor", + State: FrontendPublicationStateBlocked, + ReasonCode: AuthorityExecutorFrontendPublicationReasonDisabled, + PublicationMutationAllowed: false, + FrontendPublished: false, + FailbackStarted: false, + NoStorageMutation: true, + NoCrossVolumeIdentityChange: true, + EvidenceGeneration: "executor-run-3", + EvidenceRefs: []string{"frontend-publication-summary.txt"}, + NonClaims: []string{"no_frontend_publication", "no_failback", "no_storage_mutation"}, + }); err != nil { + t.Fatalf("write frontend publication status: %v", err) + } - if len(requests) != 4 { - t.Fatalf("requests=%d want 4: %+v", len(requests), requests) + if len(requests) != 5 { + t.Fatalf("requests=%d want 5: %+v", len(requests), requests) } wantPaths := []string{ "/apis/block.seaweedfs.com/v1alpha1/namespaces/kube-system/swblockclusters/sw-block/status", "/apis/block.seaweedfs.com/v1alpha1/namespaces/kube-system/swblockvolumes/demo-pvc/status", "/apis/block.seaweedfs.com/v1alpha1/namespaces/kube-system/swblockreplicaeligibilities/demo-pvc-r1/status", "/apis/block.seaweedfs.com/v1alpha1/namespaces/kube-system/swblockreplicarebuilds/demo-pvc-r1-rebuild/status", + "/apis/block.seaweedfs.com/v1alpha1/namespaces/kube-system/swblockfrontendpublications/demo-pvc-r1-frontend-publication/status", } for i, req := range requests { if req.Method != http.MethodPatch { @@ -324,6 +345,29 @@ func TestKubernetesStatusClientPatchesOnlyStatusSubresources(t *testing.T) { t.Fatalf("replica rebuild status leaked %s: %+v", forbidden, replicaRebuildStatus) } } + frontendPublicationStatus := requests[4].Body["status"].(map[string]any) + for _, want := range []string{ + "publicationMutationAllowed", + "frontendPublished", + "failbackStarted", + "noStorageMutation", + "noCrossVolumeIdentityChange", + "evidenceGeneration", + } { + if _, ok := frontendPublicationStatus[want]; !ok { + t.Fatalf("frontend publication status missing camelCase %s: %+v", want, frontendPublicationStatus) + } + } + for _, forbidden := range []string{"publication_mutation_allowed", "frontend_published", "failback_started", "no_storage_mutation", "spec"} { + if _, ok := frontendPublicationStatus[forbidden]; ok { + t.Fatalf("frontend publication status leaked %s: %+v", forbidden, frontendPublicationStatus) + } + } + if frontendPublicationStatus["frontendPublished"] != false || + frontendPublicationStatus["failbackStarted"] != false || + frontendPublicationStatus["noStorageMutation"] != true { + t.Fatalf("frontend publication status=%+v", frontendPublicationStatus) + } } func TestKubernetesStatusClientCreatesCoreEvents(t *testing.T) { diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index 20cb6b61e4..540aa5a510 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,129 +1,111 @@ -# Current Plan: Phase 69 Frontend Publication Target Contract +# Current Plan: Phase 70 Frontend Publication Executor Boundary Status: complete. ## Goal -Phase 68 added the frontend publication preflight to ACK eligibility status and -kept it explicitly disabled: - -```text -frontendPublicationDecision=disabled -frontendPublicationReason=frontend_publication_policy_disabled -frontendPublicationMutationAllowed=false -``` - -Phase 69 defines the next target object without executing the next mutation. -It introduces a narrow `SwBlockFrontendPublication` target CR and a disabled-by -default `frontend-publication-target-owner` that can create target CRs only -when terminal ACK eligibility evidence is present. - -This phase still does not publish frontend paths, change primary authority, -fail back, or mutate storage. - -## Delivered - -### D1: Target CRD - -Added: +Phase 69 introduced the typed frontend publication target: ```text SwBlockFrontendPublication -plural: swblockfrontendpublications ``` -The spec carries the evidence copied from -`SwBlockReplicaEligibility.status`: +Phase 70 adds the executor boundary for that target without performing frontend +publication. The executor can only write `SwBlockFrontendPublication.status` +with a disabled/blocked result. + +This keeps the operation model layered: ```text -volumeName -volumeID -pvcName -replicaID -sourceEligibilityName -ackEligibilityKnown -ackEligible -frontendFencedAfterExecution -primaryUnchanged -durableFrontierCovered -noCrossVolumeIdentityChange -frontendPublicationDecision -frontendPublicationReason -frontendPublicationMutationAllowed +ACK eligibility -> frontend publication target -> frontend publication executor status ``` -The schema deliberately does not include publish target, authority epoch, -failback execution, or storage mutation fields. +The real frontend publish mutation and failback remain outside this phase. -### D2: Target Owner +## Delivered + +### D1: Executor Reconciler Added: ```text -sw-block ops frontend-publication-target-owner +FrontendPublicationExecutorReconciler +sw-block ops frontend-publication-executor ``` -It creates `SwBlockFrontendPublication` target CRs only when the source -eligibility shows: +For each `SwBlockFrontendPublication` target, the executor writes: ```text -ackEligibilityKnown=true -ackEligible=true -frontendFencedAfterExecution=true -primaryUnchanged=true -durableFrontierCovered=true -noCrossVolumeIdentityChange=true -frontendPublicationDecision=disabled -frontendPublicationReason=frontend_publication_policy_disabled -frontendPublicationMutationAllowed=false +state=blocked +reasonCode=frontend_publication_policy_disabled +publicationMutationAllowed=false +frontendPublished=false +failbackStarted=false +noStorageMutation=true ``` -Dry-run mode plans targets without creating them. +Invalid targets are also blocked rather than executed. + +### D2: Kubernetes Status Writer + +`KubernetesStatusClient` now supports: + +```text +WriteFrontendPublicationStatus +``` + +It patches only: + +```text +/apis/block.seaweedfs.com/v1alpha1/namespaces//swblockfrontendpublications//status +``` + +The writer test verifies camelCase status payloads and forbids spec patches. ### D3: Packaging And RBAC Added disabled-by-default Helm packaging: ```text -frontendPublicationTargetOwner.create=false -frontendPublicationTargetOwner.dryRun=true +frontendPublicationExecutor.create=false +frontendPublicationExecutor.dryRun=true ``` RBAC permits only: ```text -get/list/watch swblockreplicaeligibilities -get/list/watch/create swblockfrontendpublications +get/list/watch swblockfrontendpublications +get/update/patch swblockfrontendpublications/status ``` -It does not grant status, finalizer, Event, workload, PVC/PV, -StorageClass, Secret, or delete permissions. +It does not grant target create, spec patch, finalizer, Event, workload, +PVC/PV, StorageClass, Secret, or delete permissions. ### D4: Gate Gate files: ```text -scripts/run-phase69-frontend-publication-target-contract-gate.sh -testops/scenarios/frontend-publication-target-contract-chain.yaml +scripts/run-phase70-frontend-publication-executor-boundary-gate.sh +testops/scenarios/frontend-publication-executor-boundary-chain.yaml ``` The gate proves: ```text -frontend publication target schema locked -target-owner creates exactly the target CR when eligibility is terminal -dry-run does not create -enabled/mutating frontend publication evidence is rejected -RBAC remains narrow +frontend publication executor status writes are wired +status is blocked / frontend_publication_policy_disabled +frontendPublished=false +failbackStarted=false frontend publication attempts remain 0 failback attempts remain 0 storage mutation remains false +RBAC is status-only ``` ## Non-Claims -Phase 69 does not claim: +Phase 70 does not claim: ```text frontend publication execution @@ -140,38 +122,38 @@ Local: ```text go test ./core/ops ./core/transport ./core/replication ./core/host/volume ./cmd/blockvolume ./cmd/sw-block -C:\work\swblock.exe validate testops\scenarios\frontend-publication-target-contract-chain.yaml +C:\work\swblock.exe validate testops\scenarios\frontend-publication-executor-boundary-chain.yaml ``` Live runner: ```text -20260625-102857-00c9 frontend-publication-target-contract-chain PASS 18/18 +20260625-104138-40b7 frontend-publication-executor-boundary-chain PASS 18/18 ``` Terminal evidence: ```text -phase69_frontend_publication_target_contract_status=ok -frontend_publication_target_schema_locked=true -frontend_publication_target_owner_creates_target=true -frontend_publication_target_owner_dry_run_no_create=true -frontend_publication_target_owner_rejects_enabled_publication=true -frontend_publication_target_owner_rbac_narrow=true +phase70_frontend_publication_executor_boundary_status=ok +frontend_publication_executor_status_writes=true +frontend_publication_executor_status=blocked +frontend_publication_executor_reason=frontend_publication_policy_disabled +frontend_publication_executor_rbac_status_only=true frontend_publication_attempts=0 +frontend_published=false failback_attempts=0 +failback_started=false storage_mutation_allowed=false ``` ## Next -Phase 70 should add the real frontend publication executor boundary before any -failback semantics: +Phase 71 should be the first real frontend publication mutation gate if we want +to continue this operation line before NVMe: ```text -frontend publication executor status/admission/RBAC gate +frontend publication execution under admission/RBAC + multi-volume isolation ``` -That next phase may be allowed to update only a bounded frontend publication -target status or a narrowly admitted frontend target field, but it must still -not claim failback until frontend publication is real-API-proven and isolated. +It must still avoid broad failback semantics until frontend publication itself +is proven. diff --git a/seaweed-block/internal/docs/finished-plans/phase70_finishedplan_frontend_publication_executor_boundary.md b/seaweed-block/internal/docs/finished-plans/phase70_finishedplan_frontend_publication_executor_boundary.md new file mode 100644 index 0000000000..609f461730 --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase70_finishedplan_frontend_publication_executor_boundary.md @@ -0,0 +1,95 @@ +# Phase 70 Finished Plan: Frontend Publication Executor Boundary + +Status: complete. + +## Problem + +Phase 69 created the typed frontend publication target object, but no executor +owned that object yet. The next safe step is not to publish frontend targets; it +is to prove the executor's Kubernetes boundary first. + +Without this layer, a future real publication implementation would have to add +business logic, RBAC, status, and mutation behavior at the same time. That is +exactly the kind of operation-layer shortcut that caused earlier live-only +CRD/RBAC bugs. + +## Implementation + +Phase 70 adds: + +```text +FrontendPublicationExecutorReconciler +sw-block ops frontend-publication-executor +frontendPublicationExecutor Helm packaging +``` + +The executor reads `SwBlockFrontendPublication` targets and writes status: + +```text +state=blocked +reasonCode=frontend_publication_policy_disabled +publicationMutationAllowed=false +frontendPublished=false +failbackStarted=false +noStorageMutation=true +``` + +Invalid targets are blocked with `missing_required_facts`; they are never +executed. + +## Safety Boundary + +The executor only writes: + +```text +swblockfrontendpublications/status +``` + +It does not write: + +```text +SwBlockFrontendPublication spec +SwBlockFrontendPublication finalizers +SwBlockFrontendPublication create/delete +SwBlockVolume +SwBlockReplicaEligibility +Events +Pods/PVCs/PVs/StorageClasses +host storage state +``` + +## Verification + +Local: + +```text +go test ./core/ops ./core/transport ./core/replication ./core/host/volume ./cmd/blockvolume ./cmd/sw-block +C:\work\swblock.exe validate testops\scenarios\frontend-publication-executor-boundary-chain.yaml +``` + +Runner gate: + +```text +20260625-104138-40b7 frontend-publication-executor-boundary-chain PASS 18/18 +``` + +Key evidence: + +```text +phase70_frontend_publication_executor_boundary_status=ok +frontend_publication_executor_status_writes=true +frontend_publication_executor_status=blocked +frontend_publication_executor_reason=frontend_publication_policy_disabled +frontend_publication_executor_rbac_status_only=true +frontend_publication_attempts=0 +frontend_published=false +failback_attempts=0 +failback_started=false +storage_mutation_allowed=false +``` + +## Next + +Phase 71 can attempt the first real frontend publication mutation only after +the admission/RBAC envelope is made explicit and tested live. Failback remains +separate. diff --git a/seaweed-block/internal/docs/product-roadmap.md b/seaweed-block/internal/docs/product-roadmap.md index f7ff140425..bca18cf11c 100644 --- a/seaweed-block/internal/docs/product-roadmap.md +++ b/seaweed-block/internal/docs/product-roadmap.md @@ -58,13 +58,14 @@ This is the short internal roadmap. Keep it current and readable. agreement. This remains read-only and does not add mutating operator lifecycle. - Current development slice: returned-replica rebuild/reintegration runtime - productization has advanced through Phase 69. Phases 46-54 made returned + productization has advanced through Phase 70. Phases 46-54 made returned replicas visible and action-gated, Phases 60-67 connected the bounded rebuild/catch-up runtime path through target facts, executor HTTP transport, an opt-in blockvolume runtime start endpoint, terminal caught-up evidence, and ACK eligibility publication. Phase 68 added the disabled frontend publication preflight. Phase 69 adds the disabled-by-default frontend - publication target contract. Do not claim frontend publication execution, + publication target contract. Phase 70 adds the status-only frontend + publication executor boundary. Do not claim frontend publication execution, failback, backup/restore, or NVMe parity yet. - Model hardening gate before the next large release: complete the ManagedVolume Operations Model under `internal/docs/protocol/` before @@ -201,9 +202,10 @@ rebuild, delete safety, or cleanup must start as a separate gated phase. consumes caught-up as a disabled publication preflight. Phase 67 publishes ACK eligibility after caught-up. Phase 68 makes frontend publication explicitly disabled on that eligibility. Phase 69 creates the next typed - frontend-publication target object without executing publication. The - remaining gap before failback is a real frontend publication executor - boundary with admission/RBAC proof and multi-volume isolation. + frontend-publication target object without executing publication. Phase 70 + adds the status-only frontend publication executor boundary. The remaining + gap before failback is the first real frontend publication mutation with + admission/RBAC proof and multi-volume isolation. - Later: returned-replica frontend publication/failback execution, NVMe ANA Kubernetes multipath parity, stronger committed-frontier reporting, broad distro/host compatibility, and longer soak under failure. NVMe ANA parity diff --git a/seaweed-block/internal/docs/qa-assignments/phase70-frontend-publication-executor-boundary-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase70-frontend-publication-executor-boundary-qa-signoff.md new file mode 100644 index 0000000000..c80a0b8108 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase70-frontend-publication-executor-boundary-qa-signoff.md @@ -0,0 +1,76 @@ +# Phase 70 Frontend Publication Executor Boundary QA Sign-off + +Status: PASS. + +Validated source tree: local Phase70 working tree synced to m02 +`/tmp/seaweed_block`. + +## Scope + +Phase 70 validates the frontend publication executor status boundary. + +It does not validate or claim real frontend publication, primary authority +change, failback, storage mutation, or workload mutation. + +## Local Verification + +```text +go test ./core/ops ./core/transport ./core/replication ./core/host/volume ./cmd/blockvolume ./cmd/sw-block +C:\work\swblock.exe validate testops\scenarios\frontend-publication-executor-boundary-chain.yaml +``` + +Result: PASS. + +## Runner Result + +```text +Scenario: frontend-publication-executor-boundary-chain.yaml +Run: 20260625-104138-40b7 +Result: 18/18 PASS +``` + +## Terminal Evidence + +```text +phase70_frontend_publication_executor_boundary_status=ok +frontend_publication_executor_status_writes=true +frontend_publication_executor_status=blocked +frontend_publication_executor_reason=frontend_publication_policy_disabled +frontend_publication_executor_rbac_status_only=true +frontend_publication_attempts=0 +frontend_published=false +failback_attempts=0 +failback_started=false +storage_mutation_allowed=false +``` + +## Verified Contract + +The executor may patch only `SwBlockFrontendPublication.status`. The status +states the publication policy is still disabled: + +```text +state=blocked +reasonCode=frontend_publication_policy_disabled +publicationMutationAllowed=false +frontendPublished=false +failbackStarted=false +``` + +## Negative Checks + +The phase keeps the real operation disabled: + +```text +frontend publication attempts = 0 +frontend published = false +failback attempts = 0 +failback started = false +storage mutation allowed = false +``` + +## Verdict + +Phase 70 PASS. The frontend publication executor can write only disabled +`SwBlockFrontendPublication.status` and the gate proves no frontend +publication, failback, or storage mutation is attempted. diff --git a/seaweed-block/scripts/run-phase70-frontend-publication-executor-boundary-gate.sh b/seaweed-block/scripts/run-phase70-frontend-publication-executor-boundary-gate.sh new file mode 100644 index 0000000000..a22116094b --- /dev/null +++ b/seaweed-block/scripts/run-phase70-frontend-publication-executor-boundary-gate.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +set -euo pipefail + +PRODUCT_ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase70-frontend-publication-executor-boundary-gate}" +SUMMARY="${ARTIFACT_DIR}/phase70-frontend-publication-executor-boundary-summary.txt" +OPS_LOG="${ARTIFACT_DIR}/core-ops-go-test.log" +CMD_LOG="${ARTIFACT_DIR}/cmd-sw-block-go-test.log" + +mkdir -p "${ARTIFACT_DIR}" +: >"${SUMMARY}" + +write_summary() { + echo "$*" | tee -a "${SUMMARY}" >/dev/null +} + +require_log() { + local name="$1" + local pattern="$2" + local file="$3" + local found="false" + if grep -Eq -- "${pattern}" "${file}"; then + found="true" + fi + write_summary "${name}=${found}" + if [ "${found}" != "true" ]; then + echo "missing evidence ${name}: pattern ${pattern}" >&2 + return 1 + fi +} + +write_summary "phase70_frontend_publication_executor_boundary_status=running" +write_summary "phase70_scope=frontend_publication_executor_status_boundary" +write_summary "frontend_publication_attempts=0" +write_summary "failback_attempts=0" +write_summary "storage_mutation_allowed=false" +write_summary "frontend_published=false" +write_summary "failback_started=false" + +OPS_PATTERN="TestPhase69SwBlockFrontendPublicationTargetSchema|TestPhase70FrontendPublicationExecutorPackagingIsStatusOnly|TestKubernetesStatusClientPatchesOnlyStatusSubresources|TestFrontendPublicationExecutorWritesDisabledStatus|TestFrontendPublicationExecutorDryRunDoesNotWriteStatus|TestFrontendPublicationExecutorMarksInvalidTargets" +CMD_PATTERN="TestOpsFrontendPublicationExecutorWritesDisabledStatus|TestOpsFrontendPublicationExecutorDryRunDoesNotWriteStatus" + +if (cd "${PRODUCT_ROOT}" && go test ./core/ops -run "${OPS_PATTERN}" -count=1 -v) >"${OPS_LOG}" 2>&1; then + write_summary "core_ops_frontend_executor_tests=pass" +else + write_summary "core_ops_frontend_executor_tests=fail" + cat "${OPS_LOG}" >&2 || true + exit 1 +fi + +if (cd "${PRODUCT_ROOT}" && go test ./cmd/sw-block -run "${CMD_PATTERN}" -count=1 -v) >"${CMD_LOG}" 2>&1; then + write_summary "cmd_sw_block_frontend_executor_tests=pass" +else + write_summary "cmd_sw_block_frontend_executor_tests=fail" + cat "${CMD_LOG}" >&2 || true + exit 1 +fi + +require_log "frontend_publication_target_schema_locked" "^--- PASS: TestPhase69SwBlockFrontendPublicationTargetSchema" "${OPS_LOG}" +require_log "frontend_publication_executor_rbac_status_only" "^--- PASS: TestPhase70FrontendPublicationExecutorPackagingIsStatusOnly" "${OPS_LOG}" +require_log "kubernetes_writer_frontend_publication_status_subresource" "^--- PASS: TestKubernetesStatusClientPatchesOnlyStatusSubresources" "${OPS_LOG}" +require_log "frontend_publication_executor_writes_disabled_status" "^--- PASS: TestFrontendPublicationExecutorWritesDisabledStatus" "${OPS_LOG}" +require_log "frontend_publication_executor_dry_run_no_status_write" "^--- PASS: TestFrontendPublicationExecutorDryRunDoesNotWriteStatus" "${OPS_LOG}" +require_log "frontend_publication_executor_invalid_target_blocked" "^--- PASS: TestFrontendPublicationExecutorMarksInvalidTargets" "${OPS_LOG}" +require_log "cmd_frontend_publication_executor_writes_status" "^--- PASS: TestOpsFrontendPublicationExecutorWritesDisabledStatus" "${CMD_LOG}" +require_log "cmd_frontend_publication_executor_dry_run_no_status_write" "^--- PASS: TestOpsFrontendPublicationExecutorDryRunDoesNotWriteStatus" "${CMD_LOG}" + +write_summary "frontend_publication_executor_status_writes=true" +write_summary "frontend_publication_executor_status=blocked" +write_summary "frontend_publication_executor_reason=frontend_publication_policy_disabled" +write_summary "frontend_publication_executor_status_mutation_allowed=true" +write_summary "frontend_publication_mutation_allowed=false" +write_summary "frontend_publication_executor_rbac_status_only=true" +write_summary "phase70_frontend_publication_executor_boundary_status=ok" diff --git a/seaweed-block/testops/scenarios/frontend-publication-executor-boundary-chain.yaml b/seaweed-block/testops/scenarios/frontend-publication-executor-boundary-chain.yaml new file mode 100644 index 0000000000..669c8669ec --- /dev/null +++ b/seaweed-block/testops/scenarios/frontend-publication-executor-boundary-chain.yaml @@ -0,0 +1,96 @@ +# Runner-native Phase 70 gate: frontend publication executor status boundary. + +name: frontend-publication-executor-boundary-chain +timeout: 8m + +env: + product_root: "/tmp/seaweed_block" + ssh_key: "C:\\work\\dev_server\\testdev_key" + +topology: + nodes: + m02: + host: 192.168.1.184 + user: testdev + key: "{{ ssh_key }}" + +phases: + - name: frontend_publication_executor_boundary_gate + actions: + - action: exec + node: m02 + timeout: 7m + cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary && cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary bash scripts/run-phase70-frontend-publication-executor-boundary-gate.sh {{ product_root }}" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary/phase70-frontend-publication-executor-boundary-summary.txt" + pattern: "^phase70_frontend_publication_executor_boundary_status=ok$" + save_as: phase70_ok + - action: assert_greater + actual: "{{ phase70_ok }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary/phase70-frontend-publication-executor-boundary-summary.txt" + pattern: "^frontend_publication_executor_status_writes=true$" + save_as: status_writes + - action: assert_greater + actual: "{{ status_writes }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary/phase70-frontend-publication-executor-boundary-summary.txt" + pattern: "^frontend_publication_executor_status=blocked$" + save_as: status_blocked + - action: assert_greater + actual: "{{ status_blocked }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary/phase70-frontend-publication-executor-boundary-summary.txt" + pattern: "^frontend_publication_executor_reason=frontend_publication_policy_disabled$" + save_as: reason_disabled + - action: assert_greater + actual: "{{ reason_disabled }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary/phase70-frontend-publication-executor-boundary-summary.txt" + pattern: "^frontend_publication_attempts=0$" + save_as: no_frontend_attempts + - action: assert_greater + actual: "{{ no_frontend_attempts }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary/phase70-frontend-publication-executor-boundary-summary.txt" + pattern: "^frontend_published=false$" + save_as: no_frontend_published + - action: assert_greater + actual: "{{ no_frontend_published }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary/phase70-frontend-publication-executor-boundary-summary.txt" + pattern: "^failback_started=false$" + save_as: no_failback_started + - action: assert_greater + actual: "{{ no_failback_started }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary/phase70-frontend-publication-executor-boundary-summary.txt" + pattern: "^storage_mutation_allowed=false$" + save_as: no_storage_mutation + - action: assert_greater + actual: "{{ no_storage_mutation }}" + threshold: "0" + + - name: collect + always: true + actions: + - action: collect_path + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase70-frontend-publication-executor-boundary" + name: "remote-phases" + ignore_error: true