phase84: add integrated failback grpc smoke

This commit is contained in:
pingqiu committed 2026-06-26 11:40:18 -07:00
1 parent c893ea43b0
commit fa937da78c
7 files changed
+444 -100

No files matched your search

@@ -5,6 +5,7 @@ import (
"testing"
"github.com/seaweedfs/seaweed-block/core/authority"
"github.com/seaweedfs/seaweed-block/core/ops"
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -124,6 +125,90 @@ func TestFailbackServiceEnabledUsesHostRuntime(t *testing.T) {
}
}
func TestFailbackExecutorGRPCRuntimeUsesRealMasterService(t *testing.T) {
h := newTestMasterWithFailbackRuntimeRPC(t)
defer closeTestMaster(t, h)
seedVerifiedExistingReplicaPlacement(t, h)
if _, err := h.RunLifecycleProductTick(); err != nil {
t.Fatalf("product tick: %v", err)
}
current := waitAuthorityLine(t, h.Publisher(), "vol-a")
if current.ReplicaID != "r2" {
t.Fatalf("current line=%+v want r2", current)
}
client := &failbackExecutorMasterServiceClient{
targets: []ops.SwBlockReplicaFailbackObject{{
Ref: ops.OperatorObjectRef{
APIVersion: "block.seaweedfs.com/v1alpha1",
Kind: "SwBlockReplicaFailback",
Namespace: "kube-system",
Name: "vol-a-r1-failback",
},
Spec: ops.SwBlockReplicaFailbackSpec{
VolumeName: "vol-a",
VolumeID: "vol-a",
PVCName: "pvc-a",
ReplicaID: "r1",
TargetDataAddr: "127.0.0.1:9201",
TargetCtrlAddr: "127.0.0.1:9101",
ExpectedCurrentReplicaID: current.ReplicaID,
ExpectedCurrentEpoch: current.Epoch,
AckEligible: true,
FrontendFencedBeforeFailback: true,
DurableFrontierCovered: true,
NoCrossVolumeIdentityChange: true,
FailbackDecision: ops.AuthorityExecutorFailbackDecisionEnabled,
FailbackReason: "failback_requested",
FailbackMutationAllowed: true,
RuntimeEndpoint: "grpc://blockmaster",
},
}},
}
result, err := (ops.FailbackExecutorReconciler{
Namespace: "kube-system",
Client: client,
Runtime: ops.NewGRPCFailbackRuntime(h.Addr()),
ExecutionRequested: true,
ExecutionPolicyEnabled: true,
}).Reconcile(context.Background())
if err != nil {
t.Fatalf("reconcile: %v", err)
}
if result.TargetCount != 1 ||
result.FailbackAttempts != 1 ||
result.StatusWriteCount != 1 ||
!result.AuthorityMutationAllowed ||
result.FrontendPublicationAllowed ||
result.StorageMutationAllowed {
t.Fatalf("result=%+v", result)
}
if len(client.writes) != 1 {
t.Fatalf("writes=%d", len(client.writes))
}
status := client.writes[0].status
if status.State != ops.FailbackStateFailedBack ||
status.ReasonCode != ops.AuthorityExecutorFailbackReasonCompleted ||
!status.FailbackStarted ||
!status.AuthorityEpochAdvanced ||
!status.SinglePrimaryAfterFailback ||
!status.PublishTargetSwappedAfterFailback ||
!status.NoCrossVolumeIdentityChange {
t.Fatalf("status=%+v", status)
}
line, ok := h.Publisher().VolumeAuthorityLine("vol-a")
if !ok {
t.Fatalf("missing authority line after integrated failback")
}
if line.ReplicaID != "r1" ||
line.Epoch != current.Epoch+1 ||
line.DataAddr != "127.0.0.1:9201" ||
line.CtrlAddr != "127.0.0.1:9101" {
t.Fatalf("line=%+v current=%+v", line, current)
}
}
func newTestMasterWithFailbackRuntimeRPC(t *testing.T) *Host {
t.Helper()
h, err := New(Config{
@@ -138,3 +223,22 @@ func newTestMasterWithFailbackRuntimeRPC(t *testing.T) *Host {
h.Start()
return h
}
type failbackExecutorMasterServiceClient struct {
targets []ops.SwBlockReplicaFailbackObject
writes []failbackExecutorMasterServiceWrite
}
type failbackExecutorMasterServiceWrite struct {
ref ops.OperatorObjectRef
status ops.SwBlockReplicaFailbackCRDStatus
}
func (c *failbackExecutorMasterServiceClient) ListSwBlockReplicaFailbacks(context.Context, string) ([]ops.SwBlockReplicaFailbackObject, error) {
return append([]ops.SwBlockReplicaFailbackObject(nil), c.targets...), nil
}
func (c *failbackExecutorMasterServiceClient) WriteReplicaFailbackStatus(_ context.Context, ref ops.OperatorObjectRef, status ops.SwBlockReplicaFailbackCRDStatus) error {
c.writes = append(c.writes, failbackExecutorMasterServiceWrite{ref: ref, status: status})
return nil
}
+11 -2
View File
@@ -348,7 +348,14 @@ Recommended order from here:
explicit. Default chart behavior remains non-mutating. The chart fails fast
for dry-run execution, missing execution policy, and ambiguous HTTP/gRPC
runtime transports.
41. Add backup/restore and NVMe ANA parity after they can reuse the same action
41. Phase 84: failback integrated gRPC smoke. **Closed 2026-06-26, local PASS**
(`internal/docs/finished-plans/phase84_finishedplan_failback_integrated_grpc_smoke.md`).
A local integrated test now drives the failback executor through
`GRPCFailbackRuntime` into a real blockmaster `FailbackService`, which then
advances the master-owned Publisher. This proves executor status,
authority-epoch advance, and publish-target swap through the real service
path while keeping frontend publication and storage mutation false.
42. 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.
@@ -385,7 +392,9 @@ call in a later phase; default installs still keep the mutation path off.
Phase 82 adds that executor-side gRPC runtime transport, still requiring
explicit execution policy and an explicit blockmaster address. Phase 83 packages
that path in Helm while preserving the default-off boundary and adding render
guardrails for incoherent execution values.
guardrails for incoherent execution values. Phase 84 closes the local
fake-service gap by proving the executor gRPC runtime against the real
blockmaster service and master Publisher.
The practical rule is:
+53 -98
View File
@@ -1,110 +1,73 @@
# Current Plan: Phase 83 Failback Runtime Chart Wiring
# Current Plan: Phase 84 Failback Integrated gRPC Smoke
Status: complete.
## Goal
Phase 82 added the failback executor gRPC transport. Phase 83 packages that
transport in the Helm chart without enabling it by default.
Default installs remain non-mutating:
Phase 84 proves the executor-to-blockmaster failback runtime path as one local
product loop:
```text
blockmaster.failbackRuntimeRPC=false
failbackExecutor.create=false
failbackExecutor.execution.enabled=false
FailbackExecutorReconciler
-> GRPCFailbackRuntime
-> blockmaster FailbackService
-> master-owned FailbackAuthorityRuntime
-> live Publisher.apply(IntentReassign)
```
The chart only renders the active failback RPC/executor path when the operator
sets all execution switches explicitly.
This closes the fake-service gap from Phase 82. The test uses the real
blockmaster service and real Publisher, not a fake gRPC service.
## Deliverables
### D1: Blockmaster RPC Flag
### D1: Real-Service Integration Test
Added:
```text
blockmaster.failbackRuntimeRPC
TestFailbackExecutorGRPCRuntimeUsesRealMasterService
```
When true, the blockmaster Deployment renders:
The test:
```text
--failback-runtime-rpc
starts a master Host with FailbackRuntimeRPC enabled
seeds verified existing placement so r2 is current
runs FailbackExecutorReconciler with NewGRPCFailbackRuntime(h.Addr())
writes failed_back status from terminal evidence
asserts master Publisher advances r2@N -> r1@N+1
asserts publish target swaps to r1 endpoint
asserts no frontend publication and no storage mutation
```
The value defaults to false.
### D2: Default-Off Carry-Forward
### D2: Failback Executor Runtime Values
The gate also keeps the service boundary tests in scope:
```text
TestFailbackServiceDefaultDisabled
TestFailbackServiceEnabledUsesHostRuntime
```
This proves the RPC remains disabled by default and only delegates to the
host-owned runtime when explicitly enabled.
### D3: Gate
Added:
```text
failbackExecutor.execution.enabled
failbackExecutor.execution.policy
failbackExecutor.execution.failbackRuntimeGrpcAddr
failbackExecutor.execution.failbackRuntimeURL
```
When explicitly enabled with `dryRun=false`, the failback executor can render:
```text
--enable-execution
--execution-policy
--failback-runtime-grpc-addr=<addr>
```
HTTP runtime remains available through:
```text
--failback-runtime-url=<url>
```
### D3: Render Guardrails
Helm now fails fast for incoherent execution values:
```text
execution.enabled=true with dryRun=true
execution.enabled=true without execution.policy=true
runtime address without execution.enabled=true
both HTTP and gRPC runtime addresses
```
This keeps chart behavior aligned with the CLI contract and avoids deployed
pods that immediately reject their own flags.
### D4: Gate
Added:
```text
scripts/run-phase83-failback-chart-runtime-gate.sh
testops/scenarios/failback-chart-runtime-chain.yaml
```
The gate proves:
```text
default chart omits --failback-runtime-rpc
default chart does not create failback executor
default chart omits --enable-execution and runtime address
explicit chart renders blockmaster RPC flag
explicit chart renders failback executor execution policy and gRPC address
dry-run execution is rejected
missing execution policy is rejected
ambiguous HTTP/gRPC runtime is rejected
scripts/run-phase84-failback-integrated-grpc-smoke.sh
testops/scenarios/failback-integrated-grpc-smoke-chain.yaml
```
## Non-Claims
Phase 83 does not implement:
Phase 84 does not implement:
```text
automatic failback from the deployed controller loop
default-enabled failback RPC
live end-to-end failback through Helm install
deployed Kubernetes failback controller loop
automatic failback target selection
frontend publication after failback
storage rebuild/catch-up traffic
workload mutation
@@ -114,38 +77,30 @@ NVMe ANA behavior
## Verification
```text
helm lint charts/seaweed-block
"C:\Program Files\Git\bin\bash.exe" scripts/run-phase83-failback-chart-runtime-gate.sh .
C:\work\swblock.exe validate testops\scenarios\failback-chart-runtime-chain.yaml
go test ./core/host/master -run "Test(FailbackServiceDefaultDisabled|FailbackServiceEnabledUsesHostRuntime|FailbackExecutorGRPCRuntimeUsesRealMasterService)" -count=1 -v
"C:\Program Files\Git\bin\bash.exe" scripts/run-phase84-failback-integrated-grpc-smoke.sh .
C:\work\swblock.exe validate testops\scenarios\failback-integrated-grpc-smoke-chain.yaml
```
Terminal evidence:
```text
phase83_failback_chart_runtime_status=ok
helm_lint=pass
default_omits_failback_runtime_rpc=true
default_omits_failback_executor_deployment=true
default_omits_enable_execution=true
default_omits_failback_grpc_addr=true
enabled_renders_failback_runtime_rpc=true
enabled_renders_failback_executor_deployment=true
enabled_renders_enable_execution=true
enabled_renders_execution_policy=true
enabled_renders_failback_grpc_addr=true
enabled_omits_dry_run=true
rejects_execution_with_dry_run=true
rejects_execution_without_policy=true
rejects_ambiguous_runtime_transports=true
execution_policy_still_required=true
runtime_transport_must_be_unambiguous=true
chart_default_remains_non_mutating=true
phase84_failback_integrated_grpc_status=ok
core_host_master_failback_grpc_tests=pass
service_default_disabled_test=true
service_enabled_uses_host_runtime=true
executor_grpc_uses_real_master_service=true
executor_status_failed_back=true
master_publisher_epoch_advanced=true
publish_target_swapped_after_failback=true
terminal_evidence_required=true
frontend_publication_allowed=false
storage_mutation_allowed=false
```
## Next
The next phase should run an integrated local blockmaster + failback-executor
smoke with all flags explicitly enabled, or add the missing release/README
documentation for the opt-in failback path before any public release claim.
The next phase should move from local integration to deployed-loop safety:
either a Kubernetes smoke with explicitly enabled failback components, or a
controller policy gate that proves no automatic failback happens without a
ready `SwBlockReplicaFailback` target and explicit execution policy.
@@ -0,0 +1,58 @@
# Phase 84 Finished Plan: Failback Integrated gRPC Smoke
Status: complete.
Date: 2026-06-26.
## What Changed
Phase 84 adds an integrated local product smoke for the failback execution
path. The new test starts a real blockmaster Host with the failback RPC enabled,
seeds a current r2 authority line, then runs the failback executor reconciler
through a gRPC runtime pointed at that blockmaster.
The path under test is:
```text
executor reconciler -> gRPC runtime -> FailbackService -> master Publisher
```
This is stronger than the Phase 82 fake-service test because the final authority
mutation is performed by the product-owned master Publisher.
## Evidence
The gate proves:
```text
service disabled by default
enabled service delegates to host runtime
executor gRPC runtime uses the real master service
executor writes failed_back status
master Publisher epoch advances
publish target swaps to returned replica
frontend publication remains false
storage mutation remains false
```
## Verification
```text
go test ./core/host/master -run "Test(FailbackServiceDefaultDisabled|FailbackServiceEnabledUsesHostRuntime|FailbackExecutorGRPCRuntimeUsesRealMasterService)" -count=1 -v
scripts/run-phase84-failback-integrated-grpc-smoke.sh .
swblock validate testops/scenarios/failback-integrated-grpc-smoke-chain.yaml
```
Result:
```text
phase84_failback_integrated_grpc_status=ok
executor_grpc_uses_real_master_service=true
master_publisher_epoch_advanced=true
publish_target_swapped_after_failback=true
```
## Non-Claims
Phase 84 does not enable automatic deployed failback, frontend publication,
storage catch-up traffic, workload mutation, or NVMe ANA behavior.
@@ -0,0 +1,65 @@
# Phase 84 Failback Integrated gRPC Smoke QA Sign-off
Verdict: PASS.
Date: 2026-06-26.
Scope: local integrated failback execution smoke using the real blockmaster
FailbackService and live master Publisher.
## Result
```text
phase84_failback_integrated_grpc_status=ok
core_host_master_failback_grpc_tests=pass
```
## Gate Evidence
```text
service_default_disabled_test=true
service_enabled_uses_host_runtime=true
executor_grpc_uses_real_master_service=true
executor_status_failed_back=true
master_publisher_epoch_advanced=true
publish_target_swapped_after_failback=true
terminal_evidence_required=true
frontend_publication_allowed=false
storage_mutation_allowed=false
```
## Checks
| Check | Result |
| --- | --- |
| `FailbackService` remains disabled by default | PASS |
| enabled `FailbackService` delegates to host runtime | PASS |
| failback executor gRPC runtime calls real master service | PASS |
| executor writes `failed_back` status on terminal evidence | PASS |
| master Publisher advances authority epoch | PASS |
| publish target swaps to returned replica endpoint | PASS |
| frontend publication remains false | PASS |
| storage mutation remains false | PASS |
| runner scenario validates | PASS |
## Verification Commands
```text
go test ./core/host/master -run "Test(FailbackServiceDefaultDisabled|FailbackServiceEnabledUsesHostRuntime|FailbackExecutorGRPCRuntimeUsesRealMasterService)" -count=1 -v
"C:\Program Files\Git\bin\bash.exe" scripts/run-phase84-failback-integrated-grpc-smoke.sh .
C:\work\swblock.exe validate testops\scenarios\failback-integrated-grpc-smoke-chain.yaml
git diff --check
```
## Non-Claims
This sign-off does not claim:
```text
deployed Kubernetes failback controller loop
automatic failback target selection
frontend publication after failback
storage rebuild/catch-up traffic
workload mutation
NVMe ANA behavior
```
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -euo pipefail
PRODUCT_ROOT="${1:-$(pwd)}"
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase84-failback-integrated-grpc-smoke}"
SUMMARY="${ARTIFACT_DIR}/phase84-failback-integrated-grpc-summary.txt"
MASTER_LOG="${ARTIFACT_DIR}/core-host-master-go-test.log"
mkdir -p "${ARTIFACT_DIR}"
: >"${SUMMARY}"
write_summary() {
echo "$*" | tee -a "${SUMMARY}" >/dev/null
}
require_log() {
local name="$1"
local pattern="$2"
local file="$3"
local found="false"
if grep -Eq -- "${pattern}" "${file}"; then
found="true"
fi
write_summary "${name}=${found}"
if [ "${found}" != "true" ]; then
echo "missing evidence ${name}: pattern ${pattern}" >&2
return 1
fi
}
write_summary "phase84_failback_integrated_grpc_status=running"
write_summary "phase84_scope=failback_executor_to_real_master_service"
write_summary "default_service_disabled_required=true"
write_summary "frontend_publication_allowed=false"
write_summary "storage_mutation_allowed=false"
TEST_PATTERN="Test(FailbackServiceDefaultDisabled|FailbackServiceEnabledUsesHostRuntime|FailbackExecutorGRPCRuntimeUsesRealMasterService)"
if (cd "${PRODUCT_ROOT}" && go test ./core/host/master -run "${TEST_PATTERN}" -count=1 -v) >"${MASTER_LOG}" 2>&1; then
write_summary "core_host_master_failback_grpc_tests=pass"
else
write_summary "core_host_master_failback_grpc_tests=fail"
cat "${MASTER_LOG}" >&2 || true
exit 1
fi
require_log "service_default_disabled_test" "^--- PASS: TestFailbackServiceDefaultDisabled" "${MASTER_LOG}"
require_log "service_enabled_uses_host_runtime" "^--- PASS: TestFailbackServiceEnabledUsesHostRuntime" "${MASTER_LOG}"
require_log "executor_grpc_uses_real_master_service" "^--- PASS: TestFailbackExecutorGRPCRuntimeUsesRealMasterService" "${MASTER_LOG}"
write_summary "executor_status_failed_back=true"
write_summary "master_publisher_epoch_advanced=true"
write_summary "publish_target_swapped_after_failback=true"
write_summary "terminal_evidence_required=true"
write_summary "frontend_publication_allowed=false"
write_summary "storage_mutation_allowed=false"
write_summary "phase84_failback_integrated_grpc_status=ok"
@@ -0,0 +1,96 @@
# Runner-native Phase 84 gate: local integrated smoke for failback executor ->
# gRPC runtime -> real blockmaster FailbackService -> master Publisher.
name: failback-integrated-grpc-smoke-chain
timeout: 6m
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_integrated_grpc_smoke
actions:
- action: exec
node: m02
timeout: 5m
cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc && cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc bash scripts/run-phase84-failback-integrated-grpc-smoke.sh {{ product_root }}"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc/phase84-failback-integrated-grpc-summary.txt"
pattern: "^phase84_failback_integrated_grpc_status=ok$"
save_as: phase84_ok
- action: assert_greater
actual: "{{ phase84_ok }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc/phase84-failback-integrated-grpc-summary.txt"
pattern: "^service_default_disabled_test=true$"
save_as: default_disabled
- action: assert_greater
actual: "{{ default_disabled }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc/phase84-failback-integrated-grpc-summary.txt"
pattern: "^executor_grpc_uses_real_master_service=true$"
save_as: integrated
- action: assert_greater
actual: "{{ integrated }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc/phase84-failback-integrated-grpc-summary.txt"
pattern: "^master_publisher_epoch_advanced=true$"
save_as: epoch_advanced
- action: assert_greater
actual: "{{ epoch_advanced }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc/phase84-failback-integrated-grpc-summary.txt"
pattern: "^publish_target_swapped_after_failback=true$"
save_as: target_swapped
- action: assert_greater
actual: "{{ target_swapped }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc/phase84-failback-integrated-grpc-summary.txt"
pattern: "^frontend_publication_allowed=false$"
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 }}-phase84-failback-integrated-grpc/phase84-failback-integrated-grpc-summary.txt"
pattern: "^storage_mutation_allowed=false$"
save_as: no_storage
- action: assert_greater
actual: "{{ no_storage }}"
threshold: "0"
- name: collect
always: true
actions:
- action: collect_path
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase84-failback-integrated-grpc"
name: "remote-phases"
ignore_error: true