phase46: close returned replica productization

This commit is contained in:
pingqiu committed 2026-06-19 08:46:06 -07:00
1 parent e69469f5fa
commit 27665477e7
6 files changed
+296 -37

No files matched your search

@@ -257,6 +257,105 @@ func TestObservationBundle_ReplaysReturnedReplicaProjection(t *testing.T) {
}
}
func TestObservationBundle_ReturnedReplicaProjectionIsVolumeScoped(t *testing.T) {
dir := t.TempDir()
productDir := filepath.Join(dir, "demo", "product-observation")
if err := os.MkdirAll(productDir, 0o755); err != nil {
t.Fatal(err)
}
cluster := NewClusterEvidence(time.Date(2026, 6, 19, 9, 0, 0, 0, time.UTC))
cluster.Volumes = []VolumeEvidence{{
VolumeID: "pvc-a",
Namespace: "default",
PVCName: "app-a",
ReplicationFactor: 2,
Status: ObservationStatusRecovering,
PrimaryReplica: "a-r2",
PublishTarget: "192.168.1.184:3260",
Epoch: 2,
EndpointVersion: 1,
Replicas: []ReplicaEvidence{{
ReplicaID: "a-r1",
KubernetesNode: "m01",
Observed: true,
Role: "previous_primary",
ReplicationRole: "replica_ready",
DurableFrontierKnown: true,
DurableFrontierLSN: 42,
FrontendPrimaryReady: false,
StalePrimaryFenced: true,
}, {
ReplicaID: "a-r2",
KubernetesNode: "m02",
Observed: true,
Role: "primary",
Healthy: true,
FrontendPrimaryReady: true,
ReplicationRole: "none",
FrontendAddr: "192.168.1.184:3260",
DurableFrontierKnown: true,
DurableFrontierLSN: 42,
}},
}, {
VolumeID: "pvc-b",
Namespace: "default",
PVCName: "app-b",
ReplicationFactor: 2,
Status: ObservationStatusOK,
PrimaryReplica: "b-r1",
PublishTarget: "192.168.1.188:3260",
Epoch: 1,
EndpointVersion: 1,
Replicas: []ReplicaEvidence{{
ReplicaID: "b-r1",
KubernetesNode: "tp01",
Observed: true,
Role: "primary",
Healthy: true,
FrontendPrimaryReady: true,
ReplicationRole: "none",
FrontendAddr: "192.168.1.188:3260",
DurableFrontierKnown: true,
DurableFrontierLSN: 7,
}}},
}
raw, err := MarshalObservationJSON(cluster)
if err != nil {
t.Fatal(err)
}
mustWrite(t, filepath.Join(productDir, ClusterEvidenceArtifact), string(raw))
replayed, err := BuildObservationFromBundle(ObservationBundleOptions{Dir: dir})
if err != nil {
t.Fatal(err)
}
summary := RenderObservationReportSummary(replayed)
if !strings.Contains(summary, "managed_volume_returned_replica=pvc-a replica=a-r1 state=fenced reason=returned_replica_frontend_fenced") {
t.Fatalf("summary missing pvc-a returned replica:\n%s", summary)
}
if strings.Contains(summary, "managed_volume_returned_replica=pvc-b") ||
strings.Contains(summary, "authority.reintegrate_returned_replica target=b-") {
t.Fatalf("pvc-b contaminated by pvc-a returned state:\n%s", summary)
}
snapshot := BuildOperatorFoundationSnapshot(replayed)
if len(snapshot.Volumes) != 2 {
t.Fatalf("snapshot volumes=%+v", snapshot.Volumes)
}
byID := map[string]ManagedVolumeOperatorContract{}
for _, volume := range snapshot.Volumes {
byID[volume.Status.VolumeID] = volume
}
if len(byID["pvc-a"].Status.ReplicaReintegrations) != 1 {
t.Fatalf("pvc-a returned replicas=%+v", byID["pvc-a"].Status.ReplicaReintegrations)
}
if len(byID["pvc-b"].Status.ReplicaReintegrations) != 0 {
t.Fatalf("pvc-b returned replicas=%+v", byID["pvc-b"].Status.ReplicaReintegrations)
}
if findManagedVolumeOperatorAction(byID["pvc-b"].AllowedActions, ManagedVolumeActionReintegrateReturned) != nil {
t.Fatalf("pvc-b got returned action: %+v", byID["pvc-b"].AllowedActions)
}
}
func TestObservationBundle_ManagedVolumeUsesPrimaryFailureArtifactHints(t *testing.T) {
dir := t.TempDir()
productDir := filepath.Join(dir, "demo", "product-observation")
+8 -9
View File
@@ -129,12 +129,12 @@ Recommended order from here:
The integrated PVC -> protected CR -> hold/release -> zero-residue path is
validated end-to-end.
3. Phase 46: productize returned-replica rebuild/reintegration status and
decisioning. **Active.** The engine/transport already has rebuild and
returned-replica safety pieces; the missing work is the Kubernetes/product
control loop: facts, judgment, action ownership, status, Events, fencing,
and multi-volume QA gates. Initial scope is status/decision productization;
automatic failback or broad rebuild execution remains a later executor
phase.
decisioning. **Closed 2026-06-19, QA PASS**
(`internal/docs/finished-plans/phase46_finishedplan_returned_replica_reintegration_productization.md`).
Returned replicas are now Kubernetes/product-surface visible, fenced from
frontend/ACK eligibility until evidence supports reintegration, and
volume-scoped across multi-volume reports. Automatic failback or broad
rebuild execution remains a later executor phase.
4. 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.
@@ -142,9 +142,8 @@ Recommended order from here:
The internal release-train contract is
`internal/docs/ref/operation-layer-v0.5-release-train.md`. Phases 41-44 close
the operation-layer loop for a bounded `SwBlockVolume` protection finalizer.
Phase 46 intentionally reuses this same fact -> judgment -> action -> evidence
pattern for returned-replica reintegration before any larger storage feature is
enabled.
Phase 46 reused this same fact -> judgment -> action -> evidence pattern for
returned-replica reintegration before any larger storage feature is enabled.
The practical rule is:
+15 -9
View File
@@ -177,16 +177,22 @@ Goal: prove the returned-replica lifecycle is per-volume and release-shaped.
Acceptance:
```text
[ ] returned replica on volume A does not affect volume B/C status
[ ] action decisions and reason codes remain volume-scoped
[ ] Events are bounded and stable
[ ] cleanup hygiene remains clean
[ ] finished plan records what is now claimed and what remains future work
[x] returned replica on volume A does not affect volume B/C status
[x] action decisions and reason codes remain volume-scoped
[x] Events are bounded and stable
[x] cleanup hygiene remains clean
[x] finished plan records what is now claimed and what remains future work
```
Implementation note: `TestObservationBundle_ReturnedReplicaProjectionIsVolumeScoped`
guards the multi-volume projection and action isolation. The returned-replica
projection does not add an event emitter in Phase 46; existing event identity
rules remain unchanged.
## Release Position
If Phase 46 passes, the product can claim that returned replicas are
Kubernetes-visible and safely fenced until reintegration evidence is sufficient.
It still must not claim automatic failback or production rebuild automation
unless an executor phase lands and is separately QA-validated.
Phase 46 passed for status/decision productization. The product can claim that
returned replicas are Kubernetes-visible and safely fenced until reintegration
evidence is sufficient. It still must not claim automatic failback or production
rebuild automation unless an executor phase lands and is separately
QA-validated.
@@ -0,0 +1,110 @@
# Phase 46 Finished Plan: Returned-Replica Reintegration Productization
Status: complete.
Branch: `phase46-returned-replica-reintegration`
## Goal
Make returned-replica recovery visible as a product lifecycle without claiming
automatic failback or rebuild execution.
The product now distinguishes:
```text
returned replica is reachable
!=
returned replica is frontend/ACK eligible
```
## What Landed
- Returned-replica state projection:
- `fenced`
- `recovering`
- `blocked`
- `unknown`
- `SwBlockVolume.status.replicaReintegrations[]` schema and CRD DTO mapping.
- Operator snapshot/report/explain/dashboard rendering for returned replicas.
- Action-model entries:
- `authority.reintegrate_returned_replica`
- `authority.rebuild_returned_replica`
- Both actions are decision-only in this phase:
- `mode=dry_run`
- `mutation_allowed=false`
- `decision=rejected reason=policy_disabled`
- Host fix: assignments blocked during durable recovery are replayed after
local readiness clears and replication is installed.
- TestOps live gate proves:
- `r2` remains the only primary/frontend-ready replica,
- returned `r1` is non-primary/frontend-fenced,
- returned `r1` becomes visible as a healthy peer after recovery,
- data remains readable after failover and return,
- cleanup is clean.
- Multi-volume gate proves returned-replica projection and actions are
volume-scoped.
## QA Evidence
| Gate | Evidence | Result |
|---|---|---|
| Component returned-replica gate | `20260619-083445-124f` | PASS, 16/16 |
| iSCSI returned-replica live chain | `20260619-083410-a413` | PASS, 57/57 |
| Product surfaces | `TestOpsReturnedReplicaFromBundleSurfacesAcrossReportExplainDashboard` | PASS |
| Multi-volume isolation | `TestObservationBundle_ReturnedReplicaProjectionIsVolumeScoped` | PASS |
## Fixed Product Gap
The live D5 gate exposed a real gap:
```text
assignment arrived while local readiness was blocked for durable recovery
-> assignment was skipped
-> recovery completed
-> returned replica stayed safe but under-projected
```
Fix:
```text
store last blocked assignment
-> clear local readiness after recovery
-> install replication volume
-> replay assignment
-> returned replica is admitted as SUPPORTING
-> frontend remains gated
```
## Product Claim After Phase 46
Seaweed Block can now claim:
```text
Returned replicas are Kubernetes-visible and product-surface visible.
They remain frontend/ACK fenced until explicit reintegration evidence exists.
Returned-replica action hints are dry-run/rejected unless a future executor is admitted.
```
## Non-Claims
Phase 46 does not claim:
- automatic failback,
- automatic returned-replica rebuild execution,
- production HA/SLO,
- NVMe ANA parity,
- backup/snapshot/restore.
## Next Work
The natural next phase is the real returned-replica executor decision:
```text
catch-up vs rebuild policy
-> executor admission boundary
-> evidence and progress reporting
-> terminal eligibility before ACK/frontend use
```
Until that lands, returned-replica reintegration remains status/action
productization, not automated repair.
+16 -19
View File
@@ -550,12 +550,12 @@ product risk. The recommended order is:
-> blocked/releasable -> finalizer behavior -> cleanup evidence -> support
bundle -> uninstall zero residue. Matching release images and pinned-image
smoke remain required before marking v0.5 released.
9. **Phase 46: returned-replica rebuild/reintegration productization.** Active.
High product value. The engine/transport has rebuild and returned-replica
safety pieces; the remaining work is productization through the lifecycle
action model: live facts, judgment, action owner, fencing, status, Events,
and multi-volume QA gates. Initial scope is status/decision productization,
not automatic failback or broad rebuild execution.
9. **Phase 46: returned-replica rebuild/reintegration productization.** Closed.
High product value. Returned-replica facts now project through the lifecycle
action model as visible, fenced, volume-scoped status/decision evidence
(`internal/docs/finished-plans/phase46_finishedplan_returned_replica_reintegration_productization.md`).
The phase intentionally stops short of automatic failback or broad rebuild
execution.
10. **Backup/snapshot/restore and NVMe ANA parity.**
Important, but they should reuse the status/action model rather than create
another isolated control plane.
@@ -573,12 +573,10 @@ Approximate engineering effort if scope remains tight:
- Lifecycle-owner finalizers: medium/high. Cleaner than operator-status main
patch, but requires a separate lifecycle-owner component plus real
API/admission proof that only finalizers can be patched.
- Productized returned-replica rebuild/reintegration/failback: high. The
low-level rebuild/recovery pieces exist, but shipping it as a product feature
requires lifecycle ownership, authority/fencing status, returned-replica state
projection, and long-running multi-volume failure gates. Phase 46 starts with
status/decision productization; executor-enabled rebuild/failback remains a
later decision.
- Productized returned-replica rebuild/reintegration/failback: high. Phase 46
closed the status/decision slice: returned replicas are visible, fenced, and
volume-scoped across product surfaces. Executor-enabled rebuild/failback
remains a later decision and should not be claimed until separately gated.
- Backup/snapshot/restore: high. Requires durable data semantics and user-facing
restore guarantees.
- NVMe ANA parity: medium/high. Protocol-specific work, but cheaper if it uses
@@ -617,10 +615,9 @@ Approximate engineering effort if scope remains tight:
- Phase 44 Delete Lifecycle Close Gate is closed for code/QA. The team is
intentionally skipping the v0.5 release smoke for now, so v0.5 is not marked
released until matching images and pinned-image validation are completed.
- Active work is Phase 46 Returned-Replica Rebuild / Reintegration
Productization. It should reuse the Operation Layer model to make returned
replicas visible, fenced, action-gated, and QA-verifiable before any automatic
rebuild/failback executor is enabled.
- Phase 46 Returned-Replica Rebuild / Reintegration Productization is closed.
Returned replicas are visible, fenced, action-gated, and QA-verifiable before
any automatic rebuild/failback executor is enabled.
- 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.
@@ -628,9 +625,9 @@ Approximate engineering effort if scope remains tight:
`internal/docs/ref/operation-layer-v0.5-release-train.md`; the Phase 42 gate
draft is `internal/docs/ref/phase42-lifecycle-owner-api-admission-gate.md`.
- Do not start NVMe ANA parity, backup/restore, or broad mutating recovery
workflows by extending the Operation Layer. Phase 46 is the separate gated
rebuild/reintegration productization phase; keep its first slice focused on
returned-replica facts, fencing, decisions, status, and QA evidence.
workflows by bypassing the Operation Layer. The next storage feature should
either enable a separately gated returned-replica executor or reuse the same
fact -> judgment -> action -> evidence model.
- When the current plan closes, move it to `internal/docs/finished-plans/`
with a phase/topic filename such as
`phase1_finishedplan_frontend_protocol_readiness.md`.
@@ -0,0 +1,48 @@
# Phase 46 D6 Returned-Replica Multi-Volume Close QA Sign-off
Status: PASS.
Validated source: `1311ae6` plus D6 test changes.
## Gate
`TestObservationBundle_ReturnedReplicaProjectionIsVolumeScoped`
The gate builds one bundle with two volumes:
- `pvc-a`: returned previous primary `a-r1`, current primary `a-r2`
- `pvc-b`: healthy independent primary `b-r1`
## Evidence
The report summary contains the returned-replica projection only for `pvc-a`:
```text
managed_volume_returned_replica=pvc-a replica=a-r1 state=fenced reason=returned_replica_frontend_fenced
```
The same summary does not contain:
```text
managed_volume_returned_replica=pvc-b
authority.reintegrate_returned_replica target=b-
```
The operator snapshot has two volumes. Only `pvc-a` has
`status.replica_reintegrations[]`; `pvc-b` has no returned-replica projection
and no returned-replica reintegration action.
## Boundary
Phase 46 adds status/action projection only:
- no automatic failback
- no automatic rebuild executor
- no ACK eligibility mutation
- no frontend promotion
- no new event emitter
## Verdict
D6 PASS. Returned-replica state and action decisions are volume-scoped and do
not contaminate sibling volumes.