phase89: project authority facts to volume status

This commit is contained in:
pingqiu committed 2026-06-26 12:35:14 -07:00
1 parent b37c6ed29e
commit 7f554c9296
18 files changed
+581 -127

No files matched your search

@@ -50,6 +50,18 @@ spec:
type: string
pvcName:
type: string
primaryReplicaID:
type: string
publishTarget:
type: string
authorityEpoch:
type: integer
format: int64
minimum: 0
authorityEndpointVersion:
type: integer
format: int64
minimum: 0
status:
type: string
enum:
@@ -197,6 +197,26 @@ func TestPhase38D3SwBlockVolumeAllowedActionEvaluationSchema(t *testing.T) {
}
}
func TestPhase89SwBlockVolumeAuthorityFactsSchema(t *testing.T) {
doc := readYAMLMap(t, "charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml")
statusProperties := crdStatusProperties(t, doc)
for _, want := range []string{"primaryReplicaID", "publishTarget", "authorityEpoch", "authorityEndpointVersion"} {
if _, ok := statusProperties[want]; !ok {
t.Fatalf("SwBlockVolume.status schema missing authority field %s", want)
}
}
for _, numeric := range []string{"authorityEpoch", "authorityEndpointVersion"} {
prop := yamlMap(t, statusProperties, numeric)
assertYAMLString(t, prop, "type", "integer")
assertYAMLString(t, prop, "format", "int64")
}
for _, forbidden := range []string{"primary_replica_id", "publish_target", "authority_epoch", "authority_endpoint_version"} {
if _, ok := statusProperties[forbidden]; ok {
t.Fatalf("SwBlockVolume.status schema leaked snake_case %s", forbidden)
}
}
}
func TestPhase39D2SwBlockVolumeDeleteSafetySchema(t *testing.T) {
doc := readYAMLMap(t, "charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml")
statusProperties := crdStatusProperties(t, doc)
+32 -17
View File
@@ -212,23 +212,27 @@ type WorkloadCheckFact struct {
}
type ManagedVolumeProjection struct {
VolumeID string `json:"volume_id,omitempty"`
Namespace string `json:"namespace,omitempty"`
PVCName string `json:"pvc_name,omitempty"`
PVName string `json:"pv_name,omitempty"`
StorageClass string `json:"storage_class,omitempty"`
ReplicationFactor int `json:"replication_factor,omitempty"`
AckProfile string `json:"ack_profile,omitempty"`
ClaimProfile string `json:"claim_profile,omitempty"`
Status string `json:"status"`
ReasonCode string `json:"reason_code,omitempty"`
States ManagedVolumeStates `json:"states"`
Actions []ManagedVolumeAction `json:"actions,omitempty"`
Conditions []ObservationCondition `json:"conditions,omitempty"`
DeleteSafety *SwBlockVolumeDeleteSafetyDecision `json:"delete_safety,omitempty"`
ReplicaReintegrations []ReturnedReplicaProjection `json:"replica_reintegrations,omitempty"`
NonClaims []string `json:"non_claims,omitempty"`
EvidenceRefs []string `json:"evidence_refs,omitempty"`
VolumeID string `json:"volume_id,omitempty"`
Namespace string `json:"namespace,omitempty"`
PVCName string `json:"pvc_name,omitempty"`
PVName string `json:"pv_name,omitempty"`
StorageClass string `json:"storage_class,omitempty"`
ReplicationFactor int `json:"replication_factor,omitempty"`
AckProfile string `json:"ack_profile,omitempty"`
ClaimProfile string `json:"claim_profile,omitempty"`
PrimaryReplicaID string `json:"primary_replica_id,omitempty"`
PublishTarget string `json:"publish_target,omitempty"`
AuthorityEpoch uint64 `json:"authority_epoch,omitempty"`
AuthorityEndpointVersion uint64 `json:"authority_endpoint_version,omitempty"`
Status string `json:"status"`
ReasonCode string `json:"reason_code,omitempty"`
States ManagedVolumeStates `json:"states"`
Actions []ManagedVolumeAction `json:"actions,omitempty"`
Conditions []ObservationCondition `json:"conditions,omitempty"`
DeleteSafety *SwBlockVolumeDeleteSafetyDecision `json:"delete_safety,omitempty"`
ReplicaReintegrations []ReturnedReplicaProjection `json:"replica_reintegrations,omitempty"`
NonClaims []string `json:"non_claims,omitempty"`
EvidenceRefs []string `json:"evidence_refs,omitempty"`
}
type ReturnedReplicaProjection struct {
@@ -298,6 +302,11 @@ func RenderManagedVolumeProjectionText(projection ManagedVolumeProjection) strin
emptyAsDash(projection.States.HostPath),
emptyAsDash(projection.States.Recovery),
emptyAsDash(projection.States.Workload))
fmt.Fprintf(&b, "managed_volume_authority primary=%s publish_target=%s epoch=%d endpoint_version=%d\n",
emptyAsDash(projection.PrimaryReplicaID),
emptyAsDash(projection.PublishTarget),
projection.AuthorityEpoch,
projection.AuthorityEndpointVersion)
if projection.DeleteSafety != nil {
fmt.Fprintf(&b, "managed_volume_delete_safety state=%s decision=%s reason=%s release_allowed=%t action=%s\n",
emptyAsDash(projection.DeleteSafety.State),
@@ -486,6 +495,12 @@ func ProjectManagedVolume(facts ManagedVolumeFacts) ManagedVolumeProjection {
},
EvidenceRefs: append([]string(nil), facts.EvidenceRefs...),
}
if facts.Authority != nil {
projection.PrimaryReplicaID = facts.Authority.PrimaryReplica
projection.PublishTarget = facts.Authority.PublishTarget
projection.AuthorityEpoch = facts.Authority.Epoch
projection.AuthorityEndpointVersion = facts.Authority.EndpointVersion
}
deriveManagedVolumeStates(&projection, facts)
projection.ReplicaReintegrations = returnedReplicaProjections(facts)
@@ -47,6 +47,16 @@ func TestManagedVolumeProjection_HealthyFirstVolumeReady(t *testing.T) {
projection.States.Workload != ManagedVolumeWorkloadVerified {
t.Fatalf("states=%+v", projection.States)
}
if projection.PrimaryReplicaID != "r1" ||
projection.PublishTarget != "127.0.0.1:3260" ||
projection.AuthorityEpoch != 1 ||
projection.AuthorityEndpointVersion != 1 {
t.Fatalf("authority facts primary=%s target=%s epoch=%d endpoint=%d",
projection.PrimaryReplicaID,
projection.PublishTarget,
projection.AuthorityEpoch,
projection.AuthorityEndpointVersion)
}
if len(projection.Actions) != 1 || projection.Actions[0].Type != ManagedVolumeActionCollectBundle {
t.Fatalf("actions=%+v", projection.Actions)
}
@@ -9,17 +9,21 @@ type ManagedVolumeOperatorContract struct {
}
type ManagedVolumeOperatorStatus struct {
VolumeID string `json:"volume_id,omitempty"`
PVCName string `json:"pvc_name,omitempty"`
Status string `json:"status"`
ReasonCode string `json:"reason_code,omitempty"`
Conditions []ObservationCondition `json:"conditions,omitempty"`
DeleteSafety *SwBlockVolumeDeleteSafetyDecision `json:"delete_safety,omitempty"`
ReplicaReintegrations []ReturnedReplicaProjection `json:"replica_reintegrations,omitempty"`
ExecutorPreflights []ReturnedReplicaExecutorPreflight `json:"executor_preflights,omitempty"`
ExecutorContracts []ReturnedReplicaExecutorContract `json:"executor_contracts,omitempty"`
NonClaims []string `json:"non_claims,omitempty"`
EvidenceRefs []string `json:"evidence_refs,omitempty"`
VolumeID string `json:"volume_id,omitempty"`
PVCName string `json:"pvc_name,omitempty"`
PrimaryReplicaID string `json:"primary_replica_id,omitempty"`
PublishTarget string `json:"publish_target,omitempty"`
AuthorityEpoch uint64 `json:"authority_epoch,omitempty"`
AuthorityEndpointVersion uint64 `json:"authority_endpoint_version,omitempty"`
Status string `json:"status"`
ReasonCode string `json:"reason_code,omitempty"`
Conditions []ObservationCondition `json:"conditions,omitempty"`
DeleteSafety *SwBlockVolumeDeleteSafetyDecision `json:"delete_safety,omitempty"`
ReplicaReintegrations []ReturnedReplicaProjection `json:"replica_reintegrations,omitempty"`
ExecutorPreflights []ReturnedReplicaExecutorPreflight `json:"executor_preflights,omitempty"`
ExecutorContracts []ReturnedReplicaExecutorContract `json:"executor_contracts,omitempty"`
NonClaims []string `json:"non_claims,omitempty"`
EvidenceRefs []string `json:"evidence_refs,omitempty"`
}
type ManagedVolumeOperatorEvent struct {
@@ -49,17 +53,21 @@ func ManagedVolumeOperatorContractFromProjection(projection ManagedVolumeProject
APIVersion: "block.seaweedfs.com/v1alpha1",
Kind: "ManagedVolumeStatusContract",
Status: ManagedVolumeOperatorStatus{
VolumeID: projection.VolumeID,
PVCName: projection.PVCName,
Status: projection.Status,
ReasonCode: projection.ReasonCode,
Conditions: append([]ObservationCondition(nil), projection.Conditions...),
DeleteSafety: cloneSwBlockVolumeDeleteSafetyDecision(projection.DeleteSafety),
ReplicaReintegrations: cloneReturnedReplicaProjections(projection.ReplicaReintegrations),
ExecutorPreflights: cloneReturnedReplicaExecutorPreflights(ReturnedReplicaExecutorPreflights(projection)),
ExecutorContracts: cloneReturnedReplicaExecutorContracts(ReturnedReplicaExecutorContracts(projection)),
NonClaims: append([]string(nil), projection.NonClaims...),
EvidenceRefs: append([]string(nil), projection.EvidenceRefs...),
VolumeID: projection.VolumeID,
PVCName: projection.PVCName,
PrimaryReplicaID: projection.PrimaryReplicaID,
PublishTarget: projection.PublishTarget,
AuthorityEpoch: projection.AuthorityEpoch,
AuthorityEndpointVersion: projection.AuthorityEndpointVersion,
Status: projection.Status,
ReasonCode: projection.ReasonCode,
Conditions: append([]ObservationCondition(nil), projection.Conditions...),
DeleteSafety: cloneSwBlockVolumeDeleteSafetyDecision(projection.DeleteSafety),
ReplicaReintegrations: cloneReturnedReplicaProjections(projection.ReplicaReintegrations),
ExecutorPreflights: cloneReturnedReplicaExecutorPreflights(ReturnedReplicaExecutorPreflights(projection)),
ExecutorContracts: cloneReturnedReplicaExecutorContracts(ReturnedReplicaExecutorContracts(projection)),
NonClaims: append([]string(nil), projection.NonClaims...),
EvidenceRefs: append([]string(nil), projection.EvidenceRefs...),
},
}
for _, condition := range projection.Conditions {
@@ -1,6 +1,10 @@
package ops
import "testing"
import (
"encoding/json"
"strings"
"testing"
)
func TestManagedVolumeOperatorContract_ReadinessConditionAndEvents(t *testing.T) {
projection := ProjectManagedVolume(ManagedVolumeFacts{
@@ -8,8 +12,10 @@ func TestManagedVolumeOperatorContract_ReadinessConditionAndEvents(t *testing.T)
PVCName: "demo-pvc",
PVC: &PVCFact{Phase: "Bound"},
Authority: &AuthorityFact{
PrimaryReplica: "r1",
PublishTarget: "127.0.0.1:3260",
PrimaryReplica: "r1",
PublishTarget: "127.0.0.1:3260",
Epoch: 7,
EndpointVersion: 9,
},
Replicas: []ReplicaFact{{
ReplicaID: "r1",
@@ -34,6 +40,21 @@ func TestManagedVolumeOperatorContract_ReadinessConditionAndEvents(t *testing.T)
if len(contract.Status.Conditions) < 2 {
t.Fatalf("conditions=%+v", contract.Status.Conditions)
}
if contract.Status.PrimaryReplicaID != "r1" ||
contract.Status.PublishTarget != "127.0.0.1:3260" ||
contract.Status.AuthorityEpoch != 7 ||
contract.Status.AuthorityEndpointVersion != 9 {
t.Fatalf("authority status=%+v", contract.Status)
}
raw, err := json.Marshal(contract.Status)
if err != nil {
t.Fatalf("marshal status: %v", err)
}
for _, want := range []string{`"primary_replica_id":"r1"`, `"publish_target":"127.0.0.1:3260"`, `"authority_epoch":7`, `"authority_endpoint_version":9`} {
if !strings.Contains(string(raw), want) {
t.Fatalf("operator status missing %s: %s", want, string(raw))
}
}
if len(contract.Events) == 0 || contract.Events[0].Type != "Warning" {
t.Fatalf("events=%+v", contract.Events)
}
@@ -138,6 +138,12 @@ func renderManagedProjectionSummary(b *strings.Builder, managed ManagedVolumePro
emptyAsDash(managed.VolumeID),
emptyAsDash(managed.Status),
emptyAsDash(managed.ReasonCode))
fmt.Fprintf(b, "managed_volume_authority=%s primary=%s publish_target=%s epoch=%d endpoint_version=%d\n",
emptyAsDash(managed.VolumeID),
emptyAsDash(managed.PrimaryReplicaID),
emptyAsDash(managed.PublishTarget),
managed.AuthorityEpoch,
managed.AuthorityEndpointVersion)
for _, condition := range managed.Conditions {
fmt.Fprintf(b, "managed_volume_condition=%s status=%s reason=%s severity=%s\n",
emptyAsDash(condition.Type),
@@ -80,6 +80,7 @@ func TestObservationReportSummary_IncludesManagedVolumeStatus(t *testing.T) {
"cleanup_evidence=cleanup-summary.txt",
"volume=pvc-healthy status=ok pvc=default/mysql-data",
"managed_volume=pvc-healthy status=ready reason=first_volume_verified",
"managed_volume_authority=pvc-healthy primary=r1 publish_target=192.168.1.181:3260 epoch=1 endpoint_version=1",
"managed_volume_condition=Ready status=True reason=first_volume_verified severity=info",
"managed_volume_action=observe.collect_bundle mode=read_only side_effect=observe",
} {
@@ -263,19 +263,23 @@ func supportBundleReason(cluster ClusterEvidence) string {
}
type SwBlockVolumeCRDStatus struct {
VolumeID string `json:"volumeID,omitempty"`
PVCName string `json:"pvcName,omitempty"`
Status string `json:"status"`
ReasonCode string `json:"reasonCode,omitempty"`
ObservedAt time.Time `json:"observedAt,omitempty"`
Conditions []ObservationCondition `json:"conditions,omitempty"`
DeleteSafety *SwBlockVolumeCRDDeleteSafety `json:"deleteSafety"`
ReplicaReintegrations []SwBlockVolumeCRDReturnedReplica `json:"replicaReintegrations,omitempty"`
ExecutorPreflights []SwBlockVolumeCRDExecutorPreflight `json:"executorPreflights,omitempty"`
ExecutorContracts []SwBlockVolumeCRDExecutorContract `json:"executorContracts,omitempty"`
NonClaims []string `json:"nonClaims,omitempty"`
EvidenceRefs []string `json:"evidenceRefs,omitempty"`
AllowedActions []SwBlockVolumeCRDAction `json:"allowedActions,omitempty"`
VolumeID string `json:"volumeID,omitempty"`
PVCName string `json:"pvcName,omitempty"`
PrimaryReplicaID string `json:"primaryReplicaID,omitempty"`
PublishTarget string `json:"publishTarget,omitempty"`
AuthorityEpoch uint64 `json:"authorityEpoch,omitempty"`
AuthorityEndpointVersion uint64 `json:"authorityEndpointVersion,omitempty"`
Status string `json:"status"`
ReasonCode string `json:"reasonCode,omitempty"`
ObservedAt time.Time `json:"observedAt,omitempty"`
Conditions []ObservationCondition `json:"conditions,omitempty"`
DeleteSafety *SwBlockVolumeCRDDeleteSafety `json:"deleteSafety"`
ReplicaReintegrations []SwBlockVolumeCRDReturnedReplica `json:"replicaReintegrations,omitempty"`
ExecutorPreflights []SwBlockVolumeCRDExecutorPreflight `json:"executorPreflights,omitempty"`
ExecutorContracts []SwBlockVolumeCRDExecutorContract `json:"executorContracts,omitempty"`
NonClaims []string `json:"nonClaims,omitempty"`
EvidenceRefs []string `json:"evidenceRefs,omitempty"`
AllowedActions []SwBlockVolumeCRDAction `json:"allowedActions,omitempty"`
}
type SwBlockVolumeCRDReturnedReplica struct {
@@ -502,19 +506,23 @@ func (r OperatorStatusReconciler) Reconcile(ctx context.Context) (OperatorStatus
Name: SwBlockVolumeObjectName(volume.Status),
}
volumeStatus := SwBlockVolumeCRDStatus{
VolumeID: volume.Status.VolumeID,
PVCName: volume.Status.PVCName,
Status: volume.Status.Status,
ReasonCode: volume.Status.ReasonCode,
ObservedAt: observedAt,
Conditions: append([]ObservationCondition(nil), volume.Status.Conditions...),
DeleteSafety: swBlockVolumeCRDDeleteSafety(volume.Status.DeleteSafety),
ReplicaReintegrations: swBlockVolumeCRDReturnedReplicas(volume.Status.ReplicaReintegrations),
ExecutorPreflights: swBlockVolumeCRDExecutorPreflights(volume.Status.ExecutorPreflights),
ExecutorContracts: swBlockVolumeCRDExecutorContracts(volume.Status.ExecutorContracts),
NonClaims: append([]string(nil), volume.Status.NonClaims...),
EvidenceRefs: append([]string(nil), volume.Status.EvidenceRefs...),
AllowedActions: swBlockVolumeCRDActions(volume.AllowedActions),
VolumeID: volume.Status.VolumeID,
PVCName: volume.Status.PVCName,
PrimaryReplicaID: volume.Status.PrimaryReplicaID,
PublishTarget: volume.Status.PublishTarget,
AuthorityEpoch: volume.Status.AuthorityEpoch,
AuthorityEndpointVersion: volume.Status.AuthorityEndpointVersion,
Status: volume.Status.Status,
ReasonCode: volume.Status.ReasonCode,
ObservedAt: observedAt,
Conditions: append([]ObservationCondition(nil), volume.Status.Conditions...),
DeleteSafety: swBlockVolumeCRDDeleteSafety(volume.Status.DeleteSafety),
ReplicaReintegrations: swBlockVolumeCRDReturnedReplicas(volume.Status.ReplicaReintegrations),
ExecutorPreflights: swBlockVolumeCRDExecutorPreflights(volume.Status.ExecutorPreflights),
ExecutorContracts: swBlockVolumeCRDExecutorContracts(volume.Status.ExecutorContracts),
NonClaims: append([]string(nil), volume.Status.NonClaims...),
EvidenceRefs: append([]string(nil), volume.Status.EvidenceRefs...),
AllowedActions: swBlockVolumeCRDActions(volume.AllowedActions),
}
if err := r.Writer.WriteVolumeStatus(ctx, volumeRef, volumeStatus); err != nil {
if IsKubernetesStatusNotFound(err) {
@@ -34,8 +34,10 @@ func TestOperatorStatusReconcilerWritesStatusOnlyProjection(t *testing.T) {
PVCName: "demo-pvc",
PVC: &PVCFact{Phase: "Bound"},
Authority: &AuthorityFact{
PrimaryReplica: "r1",
PublishTarget: "192.168.1.184:3260",
PrimaryReplica: "r1",
PublishTarget: "192.168.1.184:3260",
Epoch: 11,
EndpointVersion: 12,
},
Replicas: []ReplicaFact{{
ReplicaID: "r1",
@@ -95,6 +97,12 @@ func TestOperatorStatusReconcilerWritesStatusOnlyProjection(t *testing.T) {
if got := writer.volumes[0].status.Status; got != ManagedVolumeStatusReady {
t.Fatalf("ready volume status=%s", got)
}
if ready := writer.volumes[0].status; ready.PrimaryReplicaID != "r1" ||
ready.PublishTarget != "192.168.1.184:3260" ||
ready.AuthorityEpoch != 11 ||
ready.AuthorityEndpointVersion != 12 {
t.Fatalf("ready volume authority status=%+v", ready)
}
if got := writer.volumes[1].status.ReasonCode; got != ReasonCSINodeImagePullFailed {
t.Fatalf("blocked volume reason=%s", got)
}
@@ -112,9 +120,19 @@ func TestOperatorStatusReconcilerWritesStatusOnlyProjection(t *testing.T) {
if !strings.Contains(string(rawStatus), `"mutationAllowed":false`) {
t.Fatalf("CRD volume status must use camelCase mutationAllowed: %s", string(rawStatus))
}
for _, want := range []string{`"primaryReplicaID":"r1"`, `"publishTarget":"192.168.1.184:3260"`, `"authorityEpoch":11`, `"authorityEndpointVersion":12`} {
if !strings.Contains(string(rawStatus), want) {
t.Fatalf("CRD volume status missing %s: %s", want, string(rawStatus))
}
}
if strings.Contains(string(rawStatus), "mutation_allowed") {
t.Fatalf("CRD volume status must not use operator-snapshot snake_case fields: %s", string(rawStatus))
}
for _, forbidden := range []string{"primary_replica_id", "publish_target", "authority_epoch", "authority_endpoint_version"} {
if strings.Contains(string(rawStatus), forbidden) {
t.Fatalf("CRD volume status leaked snake_case %s: %s", forbidden, string(rawStatus))
}
}
if events.countByReason(ReasonFirstVolumeVerified) == 0 {
t.Fatalf("missing ready event: %+v", events.events)
}
+3
View File
@@ -539,6 +539,9 @@ control-plane path is mature.
- candidate -> syncing/rebuilding -> ready is visible in CRD/report/dashboard
- ready status gates placement/ACK eligibility
- rebuild/reintegration/failback action owner is explicit and audited
- current authority facts are visible in `SwBlockVolume.status`
(`primaryReplicaID`, `publishTarget`, `authorityEpoch`) before any
failback activation path consumes them
4. Flow-control and pressure behavior.
@@ -205,6 +205,7 @@ ambiguous HTTP/gRPC runtime addresses.
| action/preflight contract | `core/ops/returned_replica_executor_preflight.go`, `core/ops/returned_replica_executor_contract.go` |
| failback target owner | `core/ops/failback_target_owner_controller.go` |
| failback executor controller | `core/ops/failback_executor_controller.go` |
| current authority status projection | `core/ops/managed_volume_model.go`, `core/ops/managed_volume_operator_contract.go`, `core/ops/operator_status_controller.go` |
| HTTP runtime | `core/ops/failback_runtime_http.go` |
| gRPC runtime | `core/ops/failback_runtime_grpc.go` |
| authority runtime adapter | `core/ops/failback_authority_runtime_adapter.go` |
@@ -233,6 +234,7 @@ ambiguous HTTP/gRPC runtime addresses.
| 86 | decouples gRPC runtime from target-local HTTP `runtimeEndpoint` |
| 87 | aligns README/wiki/roadmap with source-gated failback claims |
| 88 | packages target owner + executor + blockmaster RPC as one explicit Helm suite |
| 89 | projects current authority facts into `SwBlockVolume.status`, operator-snapshot, and summary text for later expected-current failback activation |
## Failure Classes
@@ -253,13 +255,15 @@ Before enabling broader failback behavior:
1. Prove the target exists and is volume-scoped.
2. Prove ACK eligibility and frontier coverage came from live evidence.
3. Prove the target was frontend-fenced before failback.
4. Pass expected-current replica and epoch to blockmaster.
5. Run through blockmaster-owned `FailbackService`, not a sidecar authority copy.
6. Require terminal evidence before writing `failed_back`.
7. Keep frontend publication as a separate gated action.
8. Keep rebuild/catch-up traffic as a separate gated action.
9. Run multi-volume isolation gates.
10. Document exactly what is automatic and what is opt-in.
4. Read expected-current replica and epoch from `SwBlockVolume.status`
(`primaryReplicaID`, `authorityEpoch`) before activating a failback target.
5. Pass expected-current replica and epoch to blockmaster.
6. Run through blockmaster-owned `FailbackService`, not a sidecar authority copy.
7. Require terminal evidence before writing `failed_back`.
8. Keep frontend publication as a separate gated action.
9. Keep rebuild/catch-up traffic as a separate gated action.
10. Run multi-volume isolation gates.
11. Document exactly what is automatic and what is opt-in.
## Current Limits
+69 -47
View File
@@ -1,86 +1,108 @@
# Current Plan: Phase 88 Failback Deployed Suite Packaging
# Current Plan: Phase 89 SwBlockVolume Authority Facts
Status: complete.
## Goal
Phase 88 closes the next safe step after the source-gated failback runtime:
prove the deployable Kubernetes component suite can be rendered together with
explicit opt-in values, bounded RBAC, and schema coverage.
This phase does **not** claim automatic live failback. It packages the pieces
needed for a later live release smoke:
Phase 89 closes the status-evidence gap found after Phase 88. The failback
target owner can only safely activate a returned-replica failback target when
it has current authority inputs:
```text
blockmaster FailbackService RPC
failback target owner
failback executor
executor gRPC runtime address
explicit execution policy
expectedCurrentReplicaID
expectedCurrentEpoch
```
Those facts already exist in internal volume evidence, but they were not
visible on `SwBlockVolume.status`. This phase projects them through the
read-only/status path so later failback activation can consume observed state
instead of hardcoded or manual inputs.
## Deliverables
### D1: Helm Values Schema
### D1: Projection Contract
Added `failbackTargetOwner` to `charts/seaweed-block/values.schema.json` so the
full failback component suite is schema-visible, not just template-visible.
`ManagedVolumeProjection` now preserves:
### D2: Deployed Suite Gate
```text
primary_replica_id
publish_target
authority_epoch
authority_endpoint_version
```
`ManagedVolumeOperatorStatus` exposes the same fields in snake_case for
`operator-snapshot.json`.
### D2: Kubernetes Status Contract
`SwBlockVolume.status` now exposes the same facts as camelCase:
```text
primaryReplicaID
publishTarget
authorityEpoch
authorityEndpointVersion
```
The CRD schema includes those fields with integer `int64` authority counters.
### D3: Report Surface
`summary.txt` now includes a compact authority line:
```text
managed_volume_authority=<volume> primary=<replica> publish_target=<addr> epoch=<n> endpoint_version=<n>
```
### D4: Gate
Added:
```text
scripts/run-phase88-failback-deployed-suite-gate.sh
testops/scenarios/failback-deployed-suite-chain.yaml
scripts/run-phase89-swblockvolume-authority-facts-gate.sh
testops/scenarios/swblockvolume-authority-facts-chain.yaml
```
The gate proves:
```text
defaults omit failback runtime RPC, target owner, executor, and execution flags
explicit values render all three deployable pieces
target owner can create only SwBlockReplicaFailback targets
executor can write only SwBlockReplicaFailback.status
execution still requires explicit policy and gRPC address
frontend publication after failback is still not rendered
values schema covers target owner and executor knobs
projection preserves observed authority facts
operator-snapshot uses snake_case authority fields
SwBlockVolume.status uses camelCase authority fields
CRD schema contains the new status fields
report summary includes authority facts
no failback target is created
no failback activation is attempted
```
## Verification
```text
"C:\Program Files\Git\bin\bash.exe" scripts/run-phase88-failback-deployed-suite-gate.sh .
C:\work\swblock.exe validate testops/scenarios/failback-deployed-suite-chain.yaml
bash scripts/run-phase89-swblockvolume-authority-facts-gate.sh .
swblock validate testops/scenarios/swblockvolume-authority-facts-chain.yaml
```
Expected terminal evidence:
```text
phase88_failback_deployed_suite_status=ok
default_omits_failback_target_owner=true
default_omits_failback_executor=true
enabled_renders_failback_target_owner=true
enabled_renders_failback_executor=true
values_schema_covers_failback_suite=true
target_owner_rbac_create_targets_only=true
executor_rbac_status_only=true
automatic_failback_claimed=false
frontend_publication_after_failback_claimed=false
phase89_swblockvolume_authority_facts_status=ok
crd_status_primary_replica_id=true
crd_status_authority_epoch=true
operator_snapshot_snake_authority=true
crd_status_camel_authority=true
report_summary_authority_line=true
failback_activation_attempted=false
failback_target_created=false
```
## Next
The next step is the first real Kubernetes failback release smoke:
Phase 90 should use these status facts to make failback target activation
explicitly evidence-gated:
```text
fresh local images
install with failback suite enabled
create a real volume and returned-replica target
executor calls blockmaster gRPC
authority moves only with terminal evidence
no frontend publication claim until the publication phase lands
only activate when SwBlockVolume.status has current primary + epoch
write expectedCurrentReplicaID and expectedCurrentEpoch onto the target
still do not claim frontend publication after failback
```
If that smoke is too lab-expensive, defer the live claim and start the next
operation-layer close gate before NVMe.
@@ -0,0 +1,66 @@
# Phase 89 Finished Plan: SwBlockVolume Authority Facts
Status: complete.
Date: 2026-06-26.
## What Changed
Phase 89 projects current authority facts into the status/read surfaces used by
the operation layer:
```text
primary replica
publish target
authority epoch
authority endpoint version
```
These fields are now visible in:
```text
ManagedVolumeProjection
operator-snapshot.json
SwBlockVolume.status
summary.txt
```
## Why
Failback activation needs a positive current-authority input before it can set:
```text
expectedCurrentReplicaID
expectedCurrentEpoch
```
Before this phase, the data existed in evidence but was not exposed on the
canonical Kubernetes status object. That would force a future activation path
to use manual values or duplicate evidence parsing.
## Boundary
This phase does not:
```text
create SwBlockReplicaFailback targets
activate failback
call the failback executor
publish a frontend after failback
mutate storage
```
It is a status projection phase only.
## Verification
```text
scripts/run-phase89-swblockvolume-authority-facts-gate.sh .
swblock validate testops/scenarios/swblockvolume-authority-facts-chain.yaml
```
Expected result:
```text
phase89_swblockvolume_authority_facts_status=ok
```
+13 -3
View File
@@ -725,9 +725,19 @@ Approximate engineering effort if scope remains tight:
status now carries `frontendPublicationDecision`, `frontendPublicationReason`,
and `frontendPublicationMutationAllowed`; the decision is currently
`disabled` with mutation allowed false.
- Phase 69 should define the frontend publication target contract and
admission/RBAC boundary before any real frontend publication mutation. Do not
jump directly to failback.
- Phase 88 Failback Deployed Suite Packaging is closed. The failback target
owner, failback executor, and blockmaster gRPC runtime can be rendered as one
explicit opt-in suite, still without claiming automatic failback or frontend
publication.
- Phase 89 SwBlockVolume Authority Facts is closed. `SwBlockVolume.status` now
exposes `primaryReplicaID`, `publishTarget`, `authorityEpoch`, and
`authorityEndpointVersion`; operator-snapshot and summary surfaces expose the
same facts. These fields are the observed inputs for the next failback target
activation phase.
- Phase 90 should use the Phase 89 authority facts to activate
`SwBlockReplicaFailback` targets with explicit expected-current replica and
epoch, while preserving the non-claims that frontend publication and automatic
failback remain disabled until their own gates pass.
- Phase 41-44 are the Operation Layer v0.5 release train: lifecycle-owner
foundation, real API/admission proof, first bounded finalizer mutation, and
delete lifecycle close gate.
@@ -0,0 +1,54 @@
# Phase 89 QA Sign-off: SwBlockVolume Authority Facts
Status: pending QA.
## Scope
Validate that observed authority facts are projected into read/status surfaces
without enabling failback execution.
## Gate
Run:
```text
bash scripts/run-phase89-swblockvolume-authority-facts-gate.sh .
swblock validate testops/scenarios/swblockvolume-authority-facts-chain.yaml
```
## Required Evidence
The summary must contain:
```text
phase89_swblockvolume_authority_facts_status=ok
go_test_core_ops_authority_projection=pass
crd_status_primary_replica_id=true
crd_status_publish_target=true
crd_status_authority_epoch=true
crd_status_authority_endpoint_version=true
operator_snapshot_snake_authority=true
crd_status_camel_authority=true
report_summary_authority_line=true
failback_activation_inputs_visible=true
expected_current_replica_source=swblockvolume.status.primaryReplicaID
expected_current_epoch_source=swblockvolume.status.authorityEpoch
failback_activation_attempted=false
failback_target_created=false
storage_mutation_allowed=false
```
## Pass Criteria
- `ManagedVolumeProjection` preserves primary replica, publish target, epoch,
and endpoint version.
- `operator-snapshot.json` uses snake_case authority fields.
- `SwBlockVolume.status` uses camelCase authority fields.
- The CRD schema contains the new status fields and does not leak snake_case.
- `summary.txt` includes the authority line.
- No failback target is created and no failback activation is attempted.
## Non-Claims
Phase 89 does not prove live failback. It only exposes the status evidence that
the next activation phase must consume.
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
set -euo pipefail
PRODUCT_ROOT="${1:-$(pwd)}"
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${PRODUCT_ROOT}/results/phase89-swblockvolume-authority-facts-gate}"
SUMMARY="${ARTIFACT_DIR}/phase89-swblockvolume-authority-facts-summary.txt"
TEST_LOG="${ARTIFACT_DIR}/go-test-core-ops.log"
mkdir -p "${ARTIFACT_DIR}"
: >"${SUMMARY}"
write_summary() {
echo "$*" | tee -a "${SUMMARY}" >/dev/null
}
require_text() {
local name="$1"
local pattern="$2"
local file="$3"
local found="false"
if grep -Fq -- "${pattern}" "${file}"; then
found="true"
fi
write_summary "${name}=${found}"
if [ "${found}" != "true" ]; then
echo "missing ${name}: ${pattern}" >&2
return 1
fi
}
require_absent() {
local name="$1"
local pattern="$2"
local file="$3"
local absent="true"
if grep -Fq -- "${pattern}" "${file}"; then
absent="false"
fi
write_summary "${name}=${absent}"
if [ "${absent}" != "true" ]; then
echo "unexpected ${name}: ${pattern}" >&2
return 1
fi
}
write_summary "phase89_swblockvolume_authority_facts_status=running"
write_summary "phase89_scope=swblockvolume_status_authority_fact_projection"
write_summary "failback_activation_attempted=false"
write_summary "failback_target_created=false"
write_summary "storage_mutation_allowed=false"
TEST_RE='TestObservationReportSummary_IncludesManagedVolumeStatus|TestManagedVolumeProjection_HealthyFirstVolumeReady|TestManagedVolumeOperatorContract_ReadinessConditionAndEvents|TestOperatorStatusReconcilerWritesStatusOnlyProjection|TestPhase89SwBlockVolumeAuthorityFactsSchema'
if (cd "${PRODUCT_ROOT}" && go test ./core/ops -run "${TEST_RE}" -count=1 -v) >"${TEST_LOG}" 2>&1; then
write_summary "go_test_core_ops_authority_projection=pass"
else
write_summary "go_test_core_ops_authority_projection=fail"
cat "${TEST_LOG}" >&2 || true
exit 1
fi
CRD="${PRODUCT_ROOT}/charts/seaweed-block/crds/swblockvolumes.block.seaweedfs.com.yaml"
require_text "crd_status_primary_replica_id" "primaryReplicaID:" "${CRD}"
require_text "crd_status_publish_target" "publishTarget:" "${CRD}"
require_text "crd_status_authority_epoch" "authorityEpoch:" "${CRD}"
require_text "crd_status_authority_endpoint_version" "authorityEndpointVersion:" "${CRD}"
require_absent "crd_status_omits_snake_primary_replica_id" "primary_replica_id:" "${CRD}"
require_absent "crd_status_omits_snake_authority_epoch" "authority_epoch:" "${CRD}"
require_text "projection_preserves_primary_replica" "projection.PrimaryReplicaID != \"r1\"" "${PRODUCT_ROOT}/core/ops/managed_volume_model_test.go"
require_text "operator_snapshot_snake_authority" "\"primary_replica_id\":\"r1\"" "${PRODUCT_ROOT}/core/ops/managed_volume_operator_contract_test.go"
require_text "crd_status_camel_authority" "\"primaryReplicaID\":\"r1\"" "${PRODUCT_ROOT}/core/ops/operator_status_controller_test.go"
require_text "report_summary_authority_line" "managed_volume_authority=pvc-healthy primary=r1 publish_target=192.168.1.181:3260 epoch=1 endpoint_version=1" "${PRODUCT_ROOT}/core/ops/observation_report_test.go"
write_summary "failback_activation_inputs_visible=true"
write_summary "expected_current_replica_source=swblockvolume.status.primaryReplicaID"
write_summary "expected_current_epoch_source=swblockvolume.status.authorityEpoch"
write_summary "automatic_failback_claimed=false"
write_summary "frontend_publication_after_failback_claimed=false"
write_summary "phase89_swblockvolume_authority_facts_status=ok"
@@ -0,0 +1,97 @@
# Runner-native Phase 89 gate: SwBlockVolume.status exposes current authority
# facts for later failback target activation. This is status projection only,
# not a failback execution claim.
name: swblockvolume-authority-facts-chain
timeout: 5m
env:
product_root: "/tmp/seaweed_block"
ssh_key: "C:\\work\\dev_server\\testdev_key"
topology:
nodes:
m02:
host: 192.168.1.184
user: testdev
key: "{{ ssh_key }}"
phases:
- name: swblockvolume_authority_facts_gate
actions:
- action: exec
node: m02
timeout: 4m
cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts && cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts bash scripts/run-phase89-swblockvolume-authority-facts-gate.sh {{ product_root }}"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts/phase89-swblockvolume-authority-facts-summary.txt"
pattern: "^phase89_swblockvolume_authority_facts_status=ok$"
save_as: phase89_ok
- action: assert_greater
actual: "{{ phase89_ok }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts/phase89-swblockvolume-authority-facts-summary.txt"
pattern: "^crd_status_primary_replica_id=true$"
save_as: crd_primary
- action: assert_greater
actual: "{{ crd_primary }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts/phase89-swblockvolume-authority-facts-summary.txt"
pattern: "^crd_status_authority_epoch=true$"
save_as: crd_epoch
- action: assert_greater
actual: "{{ crd_epoch }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts/phase89-swblockvolume-authority-facts-summary.txt"
pattern: "^operator_snapshot_snake_authority=true$"
save_as: snapshot_authority
- action: assert_greater
actual: "{{ snapshot_authority }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts/phase89-swblockvolume-authority-facts-summary.txt"
pattern: "^crd_status_camel_authority=true$"
save_as: crd_camel
- action: assert_greater
actual: "{{ crd_camel }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts/phase89-swblockvolume-authority-facts-summary.txt"
pattern: "^report_summary_authority_line=true$"
save_as: report_authority
- action: assert_greater
actual: "{{ report_authority }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts/phase89-swblockvolume-authority-facts-summary.txt"
pattern: "^failback_activation_attempted=false$"
save_as: no_failback_activation
- action: assert_greater
actual: "{{ no_failback_activation }}"
threshold: "0"
- name: collect
always: true
actions:
- action: collect_path
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase89-swblockvolume-authority-facts"
name: "remote-phases"
ignore_error: true