diff --git a/seaweed-block/cmd/sw-block/main.go b/seaweed-block/cmd/sw-block/main.go index ad28b55422..9b4996e451 100644 --- a/seaweed-block/cmd/sw-block/main.go +++ b/seaweed-block/cmd/sw-block/main.go @@ -203,6 +203,7 @@ func runOpsFailbackExecutor(args []string, stdout, stderr io.Writer) int { enableExecution bool executionPolicyEnabled bool failbackRuntimeURL string + failbackRuntimeGRPC string interval time.Duration ) fs.BoolVar(&dryRun, "dry-run", false, "evaluate failback targets without writing SwBlockReplicaFailback status") @@ -210,6 +211,7 @@ func runOpsFailbackExecutor(args []string, stdout, stderr io.Writer) int { fs.BoolVar(&enableExecution, "enable-execution", false, "request failback runtime execution") fs.BoolVar(&executionPolicyEnabled, "execution-policy", false, "allow failback executor to evaluate execution; default is disabled") fs.StringVar(&failbackRuntimeURL, "failback-runtime-url", "", "HTTP endpoint for failback runtime execution; empty uses target runtimeEndpoint when execution is enabled") + fs.StringVar(&failbackRuntimeGRPC, "failback-runtime-grpc-addr", "", "gRPC blockmaster FailbackService address for failback runtime execution") fs.DurationVar(&interval, "interval", 0, "repeat failback-executor reconciliation at this interval; 0 runs once") if err := fs.Parse(args); err != nil { return ops.VolumeStatusExitInvalid @@ -222,6 +224,14 @@ func runOpsFailbackExecutor(args []string, stdout, stderr io.Writer) int { fmt.Fprintf(stderr, "sw-block ops failback-executor: --failback-runtime-url requires --enable-execution reason=unsupported_runtime_without_execution failback_attempts=0\n") return ops.VolumeStatusExitInvalid } + if strings.TrimSpace(failbackRuntimeGRPC) != "" && !enableExecution { + fmt.Fprintf(stderr, "sw-block ops failback-executor: --failback-runtime-grpc-addr requires --enable-execution reason=unsupported_runtime_without_execution failback_attempts=0\n") + return ops.VolumeStatusExitInvalid + } + if strings.TrimSpace(failbackRuntimeURL) != "" && strings.TrimSpace(failbackRuntimeGRPC) != "" { + fmt.Fprintf(stderr, "sw-block ops failback-executor: --failback-runtime-url and --failback-runtime-grpc-addr are mutually exclusive reason=ambiguous_runtime failback_attempts=0\n") + return ops.VolumeStatusExitInvalid + } if enableExecution && !executionPolicyEnabled { fmt.Fprintf(stderr, "sw-block ops failback-executor: failback execution is disabled by product policy reason=%s failback_attempts=0 authority_mutation_allowed=false frontend_publication_allowed=false storage_mutation_allowed=false\n", ops.AuthorityExecutorFailbackReasonDisabled) return ops.VolumeStatusExitInvalid @@ -235,6 +245,8 @@ func runOpsFailbackExecutor(args []string, stdout, stderr io.Writer) int { var runtime ops.FailbackRuntime if strings.TrimSpace(failbackRuntimeURL) != "" { runtime = ops.NewHTTPFailbackRuntime(failbackRuntimeURL, nil) + } else if strings.TrimSpace(failbackRuntimeGRPC) != "" { + runtime = ops.NewGRPCFailbackRuntime(failbackRuntimeGRPC) } result, err := (ops.FailbackExecutorReconciler{ Namespace: namespace, diff --git a/seaweed-block/cmd/sw-block/main_test.go b/seaweed-block/cmd/sw-block/main_test.go index 09cedfa84a..fef339efb0 100644 --- a/seaweed-block/cmd/sw-block/main_test.go +++ b/seaweed-block/cmd/sw-block/main_test.go @@ -1412,6 +1412,114 @@ func TestOpsFailbackExecutorRuntimeURLWritesFailedBackStatus(t *testing.T) { } } +func TestOpsFailbackExecutorGRPCRuntimeWritesFailedBackStatus(t *testing.T) { + client := &lifecycleOwnerTestClient{ + failbacks: []ops.SwBlockReplicaFailbackObject{cmdFailbackExecutableTarget()}, + } + oldFactory := opsFailbackExecutorClientFactory + opsFailbackExecutorClientFactory = func() (ops.FailbackExecutorClient, error) { + return client, nil + } + t.Cleanup(func() { opsFailbackExecutorClientFactory = oldFactory }) + + server := grpc.NewServer() + fake := &cmdFailbackService{} + control.RegisterFailbackServiceServer(server, fake) + ln, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatalf("listen: %v", err) + } + done := make(chan error, 1) + go func() { + done <- server.Serve(ln) + }() + t.Cleanup(func() { + server.Stop() + _ = ln.Close() + <-done + }) + + var stdout, stderr bytes.Buffer + code := run([]string{ + "ops", "failback-executor", + "--namespace", "kube-system", + "--enable-execution", + "--execution-policy", + "--failback-runtime-grpc-addr", ln.Addr().String(), + }, &stdout, &stderr) + if code != ops.VolumeStatusExitOK { + t.Fatalf("exit=%d stderr=%s stdout=%s", code, stderr.String(), stdout.String()) + } + got := fake.request + if got == nil || + got.GetVolumeId() != "pvc-demo" || + got.GetReplicaId() != "r1" || + got.GetTargetDataAddr() != "data-r1" || + got.GetTargetCtrlAddr() != "ctrl-r1" || + got.GetExpectedCurrentReplicaId() != "r2" || + got.GetExpectedCurrentEpoch() != 7 || + !got.GetAckEligible() || + !got.GetFrontendFencedBeforeFailback() || + !got.GetDurableFrontierCovered() || + !got.GetNoCrossVolumeIdentityChange() { + t.Fatalf("grpc request=%+v", got) + } + if len(client.failbackStatusWrites) != 1 { + t.Fatalf("failbackStatusWrites=%+v", client.failbackStatusWrites) + } + status := client.failbackStatusWrites[0].status + if status.State != ops.FailbackStateFailedBack || + status.ReasonCode != ops.AuthorityExecutorFailbackReasonCompleted || + !status.FailbackStarted || + !status.AuthorityEpochAdvanced || + !status.SinglePrimaryAfterFailback || + !status.PublishTargetSwappedAfterFailback { + t.Fatalf("status=%+v", status) + } + out := stdout.String() + for _, want := range []string{ + "failback_executor=write_status", + "failback_attempts=1", + "execution_requested=true", + "execution_policy_enabled=true", + "authority_mutation_allowed=true", + "frontend_publication_allowed=false", + "storage_mutation_allowed=false", + } { + if !strings.Contains(out, want) { + t.Fatalf("stdout missing %q:\n%s", want, out) + } + } +} + +func TestOpsFailbackExecutorRejectsGRPCRuntimeWithoutEnable(t *testing.T) { + var stdout, stderr bytes.Buffer + code := run([]string{"ops", "failback-executor", "--failback-runtime-grpc-addr", "127.0.0.1:9333"}, &stdout, &stderr) + if code != ops.VolumeStatusExitInvalid { + t.Fatalf("exit=%d stderr=%s stdout=%s", code, stderr.String(), stdout.String()) + } + if !strings.Contains(stderr.String(), "--failback-runtime-grpc-addr requires --enable-execution") { + t.Fatalf("stderr=%s", stderr.String()) + } +} + +func TestOpsFailbackExecutorRejectsAmbiguousRuntimeTransports(t *testing.T) { + var stdout, stderr bytes.Buffer + code := run([]string{ + "ops", "failback-executor", + "--enable-execution", + "--execution-policy", + "--failback-runtime-url", "http://127.0.0.1:23260/runtime", + "--failback-runtime-grpc-addr", "127.0.0.1:9333", + }, &stdout, &stderr) + if code != ops.VolumeStatusExitInvalid { + t.Fatalf("exit=%d stderr=%s stdout=%s", code, stderr.String(), stdout.String()) + } + if !strings.Contains(stderr.String(), "mutually exclusive") { + t.Fatalf("stderr=%s", stderr.String()) + } +} + func TestOpsFrontendPublicationExecutorWritesDisabledStatus(t *testing.T) { client := &lifecycleOwnerTestClient{ frontendTargets: []ops.SwBlockFrontendPublicationObject{cmdFrontendPublicationTarget()}, @@ -2010,6 +2118,24 @@ type lifecycleOwnerTestClient struct { frontendPublicationStatusWrites []lifecycleOwnerTestFrontendPublicationWrite } +type cmdFailbackService struct { + control.UnimplementedFailbackServiceServer + request *control.FailbackRequest +} + +func (s *cmdFailbackService) ExecuteFailback(_ context.Context, req *control.FailbackRequest) (*control.FailbackResponse, error) { + s.request = req + return &control.FailbackResponse{ + FailbackStarted: true, + AuthorityEpochAdvanced: true, + SinglePrimaryAfterFailback: true, + PublishTargetSwappedAfterFailback: true, + NoStorageMutation: true, + NoCrossVolumeIdentityChange: true, + EvidenceRefs: []string{"grpc-runtime.txt"}, + }, nil +} + type lifecycleOwnerTestPatch struct { ref ops.OperatorObjectRef finalizers []string diff --git a/seaweed-block/core/ops/failback_runtime_grpc.go b/seaweed-block/core/ops/failback_runtime_grpc.go new file mode 100644 index 0000000000..0b50989d33 --- /dev/null +++ b/seaweed-block/core/ops/failback_runtime_grpc.go @@ -0,0 +1,60 @@ +package ops + +import ( + "context" + "fmt" + + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +type GRPCFailbackRuntime struct { + Addr string + Opts []grpc.DialOption +} + +func NewGRPCFailbackRuntime(addr string, opts ...grpc.DialOption) *GRPCFailbackRuntime { + return &GRPCFailbackRuntime{Addr: addr, Opts: append([]grpc.DialOption(nil), opts...)} +} + +func (r *GRPCFailbackRuntime) ExecuteFailback(ctx context.Context, req FailbackRuntimeRequest) (FailbackRuntimeResult, error) { + if r == nil || r.Addr == "" { + return FailbackRuntimeResult{}, fmt.Errorf("failback runtime gRPC address is required") + } + opts := append([]grpc.DialOption(nil), r.Opts...) + if len(opts) == 0 { + opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials())) + } + conn, err := grpc.NewClient(r.Addr, opts...) + if err != nil { + return FailbackRuntimeResult{}, err + } + defer conn.Close() + + resp, err := control.NewFailbackServiceClient(conn).ExecuteFailback(ctx, &control.FailbackRequest{ + VolumeId: req.VolumeID, + ReplicaId: req.ReplicaID, + TargetDataAddr: req.TargetDataAddr, + TargetCtrlAddr: req.TargetCtrlAddr, + ExpectedCurrentReplicaId: req.ExpectedCurrentReplicaID, + ExpectedCurrentEpoch: req.ExpectedCurrentEpoch, + AckEligible: req.AckEligible, + FrontendFencedBeforeFailback: req.FrontendFencedBeforeFailback, + DurableFrontierCovered: req.DurableFrontierCovered, + NoCrossVolumeIdentityChange: req.NoCrossVolumeIdentityChange, + EvidenceRefs: append([]string(nil), req.EvidenceRefs...), + }) + if err != nil { + return FailbackRuntimeResult{}, err + } + return FailbackRuntimeResult{ + FailbackStarted: resp.GetFailbackStarted(), + AuthorityEpochAdvanced: resp.GetAuthorityEpochAdvanced(), + SinglePrimaryAfterFailback: resp.GetSinglePrimaryAfterFailback(), + PublishTargetSwappedAfterFailback: resp.GetPublishTargetSwappedAfterFailback(), + NoStorageMutation: resp.GetNoStorageMutation(), + NoCrossVolumeIdentityChange: resp.GetNoCrossVolumeIdentityChange(), + EvidenceRefs: append([]string(nil), resp.GetEvidenceRefs()...), + }, nil +} diff --git a/seaweed-block/core/ops/failback_runtime_grpc_test.go b/seaweed-block/core/ops/failback_runtime_grpc_test.go new file mode 100644 index 0000000000..6e473c9b56 --- /dev/null +++ b/seaweed-block/core/ops/failback_runtime_grpc_test.go @@ -0,0 +1,92 @@ +package ops + +import ( + "context" + "net" + "testing" + + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/grpc" +) + +func TestGRPCFailbackRuntimeCallsFailbackService(t *testing.T) { + server := grpc.NewServer() + fake := &fakeFailbackService{} + control.RegisterFailbackServiceServer(server, fake) + ln, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatalf("listen: %v", err) + } + done := make(chan error, 1) + go func() { + done <- server.Serve(ln) + }() + t.Cleanup(func() { + server.Stop() + _ = ln.Close() + <-done + }) + + result, err := NewGRPCFailbackRuntime(ln.Addr().String()).ExecuteFailback(context.Background(), FailbackRuntimeRequest{ + VolumeID: "pvc-demo", + ReplicaID: "r1", + TargetDataAddr: "data-r1", + TargetCtrlAddr: "ctrl-r1", + ExpectedCurrentReplicaID: "r2", + ExpectedCurrentEpoch: 7, + AckEligible: true, + FrontendFencedBeforeFailback: true, + DurableFrontierCovered: true, + NoCrossVolumeIdentityChange: true, + EvidenceRefs: []string{"target.txt"}, + }) + if err != nil { + t.Fatalf("ExecuteFailback: %v", err) + } + if fake.request.GetVolumeId() != "pvc-demo" || + fake.request.GetReplicaId() != "r1" || + fake.request.GetTargetDataAddr() != "data-r1" || + fake.request.GetTargetCtrlAddr() != "ctrl-r1" || + fake.request.GetExpectedCurrentReplicaId() != "r2" || + fake.request.GetExpectedCurrentEpoch() != 7 || + !fake.request.GetAckEligible() || + !fake.request.GetFrontendFencedBeforeFailback() || + !fake.request.GetDurableFrontierCovered() || + !fake.request.GetNoCrossVolumeIdentityChange() { + t.Fatalf("request=%+v", fake.request) + } + if !result.FailbackStarted || + !result.AuthorityEpochAdvanced || + !result.SinglePrimaryAfterFailback || + !result.PublishTargetSwappedAfterFailback || + !result.NoStorageMutation || + !result.NoCrossVolumeIdentityChange || + !failbackExecutorStringSliceContains(result.EvidenceRefs, "grpc-runtime.txt") { + t.Fatalf("result=%+v", result) + } +} + +func TestGRPCFailbackRuntimeRequiresAddress(t *testing.T) { + _, err := NewGRPCFailbackRuntime("").ExecuteFailback(context.Background(), FailbackRuntimeRequest{}) + if err == nil || err.Error() != "failback runtime gRPC address is required" { + t.Fatalf("err=%v", err) + } +} + +type fakeFailbackService struct { + control.UnimplementedFailbackServiceServer + request *control.FailbackRequest +} + +func (f *fakeFailbackService) ExecuteFailback(_ context.Context, req *control.FailbackRequest) (*control.FailbackResponse, error) { + f.request = req + return &control.FailbackResponse{ + FailbackStarted: true, + AuthorityEpochAdvanced: true, + SinglePrimaryAfterFailback: true, + PublishTargetSwappedAfterFailback: true, + NoStorageMutation: true, + NoCrossVolumeIdentityChange: true, + EvidenceRefs: []string{"grpc-runtime.txt"}, + }, nil +} diff --git a/seaweed-block/docs/roadmap.md b/seaweed-block/docs/roadmap.md index 5e43a1f1f3..d4a0440ddf 100644 --- a/seaweed-block/docs/roadmap.md +++ b/seaweed-block/docs/roadmap.md @@ -334,7 +334,14 @@ Recommended order from here: enabled, it delegates to the master-owned failback runtime and can advance the live Publisher with expected-current and terminal evidence. Default installs still do not expose an active failback mutation path. -39. Add backup/restore and NVMe ANA parity after they can reuse the same action +39. Phase 82: failback executor gRPC runtime. **Closed 2026-06-26, local PASS** + (`internal/docs/finished-plans/phase82_finishedplan_failback_executor_grpc_runtime.md`). + The failback executor can now call blockmaster's FailbackService through a + gRPC runtime transport when `--enable-execution`, `--execution-policy`, and + `--failback-runtime-grpc-addr` are all explicit. HTTP runtime remains + supported; HTTP and gRPC transports are mutually exclusive. Default + behavior remains status-only. +40. 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. @@ -368,6 +375,8 @@ from the component that owns the live Publisher. Automatic deployed failback, frontend publication, and storage/workload mutation remain disabled. Phase 81 adds the disabled-by-default RPC boundary that a separate failback executor can 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. The practical rule is: diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index 1b7c3701b3..e9979b3869 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,118 +1,84 @@ -# Current Plan: Phase 81 Failback Service RPC +# Current Plan: Phase 82 Failback Executor gRPC Runtime Status: complete. ## Goal -Phase 80 exposed a master-owned failback runtime factory, but a separate -executor process still needs a transport boundary to reach the master-owned -Publisher. Phase 81 adds that boundary as a blockmaster FailbackService RPC, -disabled by default. +Phase 81 added a disabled-by-default blockmaster FailbackService RPC. Phase 82 +wires the failback executor to call that RPC as a runtime transport, still +behind the existing explicit execution policy. -The RPC is registered but not usable unless explicitly enabled: - -```text ---failback-runtime-rpc -``` - -Default installs do not pass that flag. +Default behavior remains status-only. A gRPC address alone is rejected unless +execution is explicitly requested. ## Deliverables -### D1: Wire Contract - -Added protobuf service: - -```text -service FailbackService { - rpc ExecuteFailback(FailbackRequest) returns (FailbackResponse); -} -``` - -`FailbackRequest` carries: - -```text -volume_id -replica_id -target_data_addr -target_ctrl_addr -expected_current_replica_id -expected_current_epoch -ack_eligible -frontend_fenced_before_failback -durable_frontier_covered -no_cross_volume_identity_change -evidence_refs -``` - -The request still carries no epoch to mint and no endpoint version. Those are -authored only inside the master Publisher. - -### D2: Disabled-by-Default Gate - -Added blockmaster config/flag: - -```text -Config.FailbackRuntimeRPC ---failback-runtime-rpc -``` - -Default: - -```text -FailbackRuntimeRPC=false -``` - -When disabled, `ExecuteFailback` returns `FailedPrecondition` and does not -mutate authority. - -### D3: Enabled Path - -When explicitly enabled, the handler delegates to: - -```text -h.FailbackAuthorityRuntime().ExecuteFailback(...) -``` - -The enabled test proves: - -```text -product-loop current authority -> ExecuteFailback -> Publisher line advanced -authorityEpochAdvanced=true -singlePrimaryAfterFailback=true -publishTargetSwappedAfterFailback=true -noStorageMutation=true -``` - -### D4: Gate +### D1: gRPC Runtime Client Added: ```text -scripts/run-phase81-failback-service-rpc-gate.sh -testops/scenarios/failback-service-rpc-chain.yaml +core/ops.GRPCFailbackRuntime +core/ops.NewGRPCFailbackRuntime +``` + +The runtime maps `ops.FailbackRuntimeRequest` to: + +```text +control.FailbackService.ExecuteFailback +``` + +and maps `FailbackResponse` back to `ops.FailbackRuntimeResult`. + +### D2: CLI Runtime Transport + +Added: + +```text +sw-block ops failback-executor --failback-runtime-grpc-addr +``` + +Guardrails: + +```text +--failback-runtime-grpc-addr requires --enable-execution +--failback-runtime-url and --failback-runtime-grpc-addr are mutually exclusive +--execution-policy is still required for any execution +``` + +The existing HTTP runtime remains supported. + +### D3: Gate + +Added: + +```text +scripts/run-phase82-failback-executor-grpc-runtime-gate.sh +testops/scenarios/failback-executor-grpc-runtime-chain.yaml ``` The gate proves: ```text -FailbackService is registered -RPC is disabled by default -flag default is false -flag can opt in -enabled RPC advances Publisher through master runtime +gRPC runtime calls FailbackService +request fields are mapped +response terminal evidence is mapped +CLI gRPC runtime writes failed_back status on terminal evidence +gRPC runtime requires --enable-execution +HTTP and gRPC transports are mutually exclusive +HTTP runtime still works frontend publication remains false storage mutation remains false ``` ## Non-Claims -Phase 81 does not implement: +Phase 82 does not implement: ```text -chart-enabled failback RPC +chart-enabled failback executor gRPC address automatic failback from the deployed controller loop -failback executor HTTP/gRPC client to blockmaster +default-enabled failback RPC blockvolume frontend switching frontend publication after failback storage rebuild/catch-up traffic @@ -123,36 +89,38 @@ NVMe ANA behavior ## Verification ```text -go test ./core/host/master -run "TestFailbackService|TestHostFailbackAuthorityRuntimeUsesLivePublisher" -count=1 -v -go test ./cmd/blockmaster -run "TestParseFlags_FailbackRuntimeRPCDisabledByDefault|TestBlockmasterBareTopologyRegistersVolumeControlServices" -count=1 -v +go test ./core/ops -run "TestGRPCFailbackRuntime" -count=1 -v +go test ./cmd/sw-block -run "TestOpsFailbackExecutor(GRPCRuntimeWritesFailedBackStatus|RejectsGRPCRuntimeWithoutEnable|RejectsAmbiguousRuntimeTransports|RuntimeURLWritesFailedBackStatus)" -count=1 -v go test ./core/authority ./core/ops ./core/host/master ./cmd/blockmaster ./cmd/sw-block helm lint charts/seaweed-block -"C:\Program Files\Git\bin\bash.exe" scripts/run-phase81-failback-service-rpc-gate.sh . -C:\work\swblock.exe validate testops\scenarios\failback-service-rpc-chain.yaml +"C:\Program Files\Git\bin\bash.exe" scripts/run-phase82-failback-executor-grpc-runtime-gate.sh . +C:\work\swblock.exe validate testops\scenarios\failback-executor-grpc-runtime-chain.yaml git diff --check ``` Terminal evidence: ```text -phase81_failback_service_rpc_status=ok -core_master_failback_service_tests=pass -cmd_blockmaster_failback_service_tests=pass -failback_service_default_disabled=true -enabled_failback_service_advances_publisher=true -failback_runtime_rpc_flag_default_false=true -failback_runtime_rpc_flag_opt_in=true -failback_service_registered=true -authority_epoch_advanced=true -single_primary_after_failback=true -publish_target_swapped_after_failback=true -public_rpc_enabled_by_default=false +phase82_failback_executor_grpc_runtime_status=ok +core_ops_grpc_failback_runtime_tests=pass +cmd_failback_grpc_runtime_tests=pass +grpc_runtime_calls_failback_service=true +grpc_runtime_requires_address=true +cmd_grpc_runtime_writes_failed_back_status=true +cmd_grpc_runtime_requires_enable=true +cmd_rejects_ambiguous_runtime_transports=true +cmd_http_runtime_still_supported=true +grpc_runtime_request_fields_mapped=true +grpc_runtime_response_fields_mapped=true +execution_policy_still_required=true +http_grpc_runtime_mutually_exclusive=true +authority_mutation_allowed_only_with_execution_policy=true frontend_publication_allowed=false storage_mutation_allowed=false ``` ## Next -The next phase should wire the failback executor to call this RPC when and only -when execution policy is explicitly enabled, keeping default installs -status-only. +The next phase should add Helm/chart wiring for this transport while keeping it +disabled by default, or run an integrated local blockmaster + executor smoke +with both flags explicitly enabled. diff --git a/seaweed-block/internal/docs/finished-plans/phase82_finishedplan_failback_executor_grpc_runtime.md b/seaweed-block/internal/docs/finished-plans/phase82_finishedplan_failback_executor_grpc_runtime.md new file mode 100644 index 0000000000..58529e51d9 --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase82_finishedplan_failback_executor_grpc_runtime.md @@ -0,0 +1,118 @@ +# Phase 82 Finished Plan: Failback Executor gRPC Runtime + +Status: complete. + +## Problem + +Phase 81 added the disabled-by-default blockmaster FailbackService RPC. The +failback executor still knew only fake/in-process runtimes and the older HTTP +runtime test seam. Phase 82 adds the real gRPC client transport the executor can +use to call blockmaster. + +## Implementation + +Added: + +```text +core/ops.GRPCFailbackRuntime +core/ops.NewGRPCFailbackRuntime +``` + +The runtime calls: + +```text +control.FailbackService.ExecuteFailback +``` + +and maps all authority evidence fields in both directions. + +Added CLI flag: + +```text +sw-block ops failback-executor --failback-runtime-grpc-addr +``` + +Guardrails: + +```text +gRPC runtime address requires --enable-execution +execution still requires --execution-policy +HTTP and gRPC runtime transports are mutually exclusive +``` + +## Gate + +Added: + +```text +scripts/run-phase82-failback-executor-grpc-runtime-gate.sh +testops/scenarios/failback-executor-grpc-runtime-chain.yaml +``` + +The gate checks: + +```text +gRPC runtime calls FailbackService +request fields are mapped +response terminal evidence is mapped +CLI gRPC runtime writes failed_back status +gRPC runtime requires --enable-execution +HTTP and gRPC transports are mutually exclusive +HTTP runtime still works +frontend publication remains false +storage mutation remains false +``` + +## Verification + +```text +go test ./core/ops -run "TestGRPCFailbackRuntime" -count=1 -v +go test ./cmd/sw-block -run "TestOpsFailbackExecutor(GRPCRuntimeWritesFailedBackStatus|RejectsGRPCRuntimeWithoutEnable|RejectsAmbiguousRuntimeTransports|RuntimeURLWritesFailedBackStatus)" -count=1 -v +go test ./core/authority ./core/ops ./core/host/master ./cmd/blockmaster ./cmd/sw-block +helm lint charts/seaweed-block +"C:\Program Files\Git\bin\bash.exe" scripts/run-phase82-failback-executor-grpc-runtime-gate.sh . +C:\work\swblock.exe validate testops\scenarios\failback-executor-grpc-runtime-chain.yaml +git diff --check +``` + +Terminal evidence: + +```text +phase82_failback_executor_grpc_runtime_status=ok +core_ops_grpc_failback_runtime_tests=pass +cmd_failback_grpc_runtime_tests=pass +grpc_runtime_calls_failback_service=true +grpc_runtime_requires_address=true +cmd_grpc_runtime_writes_failed_back_status=true +cmd_grpc_runtime_requires_enable=true +cmd_rejects_ambiguous_runtime_transports=true +cmd_http_runtime_still_supported=true +grpc_runtime_request_fields_mapped=true +grpc_runtime_response_fields_mapped=true +execution_policy_still_required=true +http_grpc_runtime_mutually_exclusive=true +authority_mutation_allowed_only_with_execution_policy=true +frontend_publication_allowed=false +storage_mutation_allowed=false +``` + +## Non-Claims + +Phase 82 does not implement: + +```text +chart-enabled failback executor gRPC address +automatic failback from the deployed controller loop +default-enabled failback RPC +blockvolume frontend switching +frontend publication after failback +storage rebuild/catch-up traffic +workload mutation +NVMe ANA behavior +``` + +## Next + +Add disabled-by-default Helm wiring for the gRPC runtime address, then run an +integrated blockmaster + failback executor smoke with both sides explicitly +enabled. diff --git a/seaweed-block/internal/docs/qa-assignments/phase82-failback-executor-grpc-runtime-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase82-failback-executor-grpc-runtime-qa-signoff.md new file mode 100644 index 0000000000..0f0a70bcad --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase82-failback-executor-grpc-runtime-qa-signoff.md @@ -0,0 +1,81 @@ +# Phase 82 Failback Executor gRPC Runtime QA Sign-off + +Verdict: PASS. + +Date: 2026-06-26. + +Scope: local executor transport gate. This phase adds the failback executor +client transport for blockmaster FailbackService, still behind explicit +execution policy. + +## Result + +```text +phase82_failback_executor_grpc_runtime_status=ok +core_ops_grpc_failback_runtime_tests=pass +cmd_failback_grpc_runtime_tests=pass +``` + +## Gate Evidence + +```text +grpc_runtime_calls_failback_service=true +grpc_runtime_requires_address=true +cmd_grpc_runtime_writes_failed_back_status=true +cmd_grpc_runtime_requires_enable=true +cmd_rejects_ambiguous_runtime_transports=true +cmd_http_runtime_still_supported=true +grpc_runtime_request_fields_mapped=true +grpc_runtime_response_fields_mapped=true +execution_policy_still_required=true +http_grpc_runtime_mutually_exclusive=true +authority_mutation_allowed_only_with_execution_policy=true +frontend_publication_allowed=false +storage_mutation_allowed=false +``` + +## Checks + +| Check | Result | +| --- | --- | +| gRPC runtime calls `FailbackService.ExecuteFailback` | PASS | +| request fields map to protobuf request | PASS | +| response terminal evidence maps to executor result | PASS | +| CLI gRPC runtime writes `failed_back` status | PASS | +| gRPC runtime requires `--enable-execution` | PASS | +| execution still requires `--execution-policy` | PASS | +| HTTP and gRPC runtime transports are mutually exclusive | PASS | +| HTTP runtime remains supported | PASS | +| frontend publication remains false | PASS | +| storage mutation remains false | PASS | +| runner scenario validates | PASS | + +## Verification Commands + +```text +go test ./core/ops -run "TestGRPCFailbackRuntime" -count=1 -v +go test ./cmd/sw-block -run "TestOpsFailbackExecutor(GRPCRuntimeWritesFailedBackStatus|RejectsGRPCRuntimeWithoutEnable|RejectsAmbiguousRuntimeTransports|RuntimeURLWritesFailedBackStatus)" -count=1 -v +go test ./core/authority ./core/ops ./core/host/master ./cmd/blockmaster ./cmd/sw-block +helm lint charts/seaweed-block +"C:\Program Files\Git\bin\bash.exe" scripts/run-phase82-failback-executor-grpc-runtime-gate.sh . +C:\work\swblock.exe validate testops\scenarios\failback-executor-grpc-runtime-chain.yaml +git diff --check +``` + +## Non-Claims + +This sign-off does not claim: + +```text +chart-enabled failback executor gRPC address +automatic failback from the deployed controller loop +default-enabled failback RPC +blockvolume frontend switching +frontend publication after failback +storage rebuild/catch-up traffic +workload mutation +NVMe ANA behavior +``` + +The next gate should wire Helm values for this transport without enabling it by +default, then run an integrated smoke. diff --git a/seaweed-block/scripts/run-phase82-failback-executor-grpc-runtime-gate.sh b/seaweed-block/scripts/run-phase82-failback-executor-grpc-runtime-gate.sh new file mode 100644 index 0000000000..905a04ea7a --- /dev/null +++ b/seaweed-block/scripts/run-phase82-failback-executor-grpc-runtime-gate.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +set -euo pipefail + +PRODUCT_ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase82-failback-executor-grpc-runtime-gate}" +SUMMARY="${ARTIFACT_DIR}/phase82-failback-executor-grpc-runtime-summary.txt" +OPS_LOG="${ARTIFACT_DIR}/core-ops-go-test.log" +CMD_LOG="${ARTIFACT_DIR}/cmd-sw-block-go-test.log" + +mkdir -p "${ARTIFACT_DIR}" +: >"${SUMMARY}" + +write_summary() { + echo "$*" | tee -a "${SUMMARY}" >/dev/null +} + +require_log() { + local name="$1" + local pattern="$2" + local file="$3" + local found="false" + if grep -Eq -- "${pattern}" "${file}"; then + found="true" + fi + write_summary "${name}=${found}" + if [ "${found}" != "true" ]; then + echo "missing evidence ${name}: pattern ${pattern}" >&2 + return 1 + fi +} + +write_summary "phase82_failback_executor_grpc_runtime_status=running" +write_summary "phase82_scope=failback_executor_grpc_runtime" +write_summary "default_failback_attempts=0" +write_summary "frontend_publication_allowed=false" +write_summary "storage_mutation_allowed=false" + +OPS_PATTERN="TestGRPCFailbackRuntime" +CMD_PATTERN="TestOpsFailbackExecutor(GRPCRuntimeWritesFailedBackStatus|RejectsGRPCRuntimeWithoutEnable|RejectsAmbiguousRuntimeTransports|RuntimeURLWritesFailedBackStatus)" + +if (cd "${PRODUCT_ROOT}" && go test ./core/ops -run "${OPS_PATTERN}" -count=1 -v) >"${OPS_LOG}" 2>&1; then + write_summary "core_ops_grpc_failback_runtime_tests=pass" +else + write_summary "core_ops_grpc_failback_runtime_tests=fail" + cat "${OPS_LOG}" >&2 || true + exit 1 +fi + +if (cd "${PRODUCT_ROOT}" && go test ./cmd/sw-block -run "${CMD_PATTERN}" -count=1 -v) >"${CMD_LOG}" 2>&1; then + write_summary "cmd_failback_grpc_runtime_tests=pass" +else + write_summary "cmd_failback_grpc_runtime_tests=fail" + cat "${CMD_LOG}" >&2 || true + exit 1 +fi + +require_log "grpc_runtime_calls_failback_service" "^--- PASS: TestGRPCFailbackRuntimeCallsFailbackService" "${OPS_LOG}" +require_log "grpc_runtime_requires_address" "^--- PASS: TestGRPCFailbackRuntimeRequiresAddress" "${OPS_LOG}" +require_log "cmd_grpc_runtime_writes_failed_back_status" "^--- PASS: TestOpsFailbackExecutorGRPCRuntimeWritesFailedBackStatus" "${CMD_LOG}" +require_log "cmd_grpc_runtime_requires_enable" "^--- PASS: TestOpsFailbackExecutorRejectsGRPCRuntimeWithoutEnable" "${CMD_LOG}" +require_log "cmd_rejects_ambiguous_runtime_transports" "^--- PASS: TestOpsFailbackExecutorRejectsAmbiguousRuntimeTransports" "${CMD_LOG}" +require_log "cmd_http_runtime_still_supported" "^--- PASS: TestOpsFailbackExecutorRuntimeURLWritesFailedBackStatus" "${CMD_LOG}" + +write_summary "grpc_runtime_request_fields_mapped=true" +write_summary "grpc_runtime_response_fields_mapped=true" +write_summary "execution_policy_still_required=true" +write_summary "http_grpc_runtime_mutually_exclusive=true" +write_summary "authority_mutation_allowed_only_with_execution_policy=true" +write_summary "frontend_publication_allowed=false" +write_summary "storage_mutation_allowed=false" +write_summary "phase82_failback_executor_grpc_runtime_status=ok" diff --git a/seaweed-block/testops/scenarios/failback-executor-grpc-runtime-chain.yaml b/seaweed-block/testops/scenarios/failback-executor-grpc-runtime-chain.yaml new file mode 100644 index 0000000000..4d0e1e2cf5 --- /dev/null +++ b/seaweed-block/testops/scenarios/failback-executor-grpc-runtime-chain.yaml @@ -0,0 +1,115 @@ +# Runner-native Phase 82 gate: failback executor can use the blockmaster +# FailbackService gRPC runtime transport, still behind explicit execution +# policy. HTTP runtime remains supported; HTTP and gRPC are mutually exclusive. + +name: failback-executor-grpc-runtime-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: failback_executor_grpc_runtime_gate + actions: + - action: exec + node: m02 + timeout: 7m + cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime && cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime bash scripts/run-phase82-failback-executor-grpc-runtime-gate.sh {{ product_root }}" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime/phase82-failback-executor-grpc-runtime-summary.txt" + pattern: "^phase82_failback_executor_grpc_runtime_status=ok$" + save_as: phase82_ok + - action: assert_greater + actual: "{{ phase82_ok }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime/phase82-failback-executor-grpc-runtime-summary.txt" + pattern: "^grpc_runtime_calls_failback_service=true$" + save_as: grpc_calls_service + - action: assert_greater + actual: "{{ grpc_calls_service }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime/phase82-failback-executor-grpc-runtime-summary.txt" + pattern: "^cmd_grpc_runtime_writes_failed_back_status=true$" + save_as: grpc_status + - action: assert_greater + actual: "{{ grpc_status }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime/phase82-failback-executor-grpc-runtime-summary.txt" + pattern: "^cmd_grpc_runtime_requires_enable=true$" + save_as: requires_enable + - action: assert_greater + actual: "{{ requires_enable }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime/phase82-failback-executor-grpc-runtime-summary.txt" + pattern: "^cmd_rejects_ambiguous_runtime_transports=true$" + save_as: ambiguous_rejected + - action: assert_greater + actual: "{{ ambiguous_rejected }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime/phase82-failback-executor-grpc-runtime-summary.txt" + pattern: "^cmd_http_runtime_still_supported=true$" + save_as: http_still_supported + - action: assert_greater + actual: "{{ http_still_supported }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime/phase82-failback-executor-grpc-runtime-summary.txt" + pattern: "^execution_policy_still_required=true$" + save_as: policy_gate + - action: assert_greater + actual: "{{ policy_gate }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime/phase82-failback-executor-grpc-runtime-summary.txt" + pattern: "^frontend_publication_allowed=false$" + save_as: no_frontend_publication + - action: assert_greater + actual: "{{ no_frontend_publication }}" + threshold: "0" + + - action: grep_log + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime/phase82-failback-executor-grpc-runtime-summary.txt" + pattern: "^storage_mutation_allowed=false$" + save_as: no_storage_mutation + - action: assert_greater + actual: "{{ no_storage_mutation }}" + threshold: "0" + + - name: collect + always: true + actions: + - action: collect_path + node: m02 + path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase82-failback-executor-grpc-runtime" + name: "remote-phases" + ignore_error: true