Repository navigation
Description
Problem
The undo of <claim>-move (#7416) reads the volume of the claim when it runs, sets it to Delete, and deletes the claim. A class with Immediate binding, such as longhorn, provisions the volume a moment after the create of the claim. When the move fails within that moment, the undo finds no spec.volumeName, deletes the claim, and the provisioner still makes the volume afterwards. That volume is Released with the class's reclaim policy Retain, so it stays.
Evidence of 2026-11-27 on the homelab: a move of devops/valkey-data-roadmap to longhorn failed at the create of <claim>-dst (Pod Security restricted, #7451), about 1 s after the create of valkey-data-roadmap-move. The undo printed its three steps, and afterwards a Released Longhorn volume with claimRef.name: valkey-data-roadmap-move stayed with Retain. A second attempt of the same move at another time left a second one. I deleted both by hand.
Change
The undo of <claim>-move also finds the volumes that the move claim gets after its delete: it keeps the uid of the claim, and after the delete it sets each PersistentVolume whose spec.claimRef.uid is that uid to Delete, waiting a short bound for a late provisioning. Or make_destination waits until <claim>-move is bound before it creates the pod, and the undo of a claim that never bound waits the same bound.
Acceptance criteria
- A failing test first: an undo when the claim has no volume yet, and a volume with the claim's uid appears after the delete, sets that volume to
Delete. - A live move to
longhornthat fails at once leaves noReleasedvolume of the move. devops cichecks pass.
Alternatives check of 2026-11-27: in-use.
The repository already uses this tool.
Tool: kyverno/kyverno (https://github.com/kyverno/kyverno), Apache-2.0, last activity 2026-11-27, maintained.
Reason: Searches found only cluster-wide janitors: Kyverno's cleanup and mutate policies can find and patch PersistentVolumes by condition, which covers stray Released volumes, but no tool performs the uid-scoped cleanup inside the move undo.
Covers:
- ClusterCleanupPolicy deletes resources that match a condition on a schedule
- Mutate policies patch fields of resources, including reclaim policy
- Runs in the cluster, with no change to the CLI code
Lacks:
- No capture of the claim uid before the delete
- No short wait for a volume provisioned after the delete
- Cluster-wide and scheduled, not scoped to one move's undo
Proposed design
Problem statement
The undo of <claim>-move reads the volume of the move claim before it deletes the claim. A class with Immediate binding can provision a volume after that delete. The volume then stays Released with reclaim policy Retain.
Acceptance criteria
Requirement: Late volume cleanup
The undo of <claim>-move SHALL set the reclaim policy of each PersistentVolume whose spec.claimRef.uid is the move claim UID to Delete after it deletes the claim.
Scenario: Volume appears after the delete
- WHEN A test in
tests/k8s/test_k8s_volume_move.pyruns the undo with a fake client, the move claim has nospec.volumeName, and a PersistentVolume with the move claim UID appears after the delete. - THEN The test asserts that the undo patches
spec.persistentVolumeReclaimPolicyof that PersistentVolume toDelete.
Requirement: Bounded wait for late volume
The undo SHALL wait for a late PersistentVolume within a bounded time after it deletes the move claim.
Scenario: Late volume within the wait
- WHEN A test in
tests/k8s/test_k8s_volume_move.pyruns the undo with a fake client that returns no PersistentVolume for the move claim UID on the first read and one on a later read within the wait. - THEN The test asserts that the undo patches that PersistentVolume to
Deletebefore it returns.
Requirement: Bound volume cleanup
The undo SHALL set the reclaim policy of the volume in spec.volumeName to Delete before it deletes the move claim.
Scenario: Move claim has a bound volume
- WHEN A test in
tests/k8s/test_k8s_volume_move.pyruns the undo with a move claim whosespec.volumeNamenames a PersistentVolume. - THEN The test asserts that the undo patches that PersistentVolume to
Deleteand deletes the move claim.
Requirement: CI checks pass
The change SHALL pass the repository CI checks.
Scenario: Repository CI
- WHEN A person runs
uv run devops cion the branch. - THEN The command exits 0.
Requirement: Pending a person after the merge
A live move to longhorn that fails at once MUST leave no Released volume of the move.
Scenario: Live move failure
- WHEN After the merge, a person runs a move of a claim to
longhornand the move fails at once. - THEN The command
kubectl get pv -o jsonshows no PersistentVolume with phaseReleasedandspec.claimRef.nameequal to<claim>-move.
Existing Tool Considered
The alternatives check in the issue body records the verdict in-use for kyverno/kyverno (https://github.com/kyverno/kyverno). The repository already uses this tool. The block gives what the tool covers and lacks. This change adds the uid capture, the short wait and the move scope to the existing undo.
Key questions
- Which cleanup approach should the undo of
<claim>-moveuse?: Capture the move claim UID before the delete. After the delete, wait a bounded time and set each PersistentVolume whosespec.claimRef.uidis that UID toDelete. (best practice) [sources: k8s/README.md:122, src/devops_cli/k8s/volume_move.py:1119, docs/commands/k8s.md:1058, tests/k8s/test_k8s_volume_move.py]- Chosen: UID-scoped cleanup after the delete. It covers a volume that the class provisions after the delete. It does not depend on the copy tool.
- Rejected: Wait for
<claim>-moveto bind before pod creation. It narrows the window. It still needs a wait in the undo for a claim that never bound. - Rejected: Kyverno cluster cleanup policy. It is cluster-wide and scheduled. It does not capture the claim UID or wait inside the undo.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
devops-cli-service commentedon Nov 27, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (10)
Tools considered:
Searches run:
Sources:
dan-petty commentedon Nov 28, 2026
Replacement check for #7498 (PR #7518, which replaces the volume move copy with pv-migrate): not fixed.
The undo of
<claim>-moveis the same code (_discard_move_claim): it readsspec.volumeNamewhen it runs, sets that volume toDeleteand deletes the claim. The move still creates<claim>-movebefore the scale to zero and the copy, so a failure a moment after the create, before a class withImmediatebinding has provisioned the volume, can still leave aReleasedvolume withRetain. The window is smaller: the first step after the create is now the scale to zero, and pv-migrate starts only after the pods are gone, so the failure of #7451 at the create of<claim>-dstcannot happen. The fix of this issue (the uid of the claim andspec.claimRef.uidof a late volume) does not depend on the copy tool, so the issue stays open.devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 28, 2026
Released in v0.240.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.240.1
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 23:51 UTC