Repository navigation
Description
Problem
devops k8s volume move makes its copy pods run as root, so GNU tar keeps the owners of the files. A namespace with the Pod Security label pod-security.kubernetes.io/enforce: restricted refuses such a pod. The plan does not read that label, so the move pauses Argo CD, makes <claim>-move, and only then fails at the create of <claim>-dst, and undoes its steps.
Evidence of 2026-11-27 on the homelab: devops k8s volume move devops/valkey-data-roadmap --storage-class longhorn stopped at step 2 with pods "valkey-data-roadmap-dst" is forbidden: violates PodSecurity "restricted:latest". The namespace devops enforces restricted. The owner allowed a window of baseline for that one move: Argo CD paused (bootstrap, cluster, base, devops), enforce=baseline from 17:49:01 to 17:49:31 UTC, the move, then restricted again. The data (1.4 MB, files of uid 999, gid 1000) moved with equal digests. k8s/README.md says the namespace must allow root pods, but the command does not check it.
Change
- The plan reads the label
pod-security.kubernetes.io/enforceof the namespace and refuses a move in arestrictednamespace with a problem that names the label and the way out; and - An option to run the copy pods under
restricted: as a user and group that the person names (the owner of the data), withrunAsNonRoot, no capabilities,seccompProfile: RuntimeDefaultand anfsGroup, so tar writes the files with that owner. The plan refuses this option when the source holds files of more than one owner, if it can see that.
Acceptance criteria
- A failing test first: the plan of a claim in a
restrictednamespace refuses with that problem and changes nothing. devops cichecks pass.
Related: #7382, #7416, dan-petty/homelab#471.
Alternatives check of 2026-11-27: partly.
Tool: utkuozdemir/pv-migrate (https://github.com/utkuozdemir/pv-migrate), Apache-2.0, last activity 2026-11-26, maintained.
Reason: Web searches returned no tool that reads a namespace's pod-security enforce label; pv-migrate, the closest, copies PVC data with configurable copy pods, but it has no pre-flight refusal, no plan and no Argo CD pause.
Covers:
- Moves PVC data between storage classes
- Runs copy pods from a configurable Helm chart
- Supports rsync and sshd transfer strategies
Lacks:
- No read of the namespace pod-security enforce label
- No plan that refuses before any cluster change
- No Argo CD pause, move and undo sequence
- No refusal when source files have several owners
Proposed design
Problem statement
The issue's original plan would build root copy pods. The move now uses pv-migrate. The plan must read the Pod Security enforce label before any change, run pv-migrate as non-root when an fsGroup works, and refuse the other cases. The owner-preserving copy is a separate issue because pv-migrate --non-root does not keep file owners.
Acceptance criteria
Requirement: Restricted refusal makes no change
The plan MUST refuse a move in a namespace that enforces restricted when the copy cannot run, and MUST make no cluster change before the refusal.
Scenario: Restricted namespace without fsGroup
- WHEN the plan of a claim in a namespace with
pod-security.kubernetes.io/enforce: restrictedruns and the workload pod template has nofsGroup - THEN the new test
test_restricted_refusal_changes_nothingasserts the refusal message and that the plan calls no Argo CD pause, no claim create and no workload scale
Requirement: Refuse local-path in a restricted namespace
The plan MUST refuse a move in a restricted namespace when the target storage class does not supply an fsGroup, such as local-path.
Scenario: Local-path target
- WHEN the plan runs for a
restrictednamespace and the target class islocal-path - THEN the test
_restricted_on_local_pathasserts the refusal message names the label and the way out
Requirement: Refuse a driver without fsGroup
The plan MUST refuse a move in a restricted namespace when the CSI driver of the target class has fsGroupPolicy: None.
Scenario: Driver without fsGroup
- WHEN the plan runs for a
restrictednamespace and the CSI driver of the target class hasfsGroupPolicy: None - THEN the test
_restricted_on_a_driver_without_fs_groupasserts the refusal message names the label and the way out
Requirement: Run pv-migrate as non-root when fsGroup works
The plan SHALL run pv-migrate with --non-root and --rsync-extra-args=--no-perms when a restricted namespace has a workload fsGroup and a target class fsGroup.
Scenario: Restricted namespace with fsGroup
- WHEN the plan runs for a
restrictednamespace with a workloadfsGroupand a target class whose driver supplies anfsGroup - THEN the plan invokes pv-migrate with
--non-rootand--rsync-extra-args=--no-perms, and the test asserts those arguments
Requirement: Scoped checks pass
The change MUST pass the repository checks.
Scenario: Scoped k8s checks
- WHEN the implement job runs
uv run devops ci --check --only k8s - THEN the command exits 0
Existing Tool Considered
The alternatives check in the issue body records verdict partly for utkuozdemir/pv-migrate (Apache-2.0, maintained). The proposal uses pv-migrate for the copy. It adds the pre-flight read of the label, the refusal before any cluster change, and the --non-root and --no-perms options that pv-migrate lacks. The check in the issue body lists what the tool covers and lacks.
Key questions
- What does the current volume move do in a namespace that enforces
restricted?: The plan readspod-security.kubernetes.io/enforcebefore any change. It runs pv-migrate with--non-rootand--rsync-extra-args=--no-permswhen the workload has anfsGroupand the target class supplies one. It refuses when the workload has nofsGroup, the target class islocal-path, or the CSI driver hasfsGroupPolicy: None. [sources: k8s/README.md, tests/k8s/test_k8s_volume_move.py] - Does pv-migrate
--non-rootkeep the owner and group of each file?: No. pv-migrate--non-rootruns as user 10000 and adds--no-o --no-gto rsync. It keeps no owner and no group. The workload reads the files through itsfsGroup. [sources: k8s/README.md] - Should the plan refuse every move in a
restrictednamespace or run pv-migrate as non-root when it can?: Run pv-migrate as non-root when the workload and the storage class supply anfsGroup. Refuse only when the copy cannot run underrestricted. This avoids a needless stop and uses the open tool. (best practice) [sources: k8s/README.md, AGENTS.md]- Rejected: Refuse every restricted move. It stops moves that pv-migrate can run as non-root.
- Chosen: Run pv-migrate --non-root when fsGroup works and refuse otherwise. It uses the maintained tool and prevents the late failure.
- Rejected: Build custom copy pods as a named user and group. It builds code that pv-migrate already covers and needs a separate owner decision.
- Should the issue implement the option to run copy pods as a named user and group under
restricted?: No. Defer it. pv-migrate--non-rootdoes not keep file owners, and a custom copy pod would replace the tool. File an issue for the owner-preserving copy. (best practice) [sources: k8s/README.md, AGENTS.md]- Rejected: Implement custom copy pods as a named user and group. It builds code that pv-migrate does not support and adds a second copy path.
- Chosen: Defer the owner-preserving copy and use pv-migrate --non-root with fsGroup. It keeps one copy path and uses the maintained tool.
- Rejected: Require a baseline window for every owner-preserving move. It weakens the namespace policy and needs a person to change it.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 27, 2026
Both address volume move failure in a restricted namespace; the candidate adds a guard and an option, while #7449 fixes the pod securityContext directly.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): mostly fixed, in another form.
pod-security.kubernetes.io/enforceof the namespace (_enforces_restricted) before it changes anything. In arestrictednamespace it does not refuse every move: the copy runspv-migrate --non-root, whose pods passrestricted. The plan refuses, with no change, a workload that sets nofsGroupand a class whose volumes get nofsGroupfrom the kubelet, such aslocal-path. Each refusal names the label and the way out: give anfsGroup, move to a class such aslonghorn, or move while the namespace enforcesbaseline. Tests: the parametrized refusal test (_restricted_without_fs_group,_restricted_on_local_path,_restricted_on_a_driver_without_fs_group).restrictedis automatic, but not as a user that the person names: pv-migrate--non-rootruns as user 10000 and keeps no owner and no group (internal/rsync/cmd.goadds--no-o --no-g). The workload reads the files through itsfsGroup. A copy as the owner of the data keeps needing a window ofbaseline, as the evidence of this issue did.I leave the issue open for the owner to decide whether this form is enough.
devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.
dan-petty commentedon Nov 29, 2026
Superseded by PR #7518 (commit
2669c9e0a, closed #7498).The volume move plan in
src/devops_cli/k8s/volume_move.pyalready readspod-security.kubernetes.io/enforce, runspv-migratewith--non-rootand--rsync-extra-args=--no-permswhen a workload and storage classfsGroupwork, and refuses arestrictednamespace without a workloadfsGroup, onlocal-path, or on aCSIDriverwithfsGroupPolicy: Nonebefore making any cluster change (tests/k8s/test_k8s_volume_move.py:930-954, 1036-1038, 1165-1190). Owner-preserving copy remains tracked in #7574.