From 7cfd2ae1a5a069beea76f294e010816a34ee54a1 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 26 Jun 2026 12:53:49 -0700 Subject: [PATCH] phase92: validate failback target executor handoff --- .../failback_target_executor_handoff_test.go | 81 +++++++++++++ seaweed-block/docs/roadmap.md | 3 + .../deep-dives/returned-replica-failback.md | 15 ++- seaweed-block/internal/docs/current-plan.md | 108 ++++++------------ ...edplan_failback_target_executor_handoff.md | 42 +++++++ .../internal/docs/product-roadmap.md | 4 + ...back-target-executor-handoff-qa-signoff.md | 46 ++++++++ ...2-failback-target-executor-handoff-gate.sh | 57 +++++++++ ...ailback-target-executor-handoff-chain.yaml | 88 ++++++++++++++ 9 files changed, 368 insertions(+), 76 deletions(-) create mode 100644 seaweed-block/core/ops/failback_target_executor_handoff_test.go create mode 100644 seaweed-block/internal/docs/finished-plans/phase92_finishedplan_failback_target_executor_handoff.md create mode 100644 seaweed-block/internal/docs/qa-assignments/phase92-failback-target-executor-handoff-qa-signoff.md create mode 100644 seaweed-block/scripts/run-phase92-failback-target-executor-handoff-gate.sh create mode 100644 seaweed-block/testops/scenarios/failback-target-executor-handoff-chain.yaml diff --git a/seaweed-block/core/ops/failback_target_executor_handoff_test.go b/seaweed-block/core/ops/failback_target_executor_handoff_test.go new file mode 100644 index 0000000000..1ee11b263e --- /dev/null +++ b/seaweed-block/core/ops/failback_target_executor_handoff_test.go @@ -0,0 +1,81 @@ +package ops + +import ( + "context" + "testing" + "time" +) + +func TestFailbackTargetOwnerExecutorHandoffUsesExpectedCurrentAuthority(t *testing.T) { + ownerClient := &fakeFailbackTargetOwnerClient{volumes: []SwBlockVolumeObject{failbackTargetOwnerTestVolume()}} + ownerResult, err := (FailbackTargetOwnerReconciler{ + Namespace: "kube-system", + Client: ownerClient, + ActivateTargets: true, + ActivationPolicyEnabled: true, + RuntimeEndpoint: "blockmaster.kube-system.svc:9333", + }).Reconcile(context.Background()) + if err != nil { + t.Fatalf("owner reconcile: %v", err) + } + if ownerResult.TargetCreateCount != 1 || ownerResult.FailbackAttempts != 0 || ownerResult.FrontendPublicationAllowed || ownerResult.StorageMutationAllowed { + t.Fatalf("owner result=%+v", ownerResult) + } + if len(ownerClient.creates) != 1 { + t.Fatalf("owner creates=%+v", ownerClient.creates) + } + + executorClient := &fakeFailbackExecutorClient{targets: ownerClient.creates} + runtime := &fakeFailbackRuntime{result: FailbackRuntimeResult{ + FailbackStarted: true, + AuthorityEpochAdvanced: true, + SinglePrimaryAfterFailback: true, + PublishTargetSwappedAfterFailback: true, + NoStorageMutation: true, + NoCrossVolumeIdentityChange: true, + EvidenceRefs: []string{"phase92-failback-runtime.txt"}, + }} + executorResult, err := (FailbackExecutorReconciler{ + Namespace: "kube-system", + Client: executorClient, + Runtime: runtime, + ExecutionRequested: true, + ExecutionPolicyEnabled: true, + Now: func() time.Time { return time.Date(2026, 6, 26, 16, 0, 0, 0, time.UTC) }, + }).Reconcile(context.Background()) + if err != nil { + t.Fatalf("executor reconcile: %v", err) + } + if executorResult.FailbackAttempts != 1 || + executorResult.StatusWriteCount != 1 || + !executorResult.AuthorityMutationAllowed || + executorResult.FrontendPublicationAllowed || + executorResult.StorageMutationAllowed { + t.Fatalf("executor result=%+v", executorResult) + } + if len(runtime.requests) != 1 { + t.Fatalf("runtime requests=%+v", runtime.requests) + } + req := runtime.requests[0] + if req.ExpectedCurrentReplicaID != "r2" || + req.ExpectedCurrentEpoch != 7 || + req.ReplicaID != "r1" || + req.TargetDataAddr != "data-r1" || + req.TargetCtrlAddr != "ctrl-r1" { + t.Fatalf("runtime request=%+v", req) + } + status := executorClient.writes[0].status + if status.State != FailbackStateFailedBack || + status.ReasonCode != AuthorityExecutorFailbackReasonCompleted || + status.FailbackMutationAllowed || + !status.FailbackStarted || + !status.AuthorityEpochAdvanced || + !status.SinglePrimaryAfterFailback || + !status.PublishTargetSwappedAfterFailback || + !status.NoCrossVolumeIdentityChange { + t.Fatalf("status=%+v", status) + } + if !failbackExecutorStringSliceContains(status.EvidenceRefs, "phase92-failback-runtime.txt") { + t.Fatalf("evidenceRefs=%+v", status.EvidenceRefs) + } +} diff --git a/seaweed-block/docs/roadmap.md b/seaweed-block/docs/roadmap.md index b7eb051a6a..67da7ed74e 100644 --- a/seaweed-block/docs/roadmap.md +++ b/seaweed-block/docs/roadmap.md @@ -547,6 +547,9 @@ control-plane path is mature. frontend publication remain separate opt-in gates - failback target activation is explicit and default-off: policy plus runtime endpoint are required before a target can be stamped `enabled` + - target-owner to executor handoff is locally gated: expected-current + authority facts reach the runtime request and terminal evidence controls + `failed_back`; live deployed failback remains a separate release gate 4. Flow-control and pressure behavior. diff --git a/seaweed-block/docs/wiki/deep-dives/returned-replica-failback.md b/seaweed-block/docs/wiki/deep-dives/returned-replica-failback.md index 71d37f68de..4d6a844913 100644 --- a/seaweed-block/docs/wiki/deep-dives/returned-replica-failback.md +++ b/seaweed-block/docs/wiki/deep-dives/returned-replica-failback.md @@ -237,6 +237,7 @@ ambiguous HTTP/gRPC runtime addresses. | 89 | projects current authority facts into `SwBlockVolume.status`, operator-snapshot, and summary text for later expected-current failback activation | | 90 | makes target-owner creation require current authority facts and stamp `expectedCurrentReplicaID` / `expectedCurrentEpoch` onto disabled targets | | 91 | adds explicit target activation policy plus runtime endpoint wiring; default remains disabled and no runtime call is made by the target owner | +| 92 | proves local target-owner -> executor handoff, including expected-current facts in the runtime request and terminal `failed_back` evidence | ## Failure Classes @@ -264,12 +265,14 @@ Before enabling broader failback behavior: 6. Require explicit target activation policy and runtime endpoint before stamping `failbackDecision=enabled`. 7. Pass expected-current replica and epoch to blockmaster. -8. Run through blockmaster-owned `FailbackService`, not a sidecar authority copy. -9. Require terminal evidence before writing `failed_back`. -10. Keep frontend publication as a separate gated action. -11. Keep rebuild/catch-up traffic as a separate gated action. -12. Run multi-volume isolation gates. -13. Document exactly what is automatic and what is opt-in. +8. Prove target-owner -> executor handoff locally before the live deployed + runtime smoke. +9. Run through blockmaster-owned `FailbackService`, not a sidecar authority copy. +10. Require terminal evidence before writing `failed_back`. +11. Keep frontend publication as a separate gated action. +12. Keep rebuild/catch-up traffic as a separate gated action. +13. Run multi-volume isolation gates. +14. Document exactly what is automatic and what is opt-in. ## Current Limits diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index be526d57b2..76fe3470f9 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,108 +1,76 @@ -# Current Plan: Phase 91 Failback Target Activation Policy +# Current Plan: Phase 92 Failback Target -> Executor Handoff Status: complete. ## Goal -Phase 91 adds an explicit activation policy to the failback target-owner path. -By default, target-owner behavior remains unchanged: it creates disabled, -non-mutating `SwBlockReplicaFailback` targets only. - -When all activation knobs are explicitly supplied, the owner may create an -enabled target: +Phase 92 proves the first integrated handoff between the failback target owner +and failback executor: ```text ---activate-targets ---activation-policy ---runtime-endpoint +SwBlockVolume.status authority facts +-> target owner creates enabled SwBlockReplicaFailback target +-> executor consumes the target +-> runtime request receives expected-current replica and epoch +-> executor writes terminal failed_back status from runtime evidence ``` -This phase still does not call the failback runtime. It only stamps the target -so the separate failback executor can decide whether to execute it. +This is still a local/fake-runtime gate. It does not claim a live Kubernetes +blockmaster runtime smoke or frontend publication. ## Deliverables -### D1: Target Owner Policy +### D1: Integrated Handoff Test -`FailbackTargetOwnerReconciler` now has: +Added `TestFailbackTargetOwnerExecutorHandoffUsesExpectedCurrentAuthority`. + +It proves: ```text -ActivateTargets -ActivationPolicyEnabled -RuntimeEndpoint +target owner creates one enabled target +expectedCurrentReplicaID=r2 reaches the runtime request +expectedCurrentEpoch=7 reaches the runtime request +executor writes failed_back only after valid terminal runtime evidence +frontend publication remains false +storage mutation remains false ``` -Activation fails closed unless policy is enabled and a runtime endpoint is -present. - -### D2: CLI And Helm Wiring - -`sw-block ops failback-target-owner` accepts: - -```text ---activate-targets ---activation-policy ---runtime-endpoint -``` - -Helm exposes these under: - -```text -failbackTargetOwner.activation.enabled -failbackTargetOwner.activation.policy -failbackTargetOwner.activation.runtimeEndpoint -``` - -Defaults keep activation off and omit all activation flags. - -### D3: Gate +### D2: Gate Added: ```text -scripts/run-phase91-failback-target-activation-policy-gate.sh -testops/scenarios/failback-target-activation-policy-chain.yaml -``` - -The gate proves: - -```text -default Helm render omits activation flags -explicit values render activation flags -policy is required -runtime endpoint is required -enabled targets retain expected-current authority facts -no failback runtime call is attempted -frontend publication remains unclaimed +scripts/run-phase92-failback-target-executor-handoff-gate.sh +testops/scenarios/failback-target-executor-handoff-chain.yaml ``` ## Verification ```text -bash scripts/run-phase91-failback-target-activation-policy-gate.sh . -swblock validate testops/scenarios/failback-target-activation-policy-chain.yaml +bash scripts/run-phase92-failback-target-executor-handoff-gate.sh . +swblock validate testops/scenarios/failback-target-executor-handoff-chain.yaml ``` Expected terminal evidence: ```text -phase91_failback_target_activation_policy_status=ok -activation_default_off=true -activation_policy_required=true -activation_runtime_endpoint_required=true -activated_target_failback_decision=enabled -activated_target_failback_mutation_allowed=true -failback_runtime_call_attempted=false +phase92_failback_target_executor_handoff_status=ok +target_owner_created_enabled_target=true +executor_consumed_target=true +runtime_request_expected_current_replica=r2 +runtime_request_expected_current_epoch=7 +executor_terminal_state=failed_back +frontend_publication_after_failback_claimed=false +storage_mutation_allowed=false ``` ## Next -Phase 92 should run the first integrated target-owner -> executor handoff smoke: +Phase 93 should choose the next proof boundary: ```text -target owner creates an enabled target with expected-current facts -executor consumes that target -runtime remains fake/local unless a live service gate is explicitly selected -terminal evidence decides status -frontend publication remains separate +live blockmaster gRPC runtime smoke using the deployed suite, or +multi-volume failback handoff isolation before live runtime ``` + +Do not combine frontend publication into that step. diff --git a/seaweed-block/internal/docs/finished-plans/phase92_finishedplan_failback_target_executor_handoff.md b/seaweed-block/internal/docs/finished-plans/phase92_finishedplan_failback_target_executor_handoff.md new file mode 100644 index 0000000000..5f9614d83f --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase92_finishedplan_failback_target_executor_handoff.md @@ -0,0 +1,42 @@ +# Phase 92 Finished Plan: Failback Target -> Executor Handoff + +Status: complete. + +Date: 2026-06-26. + +## What Changed + +Phase 92 adds an integrated target-owner to executor handoff gate. The target +owner creates an enabled `SwBlockReplicaFailback` target from +`SwBlockVolume.status`; the executor consumes that target through a fake/local +runtime and writes terminal `failed_back` status only when terminal evidence is +valid. + +## What It Proves + +```text +expectedCurrentReplicaID survives target creation +expectedCurrentEpoch survives target creation +executor sends those facts to the runtime request +terminal runtime evidence controls failed_back status +frontend publication remains false +storage mutation remains false +``` + +## Boundary + +This is not a live deployed failback claim. The runtime is fake/local test code, +not a Kubernetes blockmaster service. + +## Verification + +```text +scripts/run-phase92-failback-target-executor-handoff-gate.sh . +swblock validate testops/scenarios/failback-target-executor-handoff-chain.yaml +``` + +Expected result: + +```text +phase92_failback_target_executor_handoff_status=ok +``` diff --git a/seaweed-block/internal/docs/product-roadmap.md b/seaweed-block/internal/docs/product-roadmap.md index 60f605dbe9..cf8b44e2c2 100644 --- a/seaweed-block/internal/docs/product-roadmap.md +++ b/seaweed-block/internal/docs/product-roadmap.md @@ -743,6 +743,10 @@ Approximate engineering effort if scope remains tight: is still default-off, but explicit policy plus runtime endpoint can stamp an enabled failback target for the executor handoff. The target owner still does not call the runtime or publish a frontend. +- Phase 92 Failback Target -> Executor Handoff is closed. A local/fake-runtime + gate proves expected-current authority facts survive target creation into the + executor runtime request and terminal evidence drives `failed_back` status. + Live deployed failback remains a separate gate. - Phase 41-44 are the Operation Layer v0.5 release train: lifecycle-owner foundation, real API/admission proof, first bounded finalizer mutation, and delete lifecycle close gate. diff --git a/seaweed-block/internal/docs/qa-assignments/phase92-failback-target-executor-handoff-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase92-failback-target-executor-handoff-qa-signoff.md new file mode 100644 index 0000000000..4d9d6f6303 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase92-failback-target-executor-handoff-qa-signoff.md @@ -0,0 +1,46 @@ +# Phase 92 QA Sign-off: Failback Target -> Executor Handoff + +Status: pending QA. + +## Scope + +Validate the local/fake-runtime handoff from failback target owner to failback +executor. + +## Gate + +Run: + +```text +bash scripts/run-phase92-failback-target-executor-handoff-gate.sh . +swblock validate testops/scenarios/failback-target-executor-handoff-chain.yaml +``` + +## Required Evidence + +The summary must contain: + +```text +phase92_failback_target_executor_handoff_status=ok +go_test_core_ops_failback_handoff=pass +target_owner_created_enabled_target=true +executor_consumed_target=true +runtime_request_expected_current_replica=r2 +runtime_request_expected_current_epoch=7 +executor_terminal_state=failed_back +frontend_publication_after_failback_claimed=false +storage_mutation_allowed=false +``` + +## Pass Criteria + +- Target owner creates exactly one enabled target from current authority facts. +- Executor consumes the target and calls the supplied runtime. +- Runtime request includes expected-current replica and epoch. +- Executor writes `failed_back` only after terminal evidence. +- No frontend publication or storage mutation is claimed. + +## Non-Claims + +This is not a live deployed failback smoke. It does not prove a published image +or a Kubernetes blockmaster gRPC service path. diff --git a/seaweed-block/scripts/run-phase92-failback-target-executor-handoff-gate.sh b/seaweed-block/scripts/run-phase92-failback-target-executor-handoff-gate.sh new file mode 100644 index 0000000000..18f4d16780 --- /dev/null +++ b/seaweed-block/scripts/run-phase92-failback-target-executor-handoff-gate.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -euo pipefail + +PRODUCT_ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase92-failback-target-executor-handoff-gate}" +SUMMARY="${ARTIFACT_DIR}/phase92-failback-target-executor-handoff-summary.txt" +TEST_LOG="${ARTIFACT_DIR}/go-test-core-ops.log" + +mkdir -p "${ARTIFACT_DIR}" +: >"${SUMMARY}" + +write_summary() { + echo "$*" | tee -a "${SUMMARY}" >/dev/null +} + +require_text() { + local name="$1" + local pattern="$2" + local file="$3" + local found="false" + if grep -Fq -- "${pattern}" "${file}"; then + found="true" + fi + write_summary "${name}=${found}" + if [ "${found}" != "true" ]; then + echo "missing ${name}: ${pattern}" >&2 + return 1 + fi +} + +write_summary "phase92_failback_target_executor_handoff_status=running" +write_summary "phase92_scope=target_owner_to_executor_handoff" +write_summary "frontend_publication_after_failback_claimed=false" +write_summary "storage_mutation_allowed=false" + +TEST_RE='TestFailbackTargetOwnerExecutorHandoffUsesExpectedCurrentAuthority|TestFailbackTargetOwner|TestFailbackExecutorInvokesRuntimeWhenExplicitlyEnabled' +if (cd "${PRODUCT_ROOT}" && go test ./core/ops -run "${TEST_RE}" -count=1 -v) >"${TEST_LOG}" 2>&1; then + write_summary "go_test_core_ops_failback_handoff=pass" +else + write_summary "go_test_core_ops_failback_handoff=fail" + cat "${TEST_LOG}" >&2 || true + exit 1 +fi + +require_text "handoff_test_present" "TestFailbackTargetOwnerExecutorHandoffUsesExpectedCurrentAuthority" "${PRODUCT_ROOT}/core/ops/failback_target_executor_handoff_test.go" +require_text "runtime_request_expected_replica_checked" "req.ExpectedCurrentReplicaID != \"r2\"" "${PRODUCT_ROOT}/core/ops/failback_target_executor_handoff_test.go" +require_text "runtime_request_expected_epoch_checked" "req.ExpectedCurrentEpoch != 7" "${PRODUCT_ROOT}/core/ops/failback_target_executor_handoff_test.go" +require_text "terminal_status_failed_back_checked" "status.State != FailbackStateFailedBack" "${PRODUCT_ROOT}/core/ops/failback_target_executor_handoff_test.go" +require_text "frontend_publication_remains_false_checked" "executorResult.FrontendPublicationAllowed" "${PRODUCT_ROOT}/core/ops/failback_target_executor_handoff_test.go" +require_text "storage_mutation_remains_false_checked" "executorResult.StorageMutationAllowed" "${PRODUCT_ROOT}/core/ops/failback_target_executor_handoff_test.go" + +write_summary "target_owner_created_enabled_target=true" +write_summary "executor_consumed_target=true" +write_summary "runtime_request_expected_current_replica=r2" +write_summary "runtime_request_expected_current_epoch=7" +write_summary "executor_terminal_state=failed_back" +write_summary "phase92_failback_target_executor_handoff_status=ok" diff --git a/seaweed-block/testops/scenarios/failback-target-executor-handoff-chain.yaml b/seaweed-block/testops/scenarios/failback-target-executor-handoff-chain.yaml new file mode 100644 index 0000000000..f68457c457 --- /dev/null +++ b/seaweed-block/testops/scenarios/failback-target-executor-handoff-chain.yaml @@ -0,0 +1,88 @@ +# Runner-native Phase 92 gate: target owner creates an enabled failback target, +# executor consumes it through a fake/local runtime, and expected-current +# authority facts reach the runtime request. + +name: failback-target-executor-handoff-chain +timeout: 5m + +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: failback_target_executor_handoff_gate + actions: + - action: exec + node: m02 + timeout: 4m + cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff && cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff bash scripts/run-phase92-failback-target-executor-handoff-gate.sh {{ product_root }}" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff/phase92-failback-target-executor-handoff-summary.txt" + pattern: "^phase92_failback_target_executor_handoff_status=ok$" + save_as: phase92_ok + - action: assert_greater + actual: "{{ phase92_ok }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff/phase92-failback-target-executor-handoff-summary.txt" + pattern: "^target_owner_created_enabled_target=true$" + save_as: owner_created + - action: assert_greater + actual: "{{ owner_created }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff/phase92-failback-target-executor-handoff-summary.txt" + pattern: "^executor_consumed_target=true$" + save_as: executor_consumed + - action: assert_greater + actual: "{{ executor_consumed }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff/phase92-failback-target-executor-handoff-summary.txt" + pattern: "^runtime_request_expected_current_replica=r2$" + save_as: expected_replica + - action: assert_greater + actual: "{{ expected_replica }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff/phase92-failback-target-executor-handoff-summary.txt" + pattern: "^runtime_request_expected_current_epoch=7$" + save_as: expected_epoch + - action: assert_greater + actual: "{{ expected_epoch }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff/phase92-failback-target-executor-handoff-summary.txt" + pattern: "^frontend_publication_after_failback_claimed=false$" + save_as: no_frontend_publication + - action: assert_greater + actual: "{{ no_frontend_publication }}" + threshold: "0" + + - name: collect + always: true + actions: + - action: collect_path + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase92-failback-target-executor-handoff" + name: "remote-phases" + ignore_error: true