Repository navigation
Description
Problem
devops k8s volume move pauses Argo CD by setting spec.syncPolicy.automated.enabled: false on each Application. A sync operation that already runs (for example the retry of an automated sync that failed on the immutable class of the claim, after a merge of the class change) goes on after the pause. When the move deletes the old claim (step 9), that operation can make the claim again from git, with a new empty volume, before the move binds the claim name to the new volume (steps 10-11). The create of step 11 then fails with AlreadyExists, and the same operation can scale the workload up on the empty volume.
Evidence of 2026-11-27 on the homelab (Gitea, dan-petty/homelab#472): Application gitea had a sync operation from 19:47:53 to 19:48:27 UTC (2 retries) that went on after automated.enabled: false; at 19:48:27 it made gitea/gitea-shared-storage from git, bound to a new empty Longhorn volume, and set the Deployment back to 1 replica, so a Gitea pod started its init containers on the empty volume. I scaled it to 0 within 30 s, deleted the claim, bound the name to the volume of the copy, and Gitea came back on its own data. In that case the sync started while my script had resumed Argo CD by mistake after the stranded move; the same race exists whenever an operation of a paused Application still runs.
Change
After the pause, the run waits until no Application that it paused has a running operation (status.operationState.phase Running), with a bound; it refuses to go on, and undoes the pause, when one still runs at the bound. It checks again right before the delete of the old claim.
Acceptance criteria
- A failing test first: with a running operation on a paused Application, the run waits, and does not send the delete of the old claim while the operation runs.
devops cichecks pass.
Related: #7382, #7431, dan-petty/homelab#472.
Proposed design
Problem statement
Wait for each running Argo CD sync before the old claim delete. The volume move pauses Argo CD but does not wait for running sync operations. A running sync can recreate the old claim from git after the delete and before the new volume binds. The change makes the move wait, stop at a bound, and restore the pause.
Acceptance criteria
Requirement: Wait for a running sync after pause
The volume move SHALL wait until each paused Argo CD Application has no running sync operation before it deletes the old claim.
Scenario: Running sync blocks the old claim delete
- WHEN A paused Application reports
status.operationState.phase: Runningand the run reaches the delete of the old claim. - THEN The fake Kubernetes API shows no delete request for the old claim until the fake changes the phase to
Succeeded.
Requirement: Restore pause at the wait bound
The run SHALL restore spec.syncPolicy.automated.enabled: true and exit nonzero when a paused Application still runs a sync operation at the wait bound.
Scenario: Wait bound expires with a running sync
- WHEN The wait bound expires while a paused Application reports
status.operationState.phase: Running. - THEN The command sets
spec.syncPolicy.automated.enabledtotrueon each Application it paused and exits with a nonzero status.
Requirement: Recheck before old claim delete
The run MUST check for a running sync operation immediately before it deletes the old claim.
Scenario: Late sync starts before the old claim delete
- WHEN A paused Application starts a sync operation after the first wait and before the delete of the old claim.
- THEN The run waits for that operation to end and sends no delete request while
status.operationState.phaseisRunning.
Requirement: Keep the pause until the move ends
The run SHALL keep spec.syncPolicy.automated.enabled: false on each paused Application until the move completes or fails.
Scenario: Clean wait keeps the pause
- WHEN Every paused Application has no running sync operation and the move continues.
- THEN The fake Kubernetes API shows
spec.syncPolicy.automated.enabledremainsfalseuntil the move reaches its resume step.
Requirement: Pass repository checks
The change SHALL pass the repository checks.
Scenario: CI check
- WHEN The implementation is complete.
- THEN
uv run devops ciexits 0 and reports no failed check.
Existing Tool Considered
No alternatives check has run. No open, maintained tool covers the whole need. argocd app wait waits for one Application but needs the Argo CD CLI and does not restore automated.enabled. The change builds the wait in the command at a written cost of about 8,000 tokens and 6 hours to build, keep and fix.
Key questions
- Which Argo CD Application field shows a running sync operation?: The field
status.operationState.phaseshows it. The valueRunningmeans the operation still runs. [sources: tests/k8s/test_k8s_volume_move.py] - How should the run wait for a running sync operation to end?: Poll the Application status at a short interval with the existing Kubernetes client, under a 10-minute bound. Do not add a watch or call the Argo CD CLI. (best practice) [sources: tests/k8s/test_k8s_volume_move.py, src/devops_cli/k8s/informer.py]
- Chosen: Poll with a bound. The wait is short, the command already reads Applications, and a bound stops a stuck operation.
- Rejected: Kubernetes watch. A watch adds lifecycle code and no safety for a bounded wait.
- Rejected: Call
argocd app wait. It adds the Argo CD CLI as a dependency and still does not restore the pause.
- What should the run do when the wait bound expires?: Restore
spec.syncPolicy.automated.enabled: trueon every Application it paused and exit nonzero. Do not delete the old claim. (best practice) [sources: tests/k8s/test_k8s_volume_move.py]- Chosen: Restore the pause and stop. A running sync can recreate the claim, so the move must not continue.
- Rejected: Continue with a warning. It keeps the race that the issue reports.
- Rejected: Leave the pause and stop. It leaves Argo CD paused and needs a person to repair it.
- Should the run check again immediately before the old claim delete?: Yes. Re-read the paused Applications and wait again if any has a running operation. (best practice) [sources: tests/k8s/test_k8s_volume_move.py]
- Chosen: Recheck before the delete. A sync can start after the first wait, and the delete is the risky step.
- Rejected: Rely on the first wait. It leaves the race between the wait and the delete.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 27, 2026
A running sync can recreate the claim on an empty volume and start a workload there, which is a data-loss race that already caused an incident.devops-cli-service commentedon Nov 27, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 27, 2026
Released in v0.229.3: https://github.com/dan-petty/devops-cli/releases/tag/v0.229.3
devops-cli-service commentedon Nov 27, 2026
Live since 2026-11-27 22:58 UTC
fix(k8s): end a retrying Argo CD sync in volume move (#7490)