From 72c4f65167b6ae2c8acc7814a454ca0f7a8a0845 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Tue, 23 Jun 2026 17:47:53 -0700 Subject: [PATCH] phase59: close rebuild planning gate --- seaweed-block/docs/roadmap.md | 27 +- seaweed-block/internal/docs/current-plan.md | 195 ++++------ ...inishedplan_rebuild_planning_close_gate.md | 87 +++++ ...ase59-rebuild-planning-close-qa-signoff.md | 98 +++++ ...run-phase59-rebuild-planning-close-gate.sh | 357 ++++++++++++++++++ .../rebuild-planning-close-chain.yaml | 112 ++++++ 6 files changed, 759 insertions(+), 117 deletions(-) create mode 100644 seaweed-block/internal/docs/finished-plans/phase59_finishedplan_rebuild_planning_close_gate.md create mode 100644 seaweed-block/internal/docs/qa-assignments/phase59-rebuild-planning-close-qa-signoff.md create mode 100644 seaweed-block/scripts/run-phase59-rebuild-planning-close-gate.sh create mode 100644 seaweed-block/testops/scenarios/rebuild-planning-close-chain.yaml diff --git a/seaweed-block/docs/roadmap.md b/seaweed-block/docs/roadmap.md index 8e7f8451c1..ed088dc234 100644 --- a/seaweed-block/docs/roadmap.md +++ b/seaweed-block/docs/roadmap.md @@ -192,7 +192,28 @@ Recommended order from here: This phase aligns README, release notes, user capabilities, and developer wiki pages with the Phase 54 boundary. It should not add a new storage feature or broaden the claim beyond ACK eligibility target status. -13. Add backup/restore and NVMe ANA parity after they can reuse the same action +13. Phase 56: returned-replica rebuild/catch-up contract. **Closed 2026-06-23, QA PASS** + (`internal/docs/finished-plans/phase56_finishedplan_returned_replica_rebuild_contract.md`). + The product now surfaces `authority.rebuild_returned_replica` as a disabled + future action when a returned replica is frontend-fenced and behind the + required frontier. It does not start rebuild traffic. +14. Phase 57: rebuild progress target. **Closed 2026-06-23, QA PASS** + (`internal/docs/finished-plans/phase57_finishedplan_rebuild_progress_target.md`). + `SwBlockReplicaRebuild.status` exists as the narrow target for planned + rebuild progress. The authority executor may write only planned status under + the `rebuild_traffic` mutation class; it still does not copy data, publish a + frontend, or fail back a replica. +15. Phase 58: rebuild target owner. **Closed 2026-06-23, QA PASS** + (`internal/docs/finished-plans/phase58_finishedplan_rebuild_target_owner.md`). + A separate target-owner identity can create `SwBlockReplicaRebuild` main + objects from ready rebuild contracts. It cannot write status or mutate + volume, workload, frontend, or storage state. +16. Phase 59: rebuild planning close gate. **Closed 2026-06-23, QA PASS** + (`internal/docs/finished-plans/phase59_finishedplan_rebuild_planning_close_gate.md`). + This gate connects Phases 56-58 as one product path: + rebuild contract -> target-owner-created target CR -> executor planned + status. It is still planning/status only, not real rebuild data movement. +17. Add backup/restore and NVMe ANA parity after they can reuse the same action owner, evidence, and status model rather than creating another isolated control plane. @@ -204,7 +225,9 @@ returned-replica reintegration before any larger storage feature is enabled. Phases 47-54 close the executor-admission, preflight, status-schema, ACK evidence, executor-contract, disabled executor-process bridge, and first bounded ACK eligibility mutation without allowing frontend publication, rebuild -traffic, or failback. +traffic, or failback. Phases 56-59 extend that same pattern to returned-replica +rebuild planning: contract, target CR, target owner, and planned status before +any real rebuild/catch-up traffic is enabled. The practical rule is: diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index ca03bd14a2..83cb206549 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,4 +1,4 @@ -# Current Plan: Phase 58 Rebuild Target Owner +# Current Plan: Phase 59 Rebuild Planning Close Gate Status: complete. @@ -6,181 +6,146 @@ Branch target: `phase54-returned-replica-reintegration-executor` ## Goal -Phase 57 added `SwBlockReplicaRebuild.status` as the narrow status target for -future returned-replica rebuild progress. That still required a target CR to -exist before the executor could write planned rebuild status. +Phases 56-58 built the returned-replica rebuild planning chain in pieces: -Phase 58 adds the missing owner for that target: +```text +Phase 56: SwBlockVolume.status exposes rebuild_returned_replica contract +Phase 57: SwBlockReplicaRebuild.status target exists for planned progress +Phase 58: rebuild-target-owner creates SwBlockReplicaRebuild target CRs +``` + +Phase 59 closes that planning loop as one product path: ```text SwBlockVolume.status.executorContracts[] - actionType=authority.rebuild_returned_replica - allowedMutationClass=rebuild_traffic - preflight=ready - | - v -SwBlockReplicaRebuild.spec - volumeName / volumeID / pvcName / replicaID + -> sw-block ops rebuild-target-owner + -> SwBlockReplicaRebuild.spec target exists + -> sw-block ops authority-executor --allowed-mutation-class=rebuild_traffic + -> SwBlockReplicaRebuild.status.state=planned ``` -The target owner may create the `SwBlockReplicaRebuild` main object. It does -not write status, start rebuild traffic, publish a frontend, fail back a -replica, or change primary authority. +This phase still does not move data. It proves the target no longer has to be +manually stubbed before the executor can write planned rebuild status. ## Scope In scope: -- Add a `rebuild-target-owner` reconciler. -- Add `sw-block ops rebuild-target-owner`. -- Add Kubernetes create support for `SwBlockReplicaRebuild` main objects. -- Package an optional Helm Deployment and narrow RBAC identity. -- Gate live RBAC: - - can read `SwBlockVolume`; - - can read/create `SwBlockReplicaRebuild`; - - cannot patch/update/delete rebuild targets; - - cannot write rebuild target status; - - cannot write `SwBlockVolume` status/finalizers; - - cannot mutate events, pods, PVCs, or storage classes. +- Add an integrated TestRunner gate using real `sw-block` CLI commands. +- Compile the current `sw-block` binary on the lab node. +- Run `rebuild-target-owner` inside Kubernetes with its own ServiceAccount. +- Run `authority-executor` inside Kubernetes with its own ServiceAccount. +- Verify the target-owner creates exactly one `SwBlockReplicaRebuild` target. +- Verify a second target-owner run is idempotent. +- Verify the executor writes planned rebuild status to that target. +- Verify `SwBlockVolume.status` and finalizers remain unchanged. Out of scope: - No rebuild data movement. - No WAL/block copy. -- No rebuild status write by the target owner. - No frontend publication. - No failback. - No primary authority change. +- No ACK eligibility mutation. - No cross-volume mutation. ## Deliverables -### D1: Rebuild Target Owner Controller - -Status: implemented locally. - -The controller lists `SwBlockVolume` objects and existing -`SwBlockReplicaRebuild` targets. It creates one target only when a volume has a -ready disabled rebuild contract: - -```text -actionType=authority.rebuild_returned_replica -decision=disabled -reason=executor_disabled -preflightDecision=ready -preflightReason=satisfied -allowedMutationClass contains rebuild_traffic -replicaID != "" -``` - -Existing targets are detected by volume identity plus replica ID and are not -duplicated. - -### D2: CLI and Kubernetes Create Client +### D1: Integrated Gate Script Status: implemented locally. Added: ```text -sw-block ops rebuild-target-owner [--dry-run] [--namespace ] [--interval 30s] +scripts/run-phase59-rebuild-planning-close-gate.sh ``` -The command reports terminal evidence: +The script creates synthetic CRD evidence, runs product CLI commands inside +Kubernetes jobs, and records terminal evidence. -```text -rebuild_target_owner=target_mutation|dry_run -targets_planned= -targets_existing= -targets_created= -invalid_contracts= -storage_mutation_allowed=false -frontend_publication_allowed=false -failback_allowed=false -``` - -The Kubernetes client creates only the main `SwBlockReplicaRebuild` object with -`apiVersion`, `kind`, `metadata`, and `spec`; it does not include `status`. - -### D3: Helm Packaging and RBAC +### D2: TestRunner Scenario Status: implemented locally. -Added optional chart values: +Added: -```yaml -rebuildTargetOwner: - create: false - dryRun: true - interval: 30s +```text +testops/scenarios/rebuild-planning-close-chain.yaml ``` -The packaged identity is intentionally separate from authority-executor: +The scenario asserts: -- `rebuild-target-owner`: creates target CRs only; -- `authority-executor`: writes target `/status` only. +- target-owner first run creates one target; +- target-owner second run detects the existing target and creates zero more; +- target status is empty before executor; +- executor writes `state=planned`; +- `rebuildTrafficStarted=false`; +- `noFrontendPublication=true`; +- the source `SwBlockVolume` reason and finalizers do not change. -### D4: Runner RBAC Gate +### D3: Roadmap Alignment + +Status: complete. + +Update roadmap wording so Phase 56-59 are visible as the rebuild planning +train, not a shipped real rebuild data path. + +### D4: Live QA Gate Status: QA PASS. -Added: - -- `scripts/run-phase58-rebuild-target-owner-rbac-gate.sh` -- `testops/scenarios/rebuild-target-owner-rbac-chain.yaml` - -The live gate proves both `kubectl auth can-i` and runtime behavior: - -- default identity cannot create rebuild targets; -- owner identity can create one CRD-valid target; -- owner identity cannot patch the created target; -- created target has spec identity and empty status; -- owner identity cannot mutate status, Events, workloads, PVCs, or storage - classes. - -## Verification - -Local checks: +Run: ```text -go test ./core/ops ./cmd/sw-block ./scripts -helm lint charts/seaweed-block -swblock validate testops/scenarios/rebuild-target-owner-rbac-chain.yaml -``` - -Live gate: - -```text -swblock run testops/scenarios/rebuild-target-owner-rbac-chain.yaml +swblock run testops/scenarios/rebuild-planning-close-chain.yaml ``` Expected terminal evidence: ```text -phase58_rebuild_target_owner_rbac_status=ok -owner_create_swblockreplicarebuilds_allowed=yes -owner_create_rebuild_target_runtime_allowed=true -default_create_rebuild_target_runtime_denied=true -owner_patch_rebuild_target_runtime_denied=true -owner_patch_swblockreplicarebuilds_status_denied=no -owner_create_events_denied=no -runtime_rebuild_target_status_state= +phase59_rebuild_planning_close_status=ok +rebuild_target_owner=target_mutation ... targets_created=1 ... +rebuild_target_owner=target_mutation ... targets_existing=1 targets_created=0 ... +rebuild_target_status_before_executor= +authority_executor=executed ... rebuild_progress_mutation_attempts=1 ... +rebuild_status_state_after_executor=planned +rebuild_traffic_started_after_executor=false +no_frontend_publication_after_executor=true +swblockvolume_reason_unchanged=candidate_frontier_behind +``` + +## Verification + +Local: + +```text +go test ./core/ops ./cmd/sw-block ./scripts +helm lint charts/seaweed-block +swblock validate testops/scenarios/rebuild-planning-close-chain.yaml +``` + +Live: + +```text +swblock run testops/scenarios/rebuild-planning-close-chain.yaml ``` ## Exit -Phase 58 closes when local tests pass and the runner proves the target owner can -create only rebuild target CRs, while all status, storage, frontend, workload, -and authority mutations remain denied. +Phase 59 closes when the live gate proves the returned-replica rebuild planning +chain works end-to-end without manual target stubs and without claiming rebuild +data movement. Result: ```text -20260623-164948-4735 rebuild-target-owner-rbac-chain PASS 18/18 +20260623-174546-3054 rebuild-planning-close-chain PASS 22/22 ``` Sign-off: ```text -internal/docs/qa-assignments/phase58-rebuild-target-owner-qa-signoff.md +internal/docs/qa-assignments/phase59-rebuild-planning-close-qa-signoff.md ``` diff --git a/seaweed-block/internal/docs/finished-plans/phase59_finishedplan_rebuild_planning_close_gate.md b/seaweed-block/internal/docs/finished-plans/phase59_finishedplan_rebuild_planning_close_gate.md new file mode 100644 index 0000000000..821bbdf201 --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase59_finishedplan_rebuild_planning_close_gate.md @@ -0,0 +1,87 @@ +# Phase 59 Finished Plan: Rebuild Planning Close Gate + +Status: complete. + +Completed on: 2026-06-23. + +Branch: `phase54-returned-replica-reintegration-executor`. + +## What Changed + +Phase 59 closed the returned-replica rebuild planning loop: + +```text +SwBlockVolume.status.executorContracts[] + -> rebuild-target-owner creates SwBlockReplicaRebuild.spec + -> authority-executor writes SwBlockReplicaRebuild.status +``` + +Before this phase, the executor could write planned rebuild status only if a +`SwBlockReplicaRebuild` target had been manually created. The live gate now +proves the target owner creates that target automatically from the ready rebuild +contract. + +## Product Boundary + +This phase is planning/status only. + +Non-claims: + +- no rebuild data movement; +- no WAL/block copy; +- no frontend publication; +- no failback; +- no primary authority change; +- no ACK eligibility mutation; +- no cross-volume mutation. + +## Deliverables + +- `scripts/run-phase59-rebuild-planning-close-gate.sh` + - compiles the current `sw-block` binary on the lab node; + - runs real in-cluster `sw-block ops rebuild-target-owner`; + - runs real in-cluster `sw-block ops authority-executor`; + - waits for CRD storage readiness before launching the Jobs. +- `testops/scenarios/rebuild-planning-close-chain.yaml` + - asserts target creation; + - asserts target-owner idempotency; + - asserts planned rebuild status; + - asserts no rebuild traffic/frontend/failback claims. +- Roadmap update: + - documents Phases 56-59 as the rebuild planning train. + +## Verification + +Local: + +```text +go test ./core/ops ./cmd/sw-block ./scripts +helm lint charts/seaweed-block +swblock validate testops/scenarios/rebuild-planning-close-chain.yaml +``` + +Live: + +```text +20260623-174546-3054 rebuild-planning-close-chain PASS 22/22 +``` + +Key evidence: + +```text +rebuild_target_owner=target_mutation ... targets_created=1 ... +rebuild_target_owner=target_mutation ... targets_existing=1 targets_created=0 ... +authority_executor=executed ... rebuild_progress_mutation_attempts=1 ... +rebuild_status_state_after_executor=planned +rebuild_traffic_started_after_executor=false +no_frontend_publication_after_executor=true +swblockvolume_reason_unchanged=candidate_frontier_behind +swblockvolume_finalizers_unchanged= +``` + +## Result + +The rebuild planning control-plane chain is now closed and automated. The next +major delivery can move from planned status toward a real, bounded +rebuild/catch-up data-path primitive, but that must be treated as a new +capability with its own evidence, status, failure, and cleanup gates. diff --git a/seaweed-block/internal/docs/qa-assignments/phase59-rebuild-planning-close-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase59-rebuild-planning-close-qa-signoff.md new file mode 100644 index 0000000000..a5b3379877 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase59-rebuild-planning-close-qa-signoff.md @@ -0,0 +1,98 @@ +# Phase 59 Rebuild Planning Close Gate QA Sign-off + +Status: PASS. + +Validated on: 2026-06-23. + +Runner evidence: + +```text +20260623-174546-3054 rebuild-planning-close-chain PASS 22/22 +``` + +## Scope + +Phase 59 connects the rebuild planning pieces from Phases 56-58: + +```text +SwBlockVolume.status.executorContracts[] + -> sw-block ops rebuild-target-owner + -> SwBlockReplicaRebuild.spec target + -> sw-block ops authority-executor --allowed-mutation-class=rebuild_traffic + -> SwBlockReplicaRebuild.status.state=planned +``` + +This is still a planning/status gate. It does not start rebuild data movement, +publish a frontend, fail back a replica, or change primary authority. + +## Local Checks + +```text +go test ./core/ops ./cmd/sw-block ./scripts +helm lint charts/seaweed-block +swblock validate testops/scenarios/rebuild-planning-close-chain.yaml +``` + +All passed. + +## Live Gate + +Scenario: + +```text +testops/scenarios/rebuild-planning-close-chain.yaml +``` + +Result: + +```text +=== rebuild-planning-close-chain === PASS (24.987s) +22 actions: 22 passed, 0 failed +``` + +Key terminal evidence: + +```text +phase59_rebuild_planning_close_status=ok +swblockvolumes_storage_ready_attempt=1 +swblockreplicarebuilds_storage_ready_attempt=1 +rebuild_target_owner=target_mutation namespace=sw-block-phase59-rebuild-planning volumes=1 contracts=1 targets_planned=1 targets_existing=0 targets_created=1 invalid_contracts=0 mutation_allowed=true storage_mutation_allowed=false frontend_publication_allowed=false failback_allowed=false +rebuild_target_count_after_owner=1 +rebuild_target_status_before_executor= +rebuild_target_owner=target_mutation namespace=sw-block-phase59-rebuild-planning volumes=1 contracts=1 targets_planned=1 targets_existing=1 targets_created=0 invalid_contracts=0 mutation_allowed=false storage_mutation_allowed=false frontend_publication_allowed=false failback_allowed=false +rebuild_target_count_after_idempotent_owner=1 +authority_executor=executed namespace=sw-block-phase59-rebuild-planning volumes=1 contracts=1 disabled_contracts=1 blocked_contracts=0 terminal_evidence_required=1 terminal_evidence_missing=0 ack_eligibility_target_missing=0 rebuild_target_missing=0 allowed_mutation_class=rebuild_traffic execution_requested=true execution_policy_enabled=true mutation_attempts=1 ack_eligibility_mutation_attempts=0 rebuild_progress_mutation_attempts=1 mutation_allowed=true storage_mutation_allowed=false +rebuild_status_state_after_executor=planned +rebuild_status_reason_after_executor=rebuild_progress_planned +rebuild_traffic_started_after_executor=false +no_frontend_publication_after_executor=true +no_cross_volume_identity_change_after_executor=true +swblockvolume_reason_unchanged=candidate_frontier_behind +swblockvolume_finalizers_unchanged= +``` + +## Finding + +The first run of the gate failed because the CRD API returned: + +```text +http 429 storage is (re)initializing +``` + +That was a gate timing issue, not a product defect. The gate now waits for CRD +`Established` and for list calls to succeed before launching the in-cluster CLI +Jobs. The re-run passed. + +## Verdict + +PASS. + +The rebuild planning chain no longer requires a manually stubbed +`SwBlockReplicaRebuild` target. The target-owner creates exactly one target, +the second run is idempotent, and the authority executor writes planned status +to that target. The source `SwBlockVolume` status reason and finalizers remain +unchanged. No rebuild data movement, frontend publication, failback, or +cross-volume mutation is claimed. + +Lab residue check after the run showed no Phase 59 namespace, RBAC, or +temporary CRDs remaining. diff --git a/seaweed-block/scripts/run-phase59-rebuild-planning-close-gate.sh b/seaweed-block/scripts/run-phase59-rebuild-planning-close-gate.sh new file mode 100644 index 0000000000..f295797148 --- /dev/null +++ b/seaweed-block/scripts/run-phase59-rebuild-planning-close-gate.sh @@ -0,0 +1,357 @@ +#!/usr/bin/env bash +set -euo pipefail + +PRODUCT_ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase59-rebuild-planning-close-gate}" +KUBECTL="${KUBECTL:-kubectl}" +NAMESPACE="${SW_BLOCK_PHASE59_NAMESPACE:-sw-block-phase59-rebuild-planning}" +NODE_NAME="${SW_BLOCK_PHASE59_NODE_NAME:-m02}" +RUNNER_IMAGE="${SW_BLOCK_PHASE59_RUNNER_IMAGE:-busybox:1.36}" +IMAGE_PULL_POLICY="${SW_BLOCK_PHASE59_IMAGE_PULL_POLICY:-IfNotPresent}" +TARGET_OWNER_SA="sw-block-rebuild-target-owner" +EXEC_SA="sw-block-authority-executor-exec" +SUMMARY="${ARTIFACT_DIR}/phase59-rebuild-planning-close-summary.txt" +BIN_DIR="${ARTIFACT_DIR}/bin" +VOLUME_NAME="phase59-volume" +REBUILD_TARGET_NAME="phase59-volume-r2-rebuild" +VOLUME_CRD="swblockvolumes.block.seaweedfs.com" +REBUILD_CRD="swblockreplicarebuilds.block.seaweedfs.com" + +mkdir -p "${ARTIFACT_DIR}" "${BIN_DIR}" +: >"${SUMMARY}" + +write_summary() { + echo "$*" | tee -a "${SUMMARY}" >/dev/null +} + +run_capture() { + local name="$1" + shift + "$@" >"${ARTIFACT_DIR}/${name}.stdout.txt" 2>"${ARTIFACT_DIR}/${name}.stderr.txt" +} + +run_expect_success() { + local name="$1" + shift + if run_capture "$name" "$@"; then + return 0 + fi + echo "expected success for ${name}" >&2 + cat "${ARTIFACT_DIR}/${name}.stderr.txt" >&2 || true + return 1 +} + +assert_eq() { + local name="$1" + local actual="$2" + local expected="$3" + write_summary "${name}=${actual}" + if [ "${actual}" != "${expected}" ]; then + echo "${name}: got ${actual}, expected ${expected}" >&2 + return 1 + fi +} + +crd_preexisting() { + local crd="$1" + if "${KUBECTL}" get crd "${crd}" >/dev/null 2>&1; then + echo "true" + else + echo "false" + fi +} + +PREEXISTING_VOLUME_CRD="$(crd_preexisting "${VOLUME_CRD}")" +PREEXISTING_REBUILD_CRD="$(crd_preexisting "${REBUILD_CRD}")" + +cleanup() { + set +e + "${KUBECTL}" delete job -n "${NAMESPACE}" -l block.seaweedfs.com/phase59=true --ignore-not-found >/dev/null 2>&1 + "${KUBECTL}" delete clusterrolebinding sw-block-phase59-rebuild-target-owner sw-block-phase59-authority-executor --ignore-not-found >/dev/null 2>&1 + "${KUBECTL}" delete clusterrole sw-block-phase59-rebuild-target-owner sw-block-phase59-authority-executor --ignore-not-found >/dev/null 2>&1 + "${KUBECTL}" delete namespace "${NAMESPACE}" --ignore-not-found >/dev/null 2>&1 + for _ in $(seq 1 30); do + if ! "${KUBECTL}" get namespace "${NAMESPACE}" >/dev/null 2>&1; then + break + fi + sleep 1 + done + if [ "${PREEXISTING_REBUILD_CRD}" != "true" ]; then + "${KUBECTL}" delete crd "${REBUILD_CRD}" --ignore-not-found >/dev/null 2>&1 + fi + if [ "${PREEXISTING_VOLUME_CRD}" != "true" ]; then + "${KUBECTL}" delete crd "${VOLUME_CRD}" --ignore-not-found >/dev/null 2>&1 + fi +} +trap cleanup EXIT + +write_summary "phase59_rebuild_planning_close_status=running" +write_summary "phase59_node=${NODE_NAME}" +write_summary "preexisting_volume_crd=${PREEXISTING_VOLUME_CRD}" +write_summary "preexisting_rebuild_crd=${PREEXISTING_REBUILD_CRD}" + +run_expect_success kubectl-version "${KUBECTL}" version --client=true +run_expect_success build-sw-block go build -o "${BIN_DIR}/sw-block" "${PRODUCT_ROOT}/cmd/sw-block" +run_expect_success sw-block-version "${BIN_DIR}/sw-block" --version + +run_expect_success apply-volume-crd "${KUBECTL}" apply -f "${PRODUCT_ROOT}/charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml" +run_expect_success apply-rebuild-crd "${KUBECTL}" apply -f "${PRODUCT_ROOT}/charts/seaweed-block/crds/swblockreplicarebuilds.block.seaweedfs.com.yaml" +run_expect_success wait-volume-crd-established "${KUBECTL}" wait --for=condition=Established "crd/${VOLUME_CRD}" --timeout=60s +run_expect_success wait-rebuild-crd-established "${KUBECTL}" wait --for=condition=Established "crd/${REBUILD_CRD}" --timeout=60s + +cat >"${ARTIFACT_DIR}/namespace.yaml" <&2 + cat "${ARTIFACT_DIR}/storage-ready-${name}-60.stderr.txt" >&2 || true + return 1 +} + +wait_crd_storage_ready swblockvolumes swblockvolumes +wait_crd_storage_ready swblockreplicarebuilds swblockreplicarebuilds + +cat >"${ARTIFACT_DIR}/rbac.yaml" <"${ARTIFACT_DIR}/volume.yaml" <"${ARTIFACT_DIR}/volume-status.json" <"${ARTIFACT_DIR}/${name}.yaml" <"${ARTIFACT_DIR}/describe-job-${name}.txt" 2>&1 || true + "${KUBECTL}" logs -n "${NAMESPACE}" "job/${name}" >"${ARTIFACT_DIR}/logs-job-${name}.stdout.txt" 2>"${ARTIFACT_DIR}/logs-job-${name}.stderr.txt" || true + echo "job ${name} did not complete" >&2 + cat "${ARTIFACT_DIR}/wait-job-${name}.stderr.txt" >&2 || true + cat "${ARTIFACT_DIR}/logs-job-${name}.stdout.txt" >&2 || true + return 1 +} + +job_manifest phase59-target-owner-1 "${TARGET_OWNER_SA}" ops rebuild-target-owner "--namespace=${NAMESPACE}" +run_job phase59-target-owner-1 +cat "${ARTIFACT_DIR}/logs-job-phase59-target-owner-1.stdout.txt" >>"${SUMMARY}" + +target_count="$("${KUBECTL}" get swblockreplicarebuilds -n "${NAMESPACE}" --no-headers 2>/dev/null | wc -l | tr -d ' ')" +assert_eq "rebuild_target_count_after_owner" "${target_count}" "1" + +target_volume="$("${KUBECTL}" get swblockreplicarebuilds "${REBUILD_TARGET_NAME}" -n "${NAMESPACE}" -o jsonpath='{.spec.volumeName}')" +target_replica="$("${KUBECTL}" get swblockreplicarebuilds "${REBUILD_TARGET_NAME}" -n "${NAMESPACE}" -o jsonpath='{.spec.replicaID}')" +target_status="$("${KUBECTL}" get swblockreplicarebuilds "${REBUILD_TARGET_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.state}' 2>/dev/null || true)" +assert_eq "rebuild_target_volume_name" "${target_volume}" "${VOLUME_NAME}" +assert_eq "rebuild_target_replica_id" "${target_replica}" "r2" +assert_eq "rebuild_target_status_before_executor" "${target_status}" "" + +job_manifest phase59-target-owner-2 "${TARGET_OWNER_SA}" ops rebuild-target-owner "--namespace=${NAMESPACE}" +run_job phase59-target-owner-2 +cat "${ARTIFACT_DIR}/logs-job-phase59-target-owner-2.stdout.txt" >>"${SUMMARY}" + +target_count="$("${KUBECTL}" get swblockreplicarebuilds -n "${NAMESPACE}" --no-headers 2>/dev/null | wc -l | tr -d ' ')" +assert_eq "rebuild_target_count_after_idempotent_owner" "${target_count}" "1" + +job_manifest phase59-authority-executor "${EXEC_SA}" ops authority-executor "--namespace=${NAMESPACE}" "--allowed-mutation-class=rebuild_traffic" "--enable-execution" "--execution-policy" +run_job phase59-authority-executor +cat "${ARTIFACT_DIR}/logs-job-phase59-authority-executor.stdout.txt" >>"${SUMMARY}" + +planned_state="$("${KUBECTL}" get swblockreplicarebuilds "${REBUILD_TARGET_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.state}')" +planned_reason="$("${KUBECTL}" get swblockreplicarebuilds "${REBUILD_TARGET_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.reasonCode}')" +traffic_started="$("${KUBECTL}" get swblockreplicarebuilds "${REBUILD_TARGET_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.rebuildTrafficStarted}')" +no_frontend="$("${KUBECTL}" get swblockreplicarebuilds "${REBUILD_TARGET_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.noFrontendPublication}')" +no_cross_volume="$("${KUBECTL}" get swblockreplicarebuilds "${REBUILD_TARGET_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.noCrossVolumeIdentityChange}')" +assert_eq "rebuild_status_state_after_executor" "${planned_state}" "planned" +assert_eq "rebuild_status_reason_after_executor" "${planned_reason}" "rebuild_progress_planned" +assert_eq "rebuild_traffic_started_after_executor" "${traffic_started}" "false" +assert_eq "no_frontend_publication_after_executor" "${no_frontend}" "true" +assert_eq "no_cross_volume_identity_change_after_executor" "${no_cross_volume}" "true" + +volume_status="$("${KUBECTL}" get swblockvolume "${VOLUME_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.reasonCode}')" +volume_finalizers="$("${KUBECTL}" get swblockvolume "${VOLUME_NAME}" -n "${NAMESPACE}" -o jsonpath='{.metadata.finalizers}' 2>/dev/null || true)" +assert_eq "swblockvolume_reason_unchanged" "${volume_status}" "candidate_frontier_behind" +assert_eq "swblockvolume_finalizers_unchanged" "${volume_finalizers}" "" + +write_summary "phase59_rebuild_planning_close_status=ok" diff --git a/seaweed-block/testops/scenarios/rebuild-planning-close-chain.yaml b/seaweed-block/testops/scenarios/rebuild-planning-close-chain.yaml new file mode 100644 index 0000000000..a77198e52b --- /dev/null +++ b/seaweed-block/testops/scenarios/rebuild-planning-close-chain.yaml @@ -0,0 +1,112 @@ +# Runner-native Phase 59 gate: returned-replica rebuild planning close path. + +name: rebuild-planning-close-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: rebuild_planning_close_gate + actions: + - action: exec + node: m02 + timeout: 7m + cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close && cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close bash scripts/run-phase59-rebuild-planning-close-gate.sh {{ product_root }}" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^phase59_rebuild_planning_close_status=ok$" + save_as: phase59_ok + - action: assert_greater + actual: "{{ phase59_ok }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^rebuild_target_owner=target_mutation namespace=sw-block-phase59-rebuild-planning volumes=1 contracts=1 targets_planned=1 targets_existing=0 targets_created=1 invalid_contracts=0 mutation_allowed=true storage_mutation_allowed=false frontend_publication_allowed=false failback_allowed=false$" + save_as: target_owner_created + - action: assert_greater + actual: "{{ target_owner_created }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^rebuild_target_owner=target_mutation namespace=sw-block-phase59-rebuild-planning volumes=1 contracts=1 targets_planned=1 targets_existing=1 targets_created=0 invalid_contracts=0 mutation_allowed=false storage_mutation_allowed=false frontend_publication_allowed=false failback_allowed=false$" + save_as: target_owner_idempotent + - action: assert_greater + actual: "{{ target_owner_idempotent }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^rebuild_target_count_after_owner=1$" + save_as: target_count_one + - action: assert_greater + actual: "{{ target_count_one }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^rebuild_target_status_before_executor=$" + save_as: target_status_empty + - action: assert_greater + actual: "{{ target_status_empty }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^authority_executor=executed namespace=sw-block-phase59-rebuild-planning volumes=1 contracts=1 disabled_contracts=1 blocked_contracts=0 terminal_evidence_required=1 terminal_evidence_missing=0 ack_eligibility_target_missing=0 rebuild_target_missing=0 allowed_mutation_class=rebuild_traffic execution_requested=true execution_policy_enabled=true mutation_attempts=1 ack_eligibility_mutation_attempts=0 rebuild_progress_mutation_attempts=1 mutation_allowed=true storage_mutation_allowed=false$" + save_as: executor_executed + - action: assert_greater + actual: "{{ executor_executed }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^rebuild_status_state_after_executor=planned$" + save_as: rebuild_planned + - action: assert_greater + actual: "{{ rebuild_planned }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^rebuild_traffic_started_after_executor=false$" + save_as: no_traffic + - action: assert_greater + actual: "{{ no_traffic }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^no_frontend_publication_after_executor=true$" + save_as: no_frontend + - action: assert_greater + actual: "{{ no_frontend }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close/phase59-rebuild-planning-close-summary.txt" + pattern: "^swblockvolume_reason_unchanged=candidate_frontier_behind$" + save_as: volume_unchanged + - action: assert_greater + actual: "{{ volume_unchanged }}" + threshold: "0" + + - name: collect + always: true + actions: + - action: collect_path + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase59-rebuild-planning-close" + name: "remote-phases" + ignore_error: true