Repository navigation
Description
Problem Description
Moving a claim in an Argo CD-managed restricted namespace with a long-draining workload (deployment/roadmap-service, terminationGracePeriodSeconds: 660) and 0600 files owned by UID 1000 hits two defects in devops k8s volume move:
stop_workloads()wait times out beforeterminationGracePeriodSecondsfinishes:stop_workloads()waitsDEFAULT_K8S_VOLUME_MOVE_WAIT_SECONDS(300seconds) inkubectl wait pod/<pod> --for=delete, ignoring the pod's configuredterminationGracePeriodSeconds(660seconds forroadmap-servicewhile draining rounds in flight).- Argo CD
selfHealreverts an owner-approvedbaselinePSA window before Step 1 pauses Argo CD: Labelingpod-security.kubernetes.io/enforce=baselinebefore callingdevops k8s volume moveis reverted back torestrictedby Argo CD (bootstrap/clusterselfHeal: true) whilevolume movestarts up and calls_enforces_restricted()inplan_volume_move()prior to Step 1 (pause()). Underrestricted,pv-migrate --non-rootruns rsync as UID10000and exits23(partial transfer due to error) on0600(1000:1000) files created by the workload.
Reproduction Steps
- Run
kubectl label ns devops pod-security.kubernetes.io/enforce=baseline --overwrite - Run
uv run devops k8s volume move devops/roadmap-service-home --storage-class longhorn --access-mode ReadWriteMany --size 10Gi
Expected vs Actual Behavior
- Expected:
volume movewaits long enough for workloads withterminationGracePeriodSeconds > 270to terminate gracefully (Step 3), and an opt-in operator--allow-baselinewindow appliespod-security.kubernetes.io/enforce=baselineonly after Step 1 pauses Argo CD and restoresrestrictedbefore Step 11 resumes Argo CD (and on undo). - Actual: Argo CD reverts
enforce=baselineback torestrictedbefore Step 1,_enforces_restricted()picks--non-root(rsyncexits23on0600files), and Step 3 times out after300s(5m 4s) onpod/roadmap-service-*(terminationGracePeriodSeconds: 660).
Environment Diagnostics
- DevOps CLI Version:
v0.257.0 - Python Version:
3.14.10 - OS & Architecture: Linux x86_64
- Execution Environment: DevContainer
Related
-
fix(k8s): volume move copy pods fail Pod Security restricted #7449, feat(k8s): preserve file owners in a restricted volume move #7574, dan-petty/homelab#579
-
I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
-
I have checked existing issues and pull requests to ensure this is not a duplicate.
Proposed design
Problem statement
devops k8s volume move fails on a long-draining workload in an Argo CD-managed restricted namespace. stop_workloads() waits 300 seconds and times out before a pod with terminationGracePeriodSeconds: 660 ends. Argo CD selfHeal also reverts a hand-set pod-security.kubernetes.io/enforce=baseline label before Step 1 pauses Argo CD. pv-migrate --non-root then runs as UID 10000 and exits 23 on 0600 files owned by UID 1000. The command must derive the wait from the pod grace period. It must also offer an opt-in baseline window that applies after the pause and restores the label before the resume and on undo.
Acceptance criteria
Requirement: grace-aware stop timeout
The stop step MUST wait for pod deletion with a timeout of at least the largest spec.terminationGracePeriodSeconds among the deleted pods plus a fixed margin.
Scenario: a pod with a 660 second grace period
- WHEN
stop_workloads()deletes a pod whosespec.terminationGracePeriodSecondsis660 - THEN the recorded
kubectl wait pod/<pod> --for=deleterequest has--timeoutof at least720s
Requirement: default wait floor
The stop step SHALL use DEFAULT_K8S_VOLUME_MOVE_WAIT_SECONDS as the floor of the wait timeout.
Scenario: a pod with no grace period
- WHEN a deleted pod sets no
spec.terminationGracePeriodSeconds - THEN the recorded
kubectl waitrequest has--timeout=300s
Requirement: opt-in baseline flag
devops k8s volume move SHALL accept an opt-in --allow-baseline flag and MUST change no pod security label without it.
Scenario: a run without the flag
- WHEN the operator runs
volume movewith no--allow-baseline - THEN the command sends no
kubectl labelrequest forpod-security.kubernetes.io/enforce
Requirement: baseline applied after the Argo CD pause
With --allow-baseline, the command SHALL apply pod-security.kubernetes.io/enforce=baseline only after Step 1 pauses Argo CD.
Scenario: a run with the flag
- WHEN the operator runs
volume move --allow-baseline - THEN the recorded request order shows the Argo CD pause before the
kubectl labelrequest that setsenforce=baseline
Requirement: plan skips non-root with the flag
plan_volume_move() SHALL not add --non-root to the pv-migrate arguments when the operator sets --allow-baseline.
Scenario: a restricted namespace with the flag
- WHEN the namespace enforces
restrictedand the operator sets--allow-baseline - THEN the recorded
pv-migratearguments contain no--non-root
Requirement: baseline window restore
The command SHALL restore the recorded pod-security.kubernetes.io/enforce value before Step 11 resumes Argo CD and on undo.
Scenario: the end of a flagged run
- WHEN a run with
--allow-baselinereaches Step 11 or runs undo - THEN the recorded request order shows the
kubectl labelrestore before the Argo CD resume
Requirement: help names the flag
The volume move help text SHALL name --allow-baseline and its effect.
Scenario: the rendered help
- WHEN the test renders the
volume movehelp - THEN the help text contains
--allow-baselineandbaseline
Existing Tool Considered
No alternatives check has run. pv-migrate (open and maintained) covers the data copy, and the command already uses it. It lacks the Argo CD pause, the grace-aware wait and the PSA window, so the change edits src/devops_cli/k8s/volume_move.py instead. The written cost is about 30,000 tokens and 4 hours to build, keep and fix that code.
Key questions
- Which timeout does
stop_workloads()givekubectl waitnow?: It givesDEFAULT_K8S_VOLUME_MOVE_WAIT_SECONDS, which is300seconds, so a pod with a 660 second grace period outlives the wait. [sources: src/devops_cli/config/defaults.py:1369, src/devops_cli/k8s/volume_move.py] - How must the wait timeout follow the pod grace period?: Use the largest
spec.terminationGracePeriodSecondsof the deleted pods plus a 60 second margin, withDEFAULT_K8S_VOLUME_MOVE_WAIT_SECONDSas the floor. (best practice) [sources: src/devops_cli/k8s/volume_move.py]- Chosen: grace plus margin, floored by the default. The wait follows each pod and keeps the 300 second floor for a pod with no long grace period.
- Rejected: raise the default constant. A fixed larger wait slows every move and still fails a pod with a longer grace period.
- Rejected: add a
--wait-secondsoption. The operator must not compute a value that the pod spec already holds.
- Why does
pv-migrate --non-rootexit23on the0600files?:_enforces_restricted()selects--non-root, so rsync runs as UID10000and cannot read files that UID1000owns with mode0600; rsync exits23with a partial transfer. [sources: src/devops_cli/k8s/volume_move.py:1583] - When must the baseline label apply and be restored?: Only with the opt-in
--allow-baselineflag: applyenforce=baselineafter Step 1 pauses Argo CD, and restore the recorded value before Step 11 resumes Argo CD and on undo. (best practice) [sources: src/devops_cli/k8s/volume_move.py]- Chosen: opt-in flag with a window around the paused steps. Argo CD is paused, so
selfHealcannot revert the label, and the namespace returns to its recorded level. - Rejected: always set
baseline. It weakens the namespace for every move, with no operator consent. - Rejected: require the operator to pause Argo CD by hand. The command already pauses Argo CD at Step 1, so a second manual step adds a failure.
- Chosen: opt-in flag with a window around the paused steps. Argo CD is paused, so
- How must
plan_volume_move()treat--allow-baseline?: It must treat the namespace as non-restricted when the operator sets--allow-baseline, because the window appliesbaselinebefore the migration runs. (best practice) [sources: src/devops_cli/k8s/volume_move.py]- Chosen: pass the flag into the plan and skip
--non-root. The plan matches the PSA level that the migration will run under. - Rejected: keep
--non-rootand let rsync fail. It repeats the23exit that the issue reports. - Rejected: re-plan after the pause. It runs the plan twice and adds a second code path.
- Chosen: pass the flag into the plan and skip
- Which value does the restore write?: Write the
pod-security.kubernetes.io/enforcevalue read before the window, which isrestrictedhere, and remove the label when it was absent. (best practice) [sources: src/devops_cli/k8s/volume_move.py]- Chosen: recorded prior value. A namespace that enforces another level returns to that level, not to a hard-coded one.
- Rejected: hard-code
restricted. It changes a namespace that enforces a different level.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
devops-cli-service commentedon Nov 29, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 29, 2026
Released in v0.258.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.258.0
devops-cli-service commentedon Nov 30, 2026
Live since 2026-11-30 00:51 UTC