diff --git a/seaweed-block/docs/roadmap.md b/seaweed-block/docs/roadmap.md index e44f594d44..b1047ac897 100644 --- a/seaweed-block/docs/roadmap.md +++ b/seaweed-block/docs/roadmap.md @@ -176,16 +176,17 @@ Recommended order from here: read-only `SwBlockVolume` access. It consumes executor contracts and fails closed on execution-enabled or mutating contracts, but still performs no ACK eligibility mutation, frontend publication, rebuild traffic, or failback. -11. Phase 54: returned-replica reintegration executor milestone. **In progress** - (`internal/docs/current-plan.md`). +11. Phase 54: returned-replica reintegration executor milestone. **Closed 2026-06-23, QA PASS** + (`internal/docs/finished-plans/phase54_finishedplan_returned_replica_reintegration_executor.md`). This is intentionally larger than the previous safety-latch phases. It groups executor policy, the ACK eligibility mutation target, admission/RBAC, terminal evidence, failure states, multi-volume isolation, and a live close gate into one milestone. The first allowed mutation remains narrow: - returned-replica ACK eligibility only. D1-D6 are implemented and live QA - passed through the RBAC boundary, executor call-site terminal-evidence gate, - negative/hold matrix, and dedicated multi-volume isolation. D7 remains for - the live returned-replica close gate. + returned-replica ACK eligibility only. D1-D7 passed live QA through the RBAC + boundary, executor call-site terminal-evidence gate, negative/hold matrix, + dedicated multi-volume isolation, and the live returned-replica close gate. + Frontend publication, rebuild traffic, and automatic failback remain + non-claims. 12. 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. @@ -195,9 +196,10 @@ The internal release-train contract is the operation-layer loop for a bounded `SwBlockVolume` protection finalizer. Phase 46 reused this same fact -> judgment -> action -> evidence pattern for returned-replica reintegration before any larger storage feature is enabled. -Phases 47-53 close the executor-admission, preflight, status-schema, ACK -evidence, executor-contract, and disabled executor-process bridge without -allowing mutation. +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. The practical rule is: diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index 976142144a..64db661bf0 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -308,7 +308,9 @@ Acceptance: ### D7: Live Close Gate -Run the returned-replica live chain with the executor policy enabled only for +Status: **QA PASS** (`20260623-114709-aa80`, 34/34 actions). + +Ran the returned-replica live chain with the executor policy enabled only for the bounded ACK eligibility path. Acceptance: @@ -321,6 +323,23 @@ Acceptance: - final report/dashboard/CRD agree, - TestRunner bundle captures enough evidence for QA review. +Closed evidence: + +```text +previous_primary_frontend_fenced=true +current_primary_unchanged=true +durable_frontier_covered=true +executor_ack_mutation_attempts=1 +target_reason=ack_eligibility_recorded +target_ack_eligible=true +target_frontend_fenced=true +target_primary_unchanged=true +target_frontier_covered=true +target_no_cross_volume=true +source_ack_still_false=false +target_nonclaims_ok=true +``` + ## Validation Plan Minimum local checks: @@ -342,17 +361,17 @@ returned-replica multi-volume isolation gate returned-replica live close gate ``` -## Non-Claims Until D7 Passes +## Remaining Non-Claims After D7 -- No productized returned-replica rebuild. - No automatic failback. - No frontend publication. - No rebuild/catch-up traffic. +- No broad returned-replica rebuild claim. - No production HA/SLO claim. ## Exit -Phase 54 closes only when the bounded ACK eligibility mutation is proven end to -end with live evidence and multi-volume isolation. If D2 concludes the correct -ACK eligibility target is not ready, the phase should stop at a documented -design blocker rather than implement a fake mutation path. +Phase 54 is closed. The bounded ACK eligibility mutation is proven end to end +with live returned-replica evidence and multi-volume isolation. The only +executor-owned mutation is `SwBlockReplicaEligibility.status`; broader rebuild, +frontend publication, and failback remain explicitly out of scope. diff --git a/seaweed-block/internal/docs/finished-plans/phase54_finishedplan_returned_replica_reintegration_executor.md b/seaweed-block/internal/docs/finished-plans/phase54_finishedplan_returned_replica_reintegration_executor.md new file mode 100644 index 0000000000..cc4ec3ca4b --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase54_finishedplan_returned_replica_reintegration_executor.md @@ -0,0 +1,110 @@ +# Phase 54 Finished Plan: Returned-Replica Reintegration Executor Milestone + +Status: complete. + +Branch: `phase54-returned-replica-reintegration-executor` + +## Summary + +Phase 54 turns returned-replica reintegration from a non-mutating status model +into the first bounded executor capability. + +The only productized mutation is narrow: + +```text +record returned-replica ACK eligibility on SwBlockReplicaEligibility.status +``` + +The executor still does not publish a frontend, start rebuild/catch-up traffic, +change primary authority, perform failback, mutate broad `SwBlockVolume.status`, +or touch another volume. + +## What Changed + +- Added the `ack_eligibility` execution policy gate to `sw-block ops + authority-executor`. +- Added `SwBlockReplicaEligibility` as the narrow ACK eligibility target CRD. +- Added Kubernetes status writer support for + `SwBlockReplicaEligibility.status`. +- Added execution RBAC that can patch only + `swblockreplicaeligibilities/status`. +- Connected the executor call-site to terminal returned-replica evidence: + - ACK eligibility known, + - ACK ineligible before execution, + - frontend still fenced, + - primary unchanged, + - durable frontier covered, + - no cross-volume identity change. +- Added negative/hold handling for unsafe, stale, missing, ambiguous, and + mismatched evidence. +- Added dedicated multi-volume isolation and live close gates. + +## Closed Acceptance + +```text +default executor remains disabled +unsupported mutation class fails closed +missing target holds with zero mutation +terminal evidence missing holds with zero mutation +unsafe frontend/frontier/preflight states hold with zero mutation +ambiguous or mismatched target holds with zero mutation +complete terminal evidence writes exactly one target status +multi-volume reconcile does not contaminate other volumes +live returned-replica path writes ACK eligibility only after real evidence +executor cannot patch SwBlockVolume status/finalizers/main object +executor cannot create Events or mutate pods/PVCs/storageclasses +cleanup remains zero-residue +``` + +## Validation + +Local checks: + +```text +go test ./core/ops ./cmd/sw-block +helm lint charts/seaweed-block +swblock validate testops/scenarios/authority-executor-target-rbac-chain.yaml +swblock validate testops/scenarios/authority-executor-callsite-chain.yaml +swblock validate testops/scenarios/authority-executor-negative-chain.yaml +swblock validate testops/scenarios/authority-executor-multivolume-chain.yaml +swblock validate testops/scenarios/authority-executor-live-close-chain.yaml +``` + +Live QA: + +```text +D3 target RBAC: PASS, 14/14 +D4 call-site terminal evidence: PASS, 36/36, run 20260623-110832-6b9c +D5 negative/hold matrix: PASS, 26/26, run 20260623-112339-a395 +D6 multi-volume isolation: PASS, 32/32, run 20260623-113753-d07f +D7 live close gate: PASS, 34/34, run 20260623-114709-aa80 +``` + +## Product Outcome + +The returned-replica operation layer now has a full fact -> judgment -> action +-> evidence loop for the first bounded authority executor write. + +The write is deliberately not a rebuild or failback. It records that a +returned replica is eligible to participate in ACK decisions after live +terminal evidence proves the old primary is fenced, the current primary is +unchanged, and the durable frontier is covered. + +## Remaining Non-Claims + +- No frontend publication. +- No rebuild/catch-up traffic. +- No automatic failback. +- No broad returned-replica rebuild product claim. +- No production HA/SLO claim. +- No release-image claim until the release smoke runs on published images. + +## Next Step + +The next milestone can choose one of two directions: + +- release hardening if this executor capability is intended for a v0.5/v0.6 + beta cut, +- or the next operation owner that can reuse the same evidence/action boundary, + such as returned-replica rebuild execution, node cleanup execution, or NVMe + ANA parity. diff --git a/seaweed-block/internal/docs/qa-assignments/phase54-d7-authority-executor-live-close-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase54-d7-authority-executor-live-close-qa-signoff.md new file mode 100644 index 0000000000..38c3b7f5bf --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase54-d7-authority-executor-live-close-qa-signoff.md @@ -0,0 +1,102 @@ +# Phase 54 D7 QA Sign-off: Authority Executor Live Close Gate + +Verdict: **PASS**. + +Validated live on m02 with the current Phase 54 tree and `sw-block:local` +executor image. + +Runner: + +```text +C:\work\swblock.exe run -results-dir C:\work\seaweed_block\results C:\work\seaweed_block\testops\scenarios\authority-executor-live-close-chain.yaml +``` + +Run: + +```text +20260623-114709-aa80 +authority-executor-live-close-chain PASS, 34/34 actions +``` + +## Evidence + +Summary: + +```text +phase54_authority_executor_live_close_status=running +phase54_authority_executor_image=sw-block:local +phase54_authority_executor_node=m02 +failover_pass_count=1 +r1_return_phase_count=1 +pre_checksum_count=1 +post_checksum_count=1 +r1_returned_supporting_log_count=1 +r1_returned_recovery_log_count=1 +phase54_live_evidence_status=ok +previous_primary_non_primary=true +previous_primary_frontend_fenced=true +current_primary_before=true +current_primary_after=true +current_primary_unchanged=true +required_frontier_lsn=6364 +r1_durable_lsn=6364 +r2_durable_lsn=6364 +durable_frontier_covered=true +report_returned_replica_projection_count=1 +report_action_allowed_count=1 +explain_action_count=1 +dashboard_action_count=1 +exec_patch_swblockreplicaeligibilities_status_allowed=yes +exec_patch_swblockreplicaeligibilities_main_denied=no +exec_patch_swblockvolumes_status_denied=no +exec_create_events_denied=no +exec_create_pods_denied=no +exec_patch_pvc_denied=no +executor_contracts=1 +executor_mutation_attempts=1 +executor_ack_mutation_attempts=1 +executor_terminal_missing=0 +executor_target_missing=0 +target_reason=ack_eligibility_recorded +target_ack_known=true +target_ack_eligible=true +target_frontend_fenced=true +target_primary_unchanged=true +target_frontier_covered=true +target_no_cross_volume=true +source_ack_still_false=false +target_nonclaims_ok=true +phase54_authority_executor_live_close_status=ok +``` + +## Gate Results + +| Check | Result | +| --- | --- | +| Live iSCSI/ALUA returned-replica path | PASS: failover and returned-r1 phase completed | +| Workload integrity | PASS: pre/post checksum checks passed | +| Previous primary fencing | PASS: r1 non-primary and frontend-fenced | +| Current primary stability | PASS: r2 primary before and after r1 return | +| Durable frontier | PASS: r1 durable LSN 6364 covers required LSN 6364 | +| Report/explain/dashboard | PASS: all show `authority.reintegrate_returned_replica` as allowed dry-run on the storage evidence surface | +| Executor mutation | PASS: exactly one ACK eligibility status write | +| Target CRD status | PASS: `ack_eligibility_recorded`, ACK eligible, frontend fenced, primary unchanged, frontier covered, no cross-volume identity change | +| Source volume status | PASS: source `ackEligible` remains false; broad `SwBlockVolume.status` is not rewritten by the executor | +| Non-claims | PASS: target status carries no frontend publication, no rebuild traffic, and no failback non-claims | +| RBAC boundary | PASS: only target status patch allowed; target main, SwBlockVolume status, Events, pods, and PVC mutation denied | +| Cleanup | PASS: no active iSCSI sessions, no block processes, no Phase 54 namespace/CR/CRD/job/pod/PVC/PV residue | + +## Harness Note + +The first D7 attempt failed before product execution because m02's +`/tmp/seaweed_block` product root is a synced tree, not a git worktree. The +gate now records git revision best-effort and does not require `.git`. + +## Verdict + +D7 closes. Phase 54 has live evidence that the returned-replica path can +advance exactly one bounded executor-owned fact: ACK eligibility on the matching +`SwBlockReplicaEligibility.status`. + +Remaining non-claims still hold: no frontend publication, no rebuild traffic, +no automatic failback, and no production HA/SLO claim. diff --git a/seaweed-block/internal/docs/qa-assignments/phase54-d7-authority-executor-live-close-qa.md b/seaweed-block/internal/docs/qa-assignments/phase54-d7-authority-executor-live-close-qa.md new file mode 100644 index 0000000000..ff0202592d --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase54-d7-authority-executor-live-close-qa.md @@ -0,0 +1,59 @@ +# Phase 54 D7 QA: Authority Executor Live Close Gate + +Status: implemented and validated live. + +Runner scenario: + +```text +testops/scenarios/authority-executor-live-close-chain.yaml +``` + +Gate script: + +```text +scripts/run-phase54-authority-executor-live-close-gate.sh +``` + +## Goal + +Validate the full Phase 54 close path with live storage evidence: + +1. Run the real iSCSI/ALUA returned-replica failover path. +2. Confirm the old primary returns as a fenced, non-primary replica. +3. Confirm the current primary remains primary. +4. Confirm the returned replica covers the required durable frontier. +5. Enable only the bounded `ack_eligibility` executor mutation. +6. Write exactly one matching `SwBlockReplicaEligibility.status`. + +This gate is intentionally narrow. It proves ACK eligibility can be recorded +after terminal evidence is complete. It does not claim frontend publication, +rebuild traffic, automatic failback, or production HA/SLO behavior. + +## Required Properties + +- Previous primary remains non-primary and frontend-fenced. +- Current primary remains unchanged after the old primary returns. +- Returned replica durable frontier covers the required frontier. +- Report, explain, and dashboard all show the same returned-replica action as + allowed but dry-run on the storage evidence surface. +- The executor performs exactly one ACK eligibility status mutation on the + matching `SwBlockReplicaEligibility`. +- The target status records: + - `reasonCode=ack_eligibility_recorded`, + - `ackEligibilityKnown=true`, + - `ackEligible=true`, + - `frontendFencedAfterExecution=true`, + - `primaryUnchanged=true`, + - `durableFrontierCovered=true`, + - `noCrossVolumeIdentityChange=true`. +- The source `SwBlockVolume.status.replicaReintegrations[].ackEligible` + remains `false`; the executor does not rewrite broad volume status. +- Target non-claims explicitly preserve no frontend publication, no rebuild + traffic, and no failback. +- RBAC boundary remains narrow: + - can patch `swblockreplicaeligibilities/status`, + - cannot patch `swblockreplicaeligibilities` main objects, + - cannot patch `SwBlockVolume.status`, + - cannot create Events, pods, or patch PVCs. +- Cleanup leaves no iSCSI, process, namespace, CR, CRD, job, pod, PVC, or PV + residue. diff --git a/seaweed-block/scripts/run-phase54-authority-executor-live-close-gate.sh b/seaweed-block/scripts/run-phase54-authority-executor-live-close-gate.sh new file mode 100644 index 0000000000..6e7d7da3fc --- /dev/null +++ b/seaweed-block/scripts/run-phase54-authority-executor-live-close-gate.sh @@ -0,0 +1,489 @@ +#!/usr/bin/env bash +set -euo pipefail + +PRODUCT_ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase54-authority-executor-live-close-gate}" +KUBECTL="${KUBECTL:-kubectl}" +NAMESPACE="${SW_BLOCK_PHASE54_NAMESPACE:-sw-block-phase54-authority-executor-live-close}" +EXEC_SA="sw-block-authority-executor-exec" +EXEC_USER="system:serviceaccount:${NAMESPACE}:${EXEC_SA}" +IMAGE="${SW_BLOCK_PHASE54_IMAGE:-sw-block:local}" +IMAGE_PULL_POLICY="${SW_BLOCK_PHASE54_IMAGE_PULL_POLICY:-IfNotPresent}" +NODE_NAME="${SW_BLOCK_PHASE54_NODE_NAME:-m02}" +WORK_DIR="${SW_BLOCK_ISCSI_FAILOVER_WORK_DIR:-/tmp/sw-block-phase54-live-close}" +BIN_DIR="${ARTIFACT_DIR}/bin" +FAILOVER_DIR="${ARTIFACT_DIR}/returned_failover" +SUMMARY="${ARTIFACT_DIR}/phase54-authority-executor-live-close-summary.txt" + +mkdir -p "${ARTIFACT_DIR}" "${BIN_DIR}" "${FAILOVER_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 +} + +jsonpath() { + local resource="$1" + local path="$2" + "${KUBECTL}" get "${resource}" -n "${NAMESPACE}" -o "jsonpath=${path}" 2>/dev/null || true +} + +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 +} + +assert_file_contains() { + local name="$1" + local file="$2" + local pattern="$3" + local count + count="$(grep -Ec "${pattern}" "${file}" || true)" + write_summary "${name}=${count}" + if [ "${count}" = "0" ]; then + echo "${name}: pattern ${pattern} not found in ${file}" >&2 + return 1 + fi +} + +can_i_as() { + local name="$1" + local expected="$2" + shift 2 + run_capture "can-i-${name}" "${KUBECTL}" auth can-i "$@" --as "${EXEC_USER}" -n "${NAMESPACE}" || true + local actual + actual="$(tr -d '\r\n' <"${ARTIFACT_DIR}/can-i-${name}.stdout.txt")" + assert_eq "${name}" "${actual}" "${expected}" +} + +cleanup_crds_if_empty() { + local volume_count eligibility_count + volume_count="$("${KUBECTL}" get swblockvolumes -A --no-headers 2>/dev/null | wc -l | tr -d ' ')" + eligibility_count="$("${KUBECTL}" get swblockreplicaeligibilities -A --no-headers 2>/dev/null | wc -l | tr -d ' ')" + if [ "${volume_count}" = "0" ] && [ "${eligibility_count}" = "0" ]; then + "${KUBECTL}" delete crd swblockvolumes.block.seaweedfs.com swblockreplicaeligibilities.block.seaweedfs.com --ignore-not-found >/dev/null 2>&1 || true + fi +} + +cleanup() { + set +e + "${KUBECTL}" delete job -n "${NAMESPACE}" -l block.seaweedfs.com/phase54-live-close=true --ignore-not-found >/dev/null 2>&1 + "${KUBECTL}" delete clusterrolebinding sw-block-phase54-authority-executor-live-close --ignore-not-found >/dev/null 2>&1 + "${KUBECTL}" delete clusterrole sw-block-phase54-authority-executor-live-close --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 + cleanup_crds_if_empty +} +trap cleanup EXIT + +write_summary "phase54_authority_executor_live_close_status=running" +write_summary "phase54_authority_executor_image=${IMAGE}" +write_summary "phase54_authority_executor_node=${NODE_NAME}" + +if git -C "${PRODUCT_ROOT}" rev-parse HEAD >"${ARTIFACT_DIR}/git.sha" 2>"${ARTIFACT_DIR}/git.stderr.txt"; then + git -C "${PRODUCT_ROOT}" status --short >"${ARTIFACT_DIR}/git.status" 2>>"${ARTIFACT_DIR}/git.stderr.txt" || true +else + echo "unknown" >"${ARTIFACT_DIR}/git.sha" + echo "product root is not a git worktree: ${PRODUCT_ROOT}" >>"${ARTIFACT_DIR}/git.stderr.txt" +fi + +run_expect_success "build-blockmaster" go build -o "${BIN_DIR}/blockmaster" "${PRODUCT_ROOT}/cmd/blockmaster" +run_expect_success "build-blockvolume" go build -o "${BIN_DIR}/blockvolume" "${PRODUCT_ROOT}/cmd/blockvolume" +run_expect_success "build-sw-block" go build -o "${BIN_DIR}/sw-block" "${PRODUCT_ROOT}/cmd/sw-block" + +run_expect_success "blockmaster-version" "${BIN_DIR}/blockmaster" --version +run_expect_success "blockvolume-version" "${BIN_DIR}/blockvolume" --version +run_expect_success "sw-block-version" "${BIN_DIR}/sw-block" --version + +SW_BLOCK_ARTIFACT_DIR="${FAILOVER_DIR}" \ +SW_BLOCK_BIN_DIR="${BIN_DIR}" \ +SW_BLOCK_ISCSI_FAILOVER_WORK_DIR="${WORK_DIR}" \ +SW_BLOCK_RETURN_R1_AFTER_FAILOVER=1 \ +SW_BLOCK_DEGRADED_PROBE_INTERVAL=1s \ +SW_BLOCK_DEGRADED_PROBE_COOLDOWN_BASE=1s \ +SW_BLOCK_DEGRADED_PROBE_COOLDOWN_CAP=3s \ + bash "${PRODUCT_ROOT}/scripts/run-iscsi-alua-mounted-failover-smoke.sh" "${PRODUCT_ROOT}" \ + >"${ARTIFACT_DIR}/returned-failover.stdout.txt" 2>"${ARTIFACT_DIR}/returned-failover.stderr.txt" + +assert_file_contains "failover_pass_count" "${FAILOVER_DIR}/run.log" "\\[iscsi-failover\\] PASS:" +assert_file_contains "r1_return_phase_count" "${FAILOVER_DIR}/run.log" "restart returned r1 after r2 promotion" +assert_file_contains "pre_checksum_count" "${FAILOVER_DIR}/pre-check-after-failover.log" "/pre.bin: OK" +assert_file_contains "post_checksum_count" "${FAILOVER_DIR}/post-check.log" "/post.bin: OK" +assert_file_contains "r1_returned_supporting_log_count" "${FAILOVER_DIR}/blockvolume-r1-returned.log" "admitted as SUPPORTING replica r1" +assert_file_contains "r1_returned_recovery_log_count" "${FAILOVER_DIR}/blockvolume-r1-returned.log" "durable recovered: recovered LSN=" + +python3 - "${FAILOVER_DIR}" <<'PY' +import json +import pathlib +import sys + +root = pathlib.Path(sys.argv[1]) +r1 = json.loads((root / "status-r1-returned.json").read_text()) +r2_before = json.loads((root / "status-r2-healthy.json").read_text()) +r2_after = json.loads((root / "status-r2-after-r1-return.json").read_text()) +dr1 = json.loads((root / "status-durable-r1-returned.json").read_text())["Volumes"][0] +dr2 = json.loads((root / "status-durable-r2-primary-after-r1-return.json").read_text())["Volumes"][0] + +required = int(dr2.get("DurableLSN") or 0) +r1_durable = int(dr1.get("DurableLSN") or 0) +r2_durable = int(dr2.get("DurableLSN") or 0) +r1_non_primary = str(r1.get("AuthorityRole") != "primary").lower() +r1_frontend_fenced = str(r1.get("FrontendPrimaryReady") is False).lower() +r2_primary_before = str(r2_before.get("AuthorityRole") == "primary").lower() +r2_primary_after = str(r2_after.get("AuthorityRole") == "primary").lower() +r2_primary_unchanged = str(r2_primary_before == "true" and r2_primary_after == "true").lower() +frontier_covered = str(r1_durable >= required and required > 0).lower() + +(root / "phase54-live-derived-summary.txt").write_text("\n".join([ + "phase54_live_evidence_status=ok", + f"previous_primary_non_primary={r1_non_primary}", + f"previous_primary_frontend_fenced={r1_frontend_fenced}", + f"current_primary_before={r2_primary_before}", + f"current_primary_after={r2_primary_after}", + f"current_primary_unchanged={r2_primary_unchanged}", + f"required_frontier_lsn={required}", + f"r1_durable_lsn={r1_durable}", + f"r2_durable_lsn={r2_durable}", + f"durable_frontier_covered={frontier_covered}", +]) + "\n") + +if not (r1_non_primary == r1_frontend_fenced == r2_primary_before == r2_primary_after == r2_primary_unchanged == frontier_covered == "true"): + raise SystemExit("live returned-replica evidence did not satisfy D7 preconditions") +PY + +while IFS= read -r line; do + write_summary "${line}" +done <"${FAILOVER_DIR}/phase54-live-derived-summary.txt" + +mkdir -p "${FAILOVER_DIR}/product-observation" "${FAILOVER_DIR}/report" +python3 - "${FAILOVER_DIR}" <<'PY' +import datetime +import json +import pathlib +import sys + +root = pathlib.Path(sys.argv[1]) +r1 = json.loads((root / "status-r1-returned.json").read_text()) +r2 = json.loads((root / "status-r2-after-r1-return.json").read_text()) +dr1 = json.loads((root / "status-durable-r1-returned.json").read_text())["Volumes"][0] +dr2 = json.loads((root / "status-durable-r2-primary-after-r1-return.json").read_text())["Volumes"][0] +required = int(dr2.get("DurableLSN") or 0) +r1_durable = int(dr1.get("DurableLSN") or 0) +cluster = { + "schema_version": "1.0", + "captured_at": datetime.datetime.now(datetime.timezone.utc).isoformat().replace("+00:00", "Z"), + "product_revision": "phase54-live-close", + "status": "recovering", + "volumes": [{ + "volume_id": "v1", + "namespace": "testops", + "pvc_name": "iscsi-returned-replica-chain", + "replication_factor": 2, + "ack_profile": "sync-quorum", + "status": "recovering", + "reason": "returned_replica_frontend_fenced", + "primary_replica": "r2", + "primary_node": "m02", + "publish_target": "127.0.0.1:3281", + "epoch": int(r2.get("Epoch") or 0), + "endpoint_version": int(r2.get("EndpointVersion") or 0), + "required_frontier_known": required > 0, + "required_frontier_lsn": required, + "replicas": [{ + "replica_id": "r1", + "server_id": "s1", + "kubernetes_node": "m02", + "observed": True, + "role": "returned", + "replication_role": str(r1.get("ReplicationRole") or "replica_ready"), + "durable_latched": bool(dr1.get("Latched")), + "durable_frontier_known": bool(dr1.get("FrontierKnown")), + "durable_frontier_lsn": r1_durable, + "healthy": bool(r1.get("Healthy")), + "frontend_primary_ready": bool(r1.get("FrontendPrimaryReady")), + "frontend_protocol": "iscsi", + "frontend_addr": "127.0.0.1:3280", + "status_addr": "127.0.0.1:19603", + "stale_primary_fenced": True, + "support_bundle_path": "status-r1-returned.json" + }, { + "replica_id": "r2", + "server_id": "s2", + "kubernetes_node": "m02", + "observed": True, + "role": "primary", + "replication_role": str(r2.get("ReplicationRole") or "none"), + "durable_latched": bool(dr2.get("Latched")), + "durable_frontier_known": bool(dr2.get("FrontierKnown")), + "durable_frontier_lsn": required, + "healthy": bool(r2.get("Healthy")), + "frontend_primary_ready": bool(r2.get("FrontendPrimaryReady")), + "frontend_protocol": "iscsi", + "frontend_addr": "127.0.0.1:3281", + "status_addr": "127.0.0.1:19613" + }] + }], + "non_claims": ["no automatic returned-replica failback or rebuild mutation executed"] +} +(root / "product-observation" / "cluster-evidence.json").write_text(json.dumps(cluster, indent=2) + "\n") +PY + +run_expect_success "ops-report" "${BIN_DIR}/sw-block" ops report --from-bundle "${FAILOVER_DIR}" --out "${FAILOVER_DIR}/report" +run_expect_success "ops-explain" "${BIN_DIR}/sw-block" ops explain volume --from-bundle "${FAILOVER_DIR}" v1 +cp "${ARTIFACT_DIR}/ops-explain.stdout.txt" "${FAILOVER_DIR}/explain.txt" + +dashboard_port=19488 +"${BIN_DIR}/sw-block" ops dashboard --from-bundle "${FAILOVER_DIR}" --listen "127.0.0.1:${dashboard_port}" --serve-duration 8s \ + >"${FAILOVER_DIR}/dashboard.stdout.txt" 2>"${FAILOVER_DIR}/dashboard.stderr.txt" & +dashboard_pid=$! +for _ in $(seq 1 80); do + if curl -fsS "http://127.0.0.1:${dashboard_port}/operator-snapshot.json" >"${FAILOVER_DIR}/dashboard-operator-snapshot.json" 2>"${FAILOVER_DIR}/dashboard-curl.stderr.txt"; then + break + fi + sleep 0.1 +done +test -s "${FAILOVER_DIR}/dashboard-operator-snapshot.json" +wait "${dashboard_pid}" || true + +assert_file_contains "report_returned_replica_projection_count" "${FAILOVER_DIR}/report/summary.txt" "managed_volume_returned_replica=v1 replica=r1 state=fenced reason=returned_replica_frontend_fenced" +assert_file_contains "report_action_allowed_count" "${FAILOVER_DIR}/report/summary.txt" "managed_volume_action=authority.reintegrate_returned_replica mode=dry_run side_effect=authority_mutating executor=authority_recovery_executor decision=allowed" +assert_file_contains "explain_action_count" "${FAILOVER_DIR}/explain.txt" "managed_volume_action authority.reintegrate_returned_replica mode=dry_run" +assert_file_contains "dashboard_action_count" "${FAILOVER_DIR}/dashboard-operator-snapshot.json" "\"type\": \"authority.reintegrate_returned_replica\"" + +run_expect_success kubectl-version "${KUBECTL}" version --client=true +run_expect_success apply-volume-crd "${KUBECTL}" apply -f "${PRODUCT_ROOT}/charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml" +run_expect_success apply-eligibility-crd "${KUBECTL}" apply -f "${PRODUCT_ROOT}/charts/seaweed-block/crds/swblockreplicaeligibilities.block.seaweedfs.com.yaml" + +cat >"${ARTIFACT_DIR}/namespace.yaml" <"${ARTIFACT_DIR}/rbac.yaml" <"${ARTIFACT_DIR}/live-returned.yaml" <"${ARTIFACT_DIR}/live-returned-status.json" <"${ARTIFACT_DIR}/live-r1-target.yaml" </dev/null 2>&1 || true +cat >"${ARTIFACT_DIR}/${job_name}.yaml" <"${ARTIFACT_DIR}/executor-job-describe.txt" 2>&1 || true + "${KUBECTL}" logs "job/${job_name}" -n "${NAMESPACE}" >"${ARTIFACT_DIR}/executor.log" 2>&1 || true + cat "${ARTIFACT_DIR}/executor.log" >&2 || true + exit 1 +fi +run_expect_success logs-executor-job "${KUBECTL}" logs "job/${job_name}" -n "${NAMESPACE}" +cp "${ARTIFACT_DIR}/logs-executor-job.stdout.txt" "${ARTIFACT_DIR}/executor.log" + +if ! grep -q "authority_executor=executed" "${ARTIFACT_DIR}/executor.log"; then + echo "executor did not report executed" >&2 + cat "${ARTIFACT_DIR}/executor.log" >&2 + exit 1 +fi + +assert_eq "executor_contracts" "$(grep -o 'contracts=[0-9]*' "${ARTIFACT_DIR}/executor.log" | head -1 | cut -d= -f2)" "1" +assert_eq "executor_mutation_attempts" "$(grep -o 'mutation_attempts=[0-9]*' "${ARTIFACT_DIR}/executor.log" | head -1 | cut -d= -f2)" "1" +assert_eq "executor_ack_mutation_attempts" "$(grep -o 'ack_eligibility_mutation_attempts=[0-9]*' "${ARTIFACT_DIR}/executor.log" | head -1 | cut -d= -f2)" "1" +assert_eq "executor_terminal_missing" "$(grep -o 'terminal_evidence_missing=[0-9]*' "${ARTIFACT_DIR}/executor.log" | head -1 | cut -d= -f2)" "0" +assert_eq "executor_target_missing" "$(grep -o 'ack_eligibility_target_missing=[0-9]*' "${ARTIFACT_DIR}/executor.log" | head -1 | cut -d= -f2)" "0" + +assert_eq "target_reason" "$(jsonpath swblockreplicaeligibility/live-r1 '{.status.reasonCode}')" "ack_eligibility_recorded" +assert_eq "target_ack_known" "$(jsonpath swblockreplicaeligibility/live-r1 '{.status.ackEligibilityKnown}')" "true" +assert_eq "target_ack_eligible" "$(jsonpath swblockreplicaeligibility/live-r1 '{.status.ackEligible}')" "true" +assert_eq "target_frontend_fenced" "$(jsonpath swblockreplicaeligibility/live-r1 '{.status.frontendFencedAfterExecution}')" "true" +assert_eq "target_primary_unchanged" "$(jsonpath swblockreplicaeligibility/live-r1 '{.status.primaryUnchanged}')" "true" +assert_eq "target_frontier_covered" "$(jsonpath swblockreplicaeligibility/live-r1 '{.status.durableFrontierCovered}')" "true" +assert_eq "target_no_cross_volume" "$(jsonpath swblockreplicaeligibility/live-r1 '{.status.noCrossVolumeIdentityChange}')" "true" +assert_eq "source_ack_still_false" "$(jsonpath swblockvolume/live-returned '{.status.replicaReintegrations[0].ackEligible}')" "false" + +run_expect_success target-json "${KUBECTL}" get swblockreplicaeligibility live-r1 -n "${NAMESPACE}" -o json +if grep -Eq 'frontend publication|rebuild traffic|failback' "${ARTIFACT_DIR}/target-json.stdout.txt"; then + write_summary "target_nonclaims_ok=true" +else + echo "target non-claims missing frontend/rebuild/failback entries" >&2 + exit 1 +fi + +run_capture delete-synthetic-objects "${KUBECTL}" delete swblockvolumes,swblockreplicaeligibilities --all -n "${NAMESPACE}" --ignore-not-found || true +write_summary "phase54_authority_executor_live_close_status=ok" diff --git a/seaweed-block/testops/scenarios/authority-executor-live-close-chain.yaml b/seaweed-block/testops/scenarios/authority-executor-live-close-chain.yaml new file mode 100644 index 0000000000..a89e7675a3 --- /dev/null +++ b/seaweed-block/testops/scenarios/authority-executor-live-close-chain.yaml @@ -0,0 +1,166 @@ +# Runner-native Phase 54 D7 gate: live returned-replica close with bounded ACK eligibility execution. + +name: authority-executor-live-close-chain +timeout: 22m + +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: pre_clean + actions: + - action: pre_run_cleanup + node: m02 + kill_patterns: "blockmaster,blockvolume,iscsi-target" + unmount: "/tmp/sw-block-phase54-live-close/mnt" + nvme_disconnect: "true" + iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs" + - action: assert_no_active_iscsi_sessions + node: m02 + iqn_substr: "io.seaweedfs" + - action: assert_no_processes + node: m02 + pattern: "[/]blockmaster --|[/]blockvolume --|^blockmaster |^blockvolume " + + - name: authority_executor_live_close_gate + actions: + - action: exec + node: m02 + timeout: 18m + cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close && cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close bash scripts/run-phase54-authority-executor-live-close-gate.sh {{ product_root }}" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^phase54_authority_executor_live_close_status=ok$" + save_as: phase54_live_close_ok + - action: assert_greater + actual: "{{ phase54_live_close_ok }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^previous_primary_frontend_fenced=true$" + save_as: previous_primary_fenced + - action: assert_greater + actual: "{{ previous_primary_fenced }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^current_primary_unchanged=true$" + save_as: current_primary_unchanged + - action: assert_greater + actual: "{{ current_primary_unchanged }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^durable_frontier_covered=true$" + save_as: durable_frontier_covered + - action: assert_greater + actual: "{{ durable_frontier_covered }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^executor_ack_mutation_attempts=1$" + save_as: one_ack_mutation + - action: assert_greater + actual: "{{ one_ack_mutation }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^target_reason=ack_eligibility_recorded$" + save_as: target_ack_recorded + - action: assert_greater + actual: "{{ target_ack_recorded }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^target_ack_eligible=true$" + save_as: target_ack_eligible + - action: assert_greater + actual: "{{ target_ack_eligible }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^target_frontend_fenced=true$" + save_as: target_frontend_fenced + - action: assert_greater + actual: "{{ target_frontend_fenced }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^target_primary_unchanged=true$" + save_as: target_primary_unchanged + - action: assert_greater + actual: "{{ target_primary_unchanged }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^target_frontier_covered=true$" + save_as: target_frontier_covered + - action: assert_greater + actual: "{{ target_frontier_covered }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^target_no_cross_volume=true$" + save_as: target_no_cross_volume + - action: assert_greater + actual: "{{ target_no_cross_volume }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^source_ack_still_false=false$" + save_as: source_ack_unchanged + - action: assert_greater + actual: "{{ source_ack_unchanged }}" + threshold: "0" + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close/phase54-authority-executor-live-close-summary.txt" + pattern: "^target_nonclaims_ok=true$" + save_as: target_nonclaims_ok + - action: assert_greater + actual: "{{ target_nonclaims_ok }}" + threshold: "0" + + - name: final_asserts + actions: + - action: assert_no_active_iscsi_sessions + node: m02 + iqn_substr: "io.seaweedfs" + - action: assert_no_processes + node: m02 + pattern: "[/]blockmaster --|[/]blockvolume --|^blockmaster |^blockvolume " + + - name: collect_and_cleanup + always: true + actions: + - action: pre_run_cleanup + node: m02 + kill_patterns: "blockmaster,blockvolume,iscsi-target" + unmount: "/tmp/sw-block-phase54-live-close/mnt" + nvme_disconnect: "true" + iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs" + - action: collect_path + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase54-authority-executor-live-close" + name: "remote-phases" + ignore_error: true