phase43: close bounded finalizer lifecycle

This commit is contained in:
pingqiu committed 2026-06-15 23:38:10 -07:00
1 parent 816e962250
commit 1b8fb8a8bc
3 files changed
+333 -136

No files matched your search

+114 -136
View File
@@ -1,215 +1,193 @@
# Current Plan: Phase 43 - First Bounded Finalizer Mutation
# Current Plan: Phase 44 - Delete Lifecycle Close Gate
Status: open, D1/D2 live QA PASS; D3/D4 implemented locally and awaiting live
QA. Started on 2026-06-15.
Status: open, 0% complete. Started on 2026-06-15.
Branch: `phase41-lifecycle-owner-foundation`
Previous phase: Phase 42 is closed in
`internal/docs/finished-plans/phase42_finishedplan_lifecycle_owner_admission_gate.md`.
Previous phase: Phase 43 is closed in
`internal/docs/finished-plans/phase43_finishedplan_bounded_finalizer_lifecycle.md`.
## Product Goal
Ship the first real Kubernetes lifecycle mutation in Seaweed Block:
Validate the complete user-visible delete lifecycle as one product path:
```text
add/remove only block.seaweedfs.com/swblockvolume-protection on owned
SwBlockVolume objects, gated by delete-safety evidence.
install -> first PVC -> SwBlockVolume protected -> delete requested ->
blocked/unknown evidence holds finalizer -> clean evidence releases finalizer ->
object deletion completes -> uninstall leaves zero residue
```
Phase 42 proved the lifecycle-owner identity can hold main-object
`patch swblockvolumes` without becoming a broad mutator. Phase 43 turns that
proof into the product path, but keeps the scope narrow: finalizer only, no
cleanup execution, no PVC/PV/workload/storage mutation, no rebuild/failback,
no backup, no NVMe work.
Phase 43 proved add and release independently. Phase 44 proves the integrated
operation behaves as a coherent product capability across Kubernetes objects,
CRD status, Events, report/dashboard/explain surfaces, and cleanup.
Hard exit statement:
## Why This Is Next
The operation layer is only useful if separate pieces compose:
```text
The lifecycle-owner can add the protection finalizer, hold deletion while
delete-safety is blocked or unknown, and remove the finalizer only when
delete-safety is clean and fresh. Every decision is visible through CRD status,
Events, report/dashboard surfaces, and QA evidence.
live object state + status evidence + action boundary + admitted mutation +
user-facing explanation + cleanup
```
## Why This Is The Right Next Step
This is the first ability closure after the operation-layer foundation:
```text
facts -> judgment -> admitted action owner -> real bounded mutation -> status/Event evidence
```
Starting returned-replica rebuild, NVMe ANA parity, or backup/restore before this
would add more lifecycle transitions without proving the product can safely own
a small Kubernetes mutation. Phase 43 keeps the blast radius intentionally small.
Phase 44 is the close gate before moving to a broader release or larger
features. It should not add rebuild, failback, backup, or NVMe scope.
## Scope Contract
| In | Out |
|---|---|
| lifecycle-owner component or mode | operator-status main-object patch |
| SwBlockVolume protection finalizer add/remove | PVC/PV finalizer ownership |
| delete-safety hold/release decisions | cleanup execution |
| Events for hold/release | iSCSI/multipath/hostPath mutation |
| CRD status/report/dashboard agreement | workload/storageclass mutation |
| idempotency and multi-volume isolation | rebuild/failback/promotion |
| uninstall/cleanup zero-residue gate | backup/restore/NVMe ANA parity |
| one first-volume user path | returned-replica rebuild |
| SwBlockVolume finalizer add and release | failback / repair |
| delete-safety hold/release status | automatic cleanup execution |
| CRD status/Event/report/dashboard agreement | PVC/PV/workload mutation |
| zero-residue uninstall verification | backup/snapshot/restore |
| multi-volume isolation smoke if cheap | NVMe ANA parity |
Allowed implementation rule:
Allowed mutation:
```text
operator-status must remain status/events-only.
lifecycle-owner may patch SwBlockVolume main objects only through the
Phase 42-admitted finalizer shape.
lifecycle-owner may patch only SwBlockVolume.metadata.finalizers.
operator-status remains status/events-only.
```
## D1: Product Wiring And RBAC Separation
## D1: Release Artifact / Image Alignment
Goal: introduce the product lifecycle-owner path without widening
operator-status.
Goal: ensure the shipped image and chart can actually run the lifecycle-owner.
Acceptance:
```text
[ ] lifecycle-owner has a separate identity from operator-status
[ ] lifecycle-owner RBAC matches the Phase 42 boundary
[ ] operator-status still cannot patch SwBlockVolume main objects
[ ] admission policy or equivalent finalizer-only enforcement is installed
[ ] lifecycle-owner can run disabled/dry-run by default if needed for rollout
[ ] candidate image includes sw-block ops lifecycle-owner
[ ] chart renders lifecycleOwner.create=false by default
[ ] lifecycleOwner.create=true installs Deployment/RBAC/VAP
[ ] no chart flag/image skew
```
Verification:
Fail if the chart references a subcommand or flag absent from the image.
```text
kubectl auth can-i patch swblockvolumes --as <operator-status-sa> == no
kubectl auth can-i patch swblockvolumes --as <lifecycle-owner-sa> == yes
Phase 42 forbidden patch matrix still passes
```
## D2: First PVC Creates Protected SwBlockVolume
## D2: Finalizer Add On Owned SwBlockVolume
Goal: add the protection finalizer idempotently to owned `SwBlockVolume`
objects.
Goal: a normal Day-1 PVC path creates an observable, protected
`SwBlockVolume`.
Acceptance:
```text
[ ] lifecycle-owner adds block.seaweedfs.com/swblockvolume-protection
[ ] repeated reconcile does not duplicate or churn finalizers
[ ] spec, status, labels, annotations, ownerReferences are unchanged
[ ] foreign finalizers are not added or removed
[ ] Event and status/action evidence names the volume identity
[ ] Helm install succeeds with operatorStatus + lifecycleOwner enabled
[ ] first PVC writer/reader passes
[ ] SwBlockVolume exists for the PVC
[ ] lifecycle-owner adds exactly one protection finalizer
[ ] operator-status writes Ready=True / first_volume_verified
[ ] finalizer_added Event is bounded
```
## D3: Delete Request Holds On Unsafe Evidence
Goal: a delete request cannot complete while evidence is unsafe.
Acceptance:
```text
[ ] deleting SwBlockVolume with missing cleanup evidence remains Terminating
[ ] blocked residue evidence remains Terminating
[ ] stale cleanup evidence remains Terminating
[ ] status.deleteSafety decision is unknown/rejected as appropriate
[ ] Events explain the hold reason
[ ] lifecycle-owner does not run cleanup
```
Fail if unsafe evidence releases the finalizer.
## D4: Clean Evidence Releases And Deletion Completes
Goal: clean, fresh evidence releases only the Seaweed Block finalizer.
Acceptance:
```text
[ ] clean cleanup evidence sets decision=allowed state=releasable
[ ] lifecycle-owner removes only block.seaweedfs.com/swblockvolume-protection
[ ] foreign finalizers are preserved if present
[ ] SwBlockVolume deletion completes after release
[ ] finalizer_released Event is bounded
```
Fail if any non-finalizer field changes.
## D3: Blocked / Unknown Delete Holds Finalizer
## D5: Surface Agreement
Goal: deletion is held when release evidence is unsafe.
Goal: users see the same answer everywhere.
Acceptance:
```text
[ ] blocked residue -> deleteSafety.state=blocked decision=rejected
[ ] missing cleanup evidence -> state=requested decision=unknown
[ ] stale cleanup evidence -> state=requested decision=unknown
[ ] finalizer remains present in all three cases
[ ] no cleanup is executed to make the decision pass
[ ] Events explain hold reason without claiming release
[ ] kubectl get/describe SwBlockVolume status agrees with ops report
[ ] operator-snapshot agrees with CRD status
[ ] dashboard /operator-snapshot.json agrees
[ ] ops explain names the same hold/release reason
[ ] no false Ready=True appears in blocked/unknown delete states
```
Fail if blocked, missing, or stale evidence removes the finalizer.
## D6: Multi-Volume Isolation Smoke
## D4: Clean Delete Releases Finalizer
Goal: release finalizer only when cleanup evidence is clean and fresh.
Acceptance:
```text
[ ] clean cleanup evidence -> state=releasable decision=allowed
[ ] lifecycle-owner removes only the Seaweed Block protection finalizer
[ ] finalizer removal is idempotent
[ ] finalizer_released Event is emitted once or bounded/stable
[ ] object deletion can complete after release
```
Fail if clean evidence causes any PVC/PV/workload/host mutation.
## D5: Multi-Volume Isolation
Goal: one volume's delete lifecycle does not contaminate another.
Goal: one deleting volume does not contaminate another volume.
Scenario:
```text
A: delete requested + residue -> held
B: delete requested + clean evidence -> released
C: ready volume with no delete request -> finalizer remains, no deleteSafety
D: stale evidence -> unknown, held
A deleting + blocked residue -> held
B deleting + clean evidence -> released
C normal ready volume -> remains ready, protected, no deleteSafety contamination
```
Acceptance:
```text
[ ] A remains held and does not block B release
[ ] B release does not affect A/C/D
[ ] C has no deleteSafety contamination
[ ] D remains unknown/held
[ ] Events and status use the correct volume identity
[ ] A held does not block B release
[ ] B release does not remove A/C finalizer
[ ] C remains Ready=True and protected
[ ] Events/status use the correct volume identity
```
## D6: Close Gate
## D7: Close / Release Decision
Phase 43 can close only if:
Phase 44 can close only if:
```text
[ ] Phase 42 D1-D4 admission gate still passes
[ ] finalizer add works on owned SwBlockVolume
[ ] blocked/missing/stale delete-safety holds finalizer
[ ] clean/fresh delete-safety releases finalizer
[ ] operator-status remains status/events-only
[ ] D1-D6 PASS on a clean VAP-capable lab
[ ] lifecycle-owner has no cleanup/PVC/PV/workload/storage mutation power
[ ] uninstall/cleanup verifier reports zero residue
[ ] QA sign-off records Phase 44 is eligible for delete lifecycle release close
[ ] operator-status remains status/events-only
[ ] final cleanup verifier reports zero residue
[ ] release notes and README claim only bounded SwBlockVolume finalizer
lifecycle, not automatic cleanup or broad lifecycle automation
```
## Current Progress
- D1/D2 live QA PASS:
- `sw-block ops lifecycle-owner` command added.
- separate Helm lifecycle-owner Deployment/RBAC added, disabled by default.
- lifecycle-owner admission policy added for finalizer-only patch shape.
- Kubernetes client can list `SwBlockVolume` objects and patch only
`metadata.finalizers`.
- live VAP/RBAC boundary and idempotent finalizer add validated in
`internal/docs/qa-assignments/phase43-d1-d2-lifecycle-owner-finalizer-add-qa-signoff.md`.
- D3/D4 local implementation complete:
- lifecycle-owner holds deleting volumes when `status.deleteSafety` is absent,
blocked, or unknown/stale.
- lifecycle-owner removes only the Seaweed Block protection finalizer when
`status.deleteSafety` is releasable and allowed.
- local tests pass; live QA pending.
- 0%: Phase 44 opened from Phase 43.
- Phase 43 already proved add and release as separate live gates.
- Phase 44 must prove the integrated path and release wording.
## Prerequisites / Risks
- Keep the Phase 42 admission policy in the loop; RBAC alone is not enough for
CRD finalizers.
- Do not put main-object patch permission on operator-status.
- Deleting a CR with finalizers can easily leave stuck test objects. Every gate
must include cleanup and force-clean instructions.
- Do not add automatic cleanup to make finalizer release pass.
- Keep Events bounded; repeated reconcile should not create unbounded duplicate
lifecycle Events.
- Use a candidate image that includes `sw-block ops lifecycle-owner`.
- Use a VAP-capable lab; Rancher Desktop without VAP is not sufficient.
- Be careful with deleting CRs that have finalizers; every failed gate must
include admin cleanup instructions.
- Do not paper over unsafe evidence by running cleanup inside lifecycle-owner.
## Next Step
Run D3/D4 live QA:
Build or publish a candidate image from the current branch, then author/run the
D1-D4 integrated live scenario:
```text
blocked/missing/stale delete-safety holds finalizer
clean/fresh delete-safety releases only Seaweed Block finalizer
operator-status remains status/events-only
lifecycle-owner keeps no cleanup/PVC/PV/workload/storage mutation power
install with operatorStatus + lifecycleOwner
create first PVC
observe protection finalizer
request delete
prove hold under unsafe evidence
patch/provide clean delete-safety evidence
prove finalizer release and object deletion
```
@@ -0,0 +1,95 @@
# Phase 43 Finished Plan: Bounded SwBlockVolume Finalizer Lifecycle
Status: closed on 2026-06-15.
Branch: `phase41-lifecycle-owner-foundation`
## Outcome
Phase 43 ships the first real bounded Kubernetes lifecycle mutation in Seaweed
Block:
```text
add/remove only block.seaweedfs.com/swblockvolume-protection on owned
SwBlockVolume objects, admitted by Kubernetes VAP and gated by delete-safety.
```
This closes the control-plane loop that Phase 42 prepared:
```text
status evidence -> delete-safety decision -> admitted lifecycle owner ->
finalizer mutation -> Kubernetes Event / observable object state
```
## Delivered
- Product lifecycle-owner command:
- `sw-block ops lifecycle-owner`,
- separate identity from operator-status,
- dry-run capable,
- periodic reconcile capable.
- Helm lifecycle-owner packaging:
- disabled by default,
- separate Deployment, ServiceAccount, RBAC,
- ValidatingAdmissionPolicy and binding for finalizer-only patch shape.
- Finalizer add:
- adds exactly `block.seaweedfs.com/swblockvolume-protection`,
- preserves existing foreign finalizers,
- idempotent on repeated reconcile,
- emits bounded `finalizer_added` Events.
- Delete-safety-gated finalizer release:
- missing delete-safety -> hold,
- blocked residue -> hold,
- stale/unknown evidence -> hold,
- clean/releasable evidence -> remove only the Seaweed Block protection
finalizer,
- preserves foreign finalizers,
- emits `finalizer_released` or hold-reason Events.
- Operator-status boundary preserved:
- remains status/events-only,
- no main-object patch power,
- no finalizer mutation Events from operator-status.
## QA Evidence
- D1/D2 finalizer add:
`internal/docs/qa-assignments/phase43-d1-d2-lifecycle-owner-finalizer-add-qa-signoff.md`
- QA PASS on m02 (`k3s v1.34.4+k3s1`) with real
ValidatingAdmissionPolicy enforcement,
- lifecycle-owner finalizer add works and is idempotent,
- VAP denies spec/status/labels/annotations/ownerReferences/foreign/mixed
mutations,
- operator-status cannot patch main `SwBlockVolume`,
- lifecycle-owner has no workload/storage mutation power.
- D3/D4 finalizer release:
`internal/docs/qa-assignments/phase43-d3-d4-lifecycle-owner-finalizer-release-qa-signoff.md`
- QA PASS on m02 with fresh build from `252ec35`,
- missing/blocked/stale delete-safety holds finalizer,
- clean/releasable delete-safety releases only the protection finalizer,
- foreign finalizer remains,
- spec/status/labels/annotations unchanged,
- no cleanup executed,
- cleanup verifier reports zero residue.
## Non-Claims
Phase 43 does not execute cleanup, delete PVC/PV/workload/storage resources,
repair iSCSI/multipath/hostPath residue, rebuild replicas, fail back primaries,
perform backup/restore, implement NVMe ANA parity, or claim production SLOs.
The lifecycle-owner owns only the Seaweed Block `SwBlockVolume` protection
finalizer. It does not own PVC/PV finalizers.
## Required Carry-Forward
Phase 44 should validate the whole user-visible delete lifecycle as an
integrated path:
```text
install -> first PVC -> SwBlockVolume protected -> delete requested ->
blocked residue holds finalizer -> clean evidence releases finalizer ->
object deletion completes -> uninstall cleanup leaves zero residue
```
The close gate should prove CRD status, Events, report/dashboard/explain, and
actual Kubernetes object state agree across the hold and release transitions.
@@ -0,0 +1,124 @@
# QA Sign-off — Phase 43 D3/D4 Delete-Safety Gated Finalizer Release
Verdict: **PASS.** The lifecycle-owner release half works and is correctly gated:
it **holds** the Seaweed Block protection finalizer while delete-safety is
missing, blocked, or stale, and **releases only** that finalizer when
`status.deleteSafety` says release is allowed — preserving foreign finalizers,
mutating no non-finalizer field, and executing no cleanup. Validated live on a
real VAP-capable cluster. With D1/D2 (add) already PASS, the bounded delete
lifecycle (add + release) is complete.
Date: 2026-06-15
Source: branch `phase41-lifecycle-owner-foundation` @ `252ec35 phase43: gate
finalizer release on delete safety`
Image: fresh local build from `252ec35` (`sw-block:local`), imported to m01+m02.
Environment: m02 k3s **v1.34.4+k3s1** (ValidatingAdmissionPolicy enforced).
Install: `helm install ... --set operatorStatus.create=true
--set operatorStatus.dryRun=false --set lifecycleOwner.create=true
--set lifecycleOwner.dryRun=false --set lifecycleOwner.interval=15s` (pods 1/1).
## G1 — Local Contract — PASS
`go test ./core/ops ./cmd/sw-block` → `ok` (both); `helm lint
charts/seaweed-block` → 1 chart linted, 0 failed.
## G2 — Hold On Missing / Blocked / Stale Evidence — PASS
Three deleting `SwBlockVolume` objects (each with the protection finalizer and a
deletionTimestamp), reconciled once:
```text
hold-missing (no status.deleteSafety) -> finalizers stay [protection]
hold-blocked (state=blocked, decision=rejected) -> finalizers stay [protection]
hold-stale (state=requested, decision=unknown,
reason=cleanup_evidence_stale) -> finalizers stay [protection]
controller log (steady state): volumes=4 finalizer_held=3 finalizer_released=0
Warning Events (each names the hold reason, none claim release):
cleanup_evidence_missing swblockvolume/hold-missing
iscsi_node_records_present swblockvolume/hold-blocked
cleanup_evidence_stale swblockvolume/hold-stale
message: "Seaweed Block protection finalizer held until delete-safety evidence allows release"
```
All three keep the protection finalizer; no patch removes it; the hold is reported
with a stable reason via a Warning Event; no cleanup command is executed (the
lifecycle-owner only patches `metadata.finalizers`).
## G3 — Release On Clean Fresh Evidence — PASS
One deleting `SwBlockVolume` with `finalizers=[example.com/foreign,
block.seaweedfs.com/swblockvolume-protection]` and
`status.deleteSafety={state=releasable, decision=allowed,
finalizerReleaseAllowed=true}`, reconciled once:
```text
finalizers: [example.com/foreign, protection] -> [example.com/foreign]
spec.pvcName=release-clean labels.keep=true annotations.keep=true deleteSafety.state=releasable (all unchanged)
controller log: finalizer_released=1 (first iteration)
Event: Normal finalizer_released swblockvolume/release-clean
"Seaweed Block protection finalizer released after clean delete-safety evidence"
after removing the foreign finalizer (admin): object reaches NotFound (deletion finishes)
```
Only the protection finalizer is removed; the foreign finalizer is preserved; no
non-finalizer field changes; the object can finish deletion once the Seaweed Block
finalizer is gone; a single bounded Normal `finalizer_released` Event is emitted.
## G4 — Admission / RBAC Boundary — PASS
`252ec35` does not touch `lifecycle-owner-rbac.yaml`,
`lifecycle-owner-admission.yaml`, or `operator-status-rbac.yaml` (git diff empty
vs D1/D2 `1244285`), so the D1/D2 full matrix (operator-status no main patch;
lifecycle-owner finalizer-only main patch; 36/36 forbidden resource×verb denied;
spec/labels/annotations/ownerReferences/foreign/mixed denied) still applies. Live
spot-check confirmed:
```text
operator-status patch swblockvolumes(main) => no
lifecycle-owner patch swblockvolumes(main) => yes (VAP-confined to finalizers)
lifecycle-owner spec patch => denied (VAP)
lifecycle-owner patch pods => no
lifecycle-owner delete persistentvolumeclaims => no
```
## G5 — Cleanup — PASS
```text
helm uninstall: release uninstalled
verify-helm-cleanup.sh: cleanup_status=ok cleanup_observed_at=2026-06-16T05:17:05Z
swblockvolumes=0 lifecycle-owner VAP/binding=0/0 RBAC=0/0 pods=0 helm=0
```
No stuck `SwBlockVolume`, VAP, binding, RBAC, pods, PVCs, PVs, iSCSI, multipath,
or dmsetup residue.
## Blocking Findings
None. No blocking condition: missing/blocked/stale evidence never released the
finalizer; clean releasable evidence removed only the protection finalizer (foreign
preserved); no non-finalizer field changed; no cleanup was executed; the
lifecycle-owner gained no workload/storage mutation power.
## Non-Blocking Findings
1. Release requires the exact triple `finalizerReleaseAllowed=true` **and**
`decision=allowed` **and** `state=releasable` (`lifecycleOwnerReleaseAllowed`).
A partial/clean-but-not-fully-releasable decision correctly holds. Worth a doc
note so operators understand which delete-safety shape releases.
2. The `status.deleteSafety` here was set directly for the gate; in production it
is projected by operator-status from real cleanup evidence. The end-to-end
path (real residue → operator-status projects blocked/releasable →
lifecycle-owner holds/releases) is the natural Phase 44 close-gate scenario.
3. tp01 `NotReady` — unrelated to this single-node gate.
## Recommendation
**Phase 43 D3/D4 pass.** The delete-safety-gated finalizer release is
real-API-proven: hold on missing/blocked/stale, release-only-protection on
clean/releasable, foreign-preserving, non-mutating, cleanup-free, with
operator-status untouched and zero residue. Combined with D1/D2, Phase 43 delivers
the full bounded `SwBlockVolume` protection-finalizer lifecycle (add + release).
The remaining work toward a delete-lifecycle release is the end-to-end close gate
(Phase 44): real cleanup evidence → operator-status projection → lifecycle-owner
hold/release as one user-visible path.