Repository navigation
Description
Problem Description
devops k8s volume move cannot move a claim in a namespace that enforces Pod Security restricted. It builds its copy pods itself, with no securityContext. It reads only the image of the copy container from CronJob devops/volume-move (src/devops_cli/k8s/volume_move.py). Namespace devops enforces restricted, so the API server refuses the first copy pod.
Evidence, 2026-11-27 17:32 UTC
dan-petty/homelab#580 gives the claims devops/valkey-data-roadmap and devops/renovate-cache the class longhorn. A bound claim cannot change its class, so each sync of Application devops fails until the data moves. The move stopped at step 2 and undid each step:
$ uv run devops k8s volume move devops/valkey-data-roadmap --storage-class longhorn
The move stopped at step 2: `kubectl create` exited 1: Error from server (Forbidden): error when creating "STDIN": pods "valkey-data-roadmap-dst" is forbidden: violates PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "copy" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "copy" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "copy" ...
Namespaces llm and monitoring enforce privileged, so the earlier moves there passed. The sync of Application devops fails since 17:00 UTC, so no new release of devops-cli reaches the cluster.
Expected Behavior
The copy pods pass Pod Security restricted: runAsNonRoot, allowPrivilegeEscalation: false, capabilities.drop: ["ALL"] and the seccomp profile RuntimeDefault. They run as the user and group of the pod template of the workload that mounts the claim, and the new volume gets the fsGroup of that template, so the copy reads each file and writes it with the same owner. Example: deployment/valkey-roadmap runs as user 999, group 1000, fsGroup 1000. CronJob renovate runs as 12021. The compare of step 6 still finds no difference.
Acceptance Criteria
- A test: the copy pods of a move in a namespace that enforces
restrictedhave each field that the profile asks for, and the user, group andfsGroupof the workload pod template. - A test: a workload whose pod template runs as root keeps the copy pods of today in a namespace that admits them.
- Pending a person or an agent after the release:
uv run devops k8s volume move devops/valkey-data-roadmap --storage-class longhornends with no difference in step 6, and the next sync of Applicationdevopssucceeds.
Related
- feat(k8s): move a claim to another storage class with volume move #7382 (the move to another class), dan-petty/homelab#580 (the move plan of the
devopsclaims).
Alternatives check of 2026-11-27: none.
Tool: none found.
Reason: Searches found only generic PVC migrators and cluster policy engines, which run their own pods or mutate cluster-side; none gives the CLI's copy pods the restricted fields plus the workload user, group and fsGroup, or fixes the step 6 compare.
Lacks:
- No library builds a restricted securityContext into a pod manifest the CLI creates
- No tool derives runAsUser, runAsGroup and fsGroup from the workload pod template
- No tool adjusts the copy and digest scripts for the provisioner-owned root directory
- No tool refuses a claim whose workloads set disagreeing user or fsGroup values
Proposed design
Problem statement
Do not rebuild the copy pods: the move now uses pv-migrate --non-root in a restricted namespace. The remaining gate is the live move of devops/valkey-data-roadmap, which waits on dan-petty/devtools#118. The defect is that a claim in a namespace that enforces Pod Security restricted cannot move, because the API server refuses the copy pod. The fix must pass the restricted profile and keep the data readable by the workload.
Acceptance criteria
Requirement: Restricted namespace uses pv-migrate non-root
The move SHALL pass --non-root and --rsync-extra-args=--no-perms to pv-migrate when the namespace enforces Pod Security restricted, which makes pv-migrate give the copy pods the restricted securityContext.
Scenario: Restricted namespace
- WHEN A test calls
pv_migrate_argvwith a plan whosenon_rootis true. - THEN The argv contains
--non-rootand--rsync-extra-args=--no-perms.
Requirement: Non-restricted namespace keeps the root copy
The move SHALL call pv-migrate without --non-root when the namespace does not enforce Pod Security restricted.
Scenario: Non-restricted namespace
- WHEN A test calls
pv_migrate_argvwith a plan whosenon_rootis false. - THEN The argv contains no
--non-rootand no--rsync-extra-args.
Requirement: Restricted move refuses a workload without fsGroup
plan_volume_move SHALL refuse a restricted-namespace move when a workload pod template sets no fsGroup.
Scenario: Workload without fsGroup
- WHEN A test calls
_non_root_problemswith a workload state whosefs_groupis None and a target class whosefs_groupis true. - THEN The result contains the message
volume_move_restricted_no_fs_groupfor that workload.
Requirement: Restricted move refuses a class without fsGroup
plan_volume_move SHALL refuse a restricted-namespace move when the target class cannot give the fsGroup to its files.
Scenario: Class with no fsGroup
- WHEN A test calls
_non_root_problemswith a workload state whosefs_groupis 1000 and a_TargetClasswhosefs_groupis false. - THEN The result contains the message
volume_move_restricted_classfor the target class.
Requirement: Pending a person after the merge
The move SHALL finish a live move of devops/valkey-data-roadmap to class longhorn with no difference in step 6, and the next sync of Application devops SHALL succeed.
Scenario: Live move after release
- WHEN A person runs
uv run devops k8s volume move devops/valkey-data-roadmap --storage-class longhornafter the release. - THEN Step 6 reports no difference and the next sync of Application
devopssucceeds.
Existing Tool Considered
The alternatives check of 2026-11-27 in the issue body gives the verdict none and names no tool. The repository already uses pv-migrate for the copy (#7518). The proposal keeps pv-migrate with --non-root and --rsync-extra-args=--no-perms in a restricted namespace, and refuses a move when the workload has no fsGroup or the target class gives no fsGroup. It builds no copy code.
Key questions
- How does the move make the copy pods pass Pod Security
restricted?: The move passes--non-rootand--rsync-extra-args=--no-permsto pv-migrate when the namespace enforcesrestricted. pv-migrate v3.8.0 then gives the sshd and rsync pods the restricted securityContext. (best practice) [sources: src/devops_cli/k8s/volume_move.py, tests/k8s/test_k8s_volume_move.py]- Chosen: Use pv-migrate
--non-root. pv-migrate is already the copy tool, and its non-root values meet the restricted profile. - Rejected: Build the copy pod securityContext in the CLI. The repository replaced its own copy pods with pv-migrate in refactor(k8s): replace the volume move copy with pv-migrate #7518; building them again adds code that the tool covers.
- Rejected: Use a Pod Security exception. It lowers a security threshold, which only the owner can allow.
- Chosen: Use pv-migrate
- How does the workload read a copy whose files keep no owner?: The workload reads the copy through its
fsGroup. The plan refuses a restricted-namespace move when a workload sets nofsGroup, or when the target class cannot give thefsGroupto its files. (best practice) [sources: src/devops_cli/k8s/volume_move.py, src/devops_cli/lang/en/messages.py, tests/k8s/test_k8s_volume_move.py]- Chosen: Require a workload fsGroup and a class that applies it. pv-migrate
--non-rootadds--no-o --no-gto rsync, so the fsGroup is the only way the workload gets access. - Rejected: Run the copy as the workload user and group. The pv-migrate rsync and sshd images have only user 10000; a workload
runAsUserdoes not work. - Rejected: Copy as root with a Pod Security exception. It lowers a security threshold.
- Chosen: Require a workload fsGroup and a class that applies it. pv-migrate
- What does the move do in a namespace that does not enforce
restricted?: The move calls pv-migrate without--non-root. The copy runs as root and rsync-akeeps each owner. (best practice) [sources: src/devops_cli/k8s/volume_move.py, tests/k8s/test_k8s_volume_move.py]- Chosen: Run as root when the namespace admits it. The root copy keeps file owners and the namespace does not refuse it.
- Rejected: Always run
--non-root. It drops owners where the namespace would allow root, and the issue asks to keep the old copy for a root workload.
- Does the repository need a new copy tool?: No. The repository already uses pv-migrate for the copy. The alternatives check of 2026-11-27 in the issue body gives the verdict
nonefor the original need. The proposal keeps pv-migrate and adds no copy code. [sources: src/devops_cli/k8s/volume_move.py]
Fit
Fits in one pull request.
Suspected block
The live move waits on dan-petty/devtools#118, which adds pv-migrate to the devtools image.
Dependencies
None.
Activity
dan-petty commentedon Nov 27, 2026
The Argo CD sync of Application devops fails, blocking all devops-cli releases to the cluster.dan-petty commentedon Nov 27, 2026
Stop: a non-root copy cannot pass step 5 or step 6 (evidence, 2026-11-27)
I did not build this item and I opened no pull request. With copy pods that run as the workload user, the copy of step 5 fails, and the compare of step 6 cannot find "no difference". To continue, the compare must change, or the copy must run as root. The owner must make this decision.
Test. I ran GNU tar 1.35 of the copy image (
debian:trixie-slim@sha256:8aa5a7bf…, the image of CronJobdevops/volume-move) and the digest script of the move (CONST_K8S_VOLUME_MOVE_DIGEST_SCRIPT) in rootless podman, on a temporary volume. I made no write to the cluster.setupscript of ConfigMaplocal-path-storage/local-path-configrunsmkdir -m 0777 -p "$VOL_DIR"as root, so the root directory isd 777 0:0. The volumes ofdevops/valkey-data-roadmapanddevops/renovate-cachearehostPathvolumes, so the kubelet applies no fsGroup to them. The test files belong to user 999, group 1000.0755 0:0. CSIDriverdriver.longhorn.iohasfsGroupPolicy: ReadWriteOnceWithFSType, and classlonghornhasfsType: ext4, so the kubelet applies the fsGroup 1000: the root directory becomes2775 0:1000.no-new-privileges.tar -x0755 0:02775 0:1000(fsGroup)tar --no-overwrite-dir2775 0:1000(fsGroup)0755 0:0(no fsGroup)Cannot mkdir: Permission denied)Errors of the non-root extract:
Metadata lines (
%y %m %U:%G %P) that are different on the two sides:The count, the bytes, the content digest and the owner, group and mode of each file were equal. A file dated 2020-01-02 kept that date (the compare does not check mtime).
Cause. Only the owner of a file, or a process with
CAP_FOWNERandCAP_CHOWN, can change the mode, the time and the owner of the file. Root owns the root directory of the new volume. Pod Securityrestrictedrefuses user 0 and each added capability exceptNET_BIND_SERVICE. Thus a non-root copy cannot give the new root directory the owner0:0and the mode0777of the old root directory, and tar exits 2 when it tries. Also, each new directory gets the setgid bit from the fsGroup root directory. In the test, the directories with mode 700 kept that bit (2700); the directories with mode 711, 750, 755 and 775 did not.Options (each one needs a decision of the owner):
devopsenforcesrestricted, so this needs a change of a Pod Security label or of an admission policy.devopsnow: put the class of the two claims back tolocal-pathin the environment repository until a move can run. The class change of the bound claims is the cause of the failed sync.Script to do the test again
Write the digest script first:
uv run python -c "from devops_cli.config.constants import CONST_K8S_VOLUME_MOVE_DIGEST_SCRIPT as s; open('digest.sh','w').write(s)". Then run the script with no variables (the non-root copy), withEXTRACT_FLAGS=--no-overwrite-dir, withCOPY_USER=0:0 CAP_FLAGS= DST_FSGROUP=(the copy of today), and withDST_FSGROUP=.dan-petty commentedon Nov 27, 2026
Cannot be built as written: a non-root copy in a restricted namespace cannot set the mode of the new root directory, and the metadata compare of step 6 then differs (evidence: #7449 (comment)). The owner chooses between a change of the compare, a root copy with a Pod Security exception, or no move for this claim.
devops-cli-service commentedon Nov 27, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
dan-petty commentedon Nov 27, 2026
Update 2026-11-27 19:22 UTC: this item no longer blocks Application
devops. The two claims were made again with the classlonghornat about 17:49 UTC, not by a move (the new pod ofvalkey-roadmapstarted then). The owner then confirmed this choice over a move:valkey-roadmapholds only the brain index, which ADR 0023 rates as derived data. Both claims are nowlonghornand Bound, the oldlocal-pathvolume ofvalkey-data-roadmapis kept asReleased, and the Application is Synced and Healthy at v0.228.2 since 18:28 UTC.The defect stays:
volume movecannot move a claim in a namespace that enforcesrestricted. Priority goes from P0 to P2. The choice between the options of the evidence comment stays with the owner.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): partly fixed. The copy passes Pod Security
restricted, but the files do not keep their owner.pv-migrate --strategies clusterip. When the namespace haspod-security.kubernetes.io/enforce: restricted, the move adds--non-root. In pv-migrate v3.8.0,applyNonRootValues(internal/strategy/strategy.go:226) gives the sshd and rsync podsrunAsNonRoot: true, user and group 10000,allowPrivilegeEscalation: false,capabilities.drop: [ALL],seccompProfile: RuntimeDefaultandfsGroup: 10000. The testtest_a_namespace_that_enforces_restricted_copies_with_non_rootchecks that the call ends with--non-root.restricted, pv-migrate runs as root and rsync-akeeps each owner (test_a_namespace_that_does_not_enforce_restricted_copies_as_root).--non-rootadds--no-o --no-gto rsync (internal/rsync/cmd.go), and the rsync and sshd images have only user 10000 in/etc/passwd, which OpenSSH needs, so arunAsUserof the workload does not work. The workload reads the copy through itsfsGroup. So the plan refuses a move in arestrictednamespace when a workload sets nofsGroup, or when the class gives nofsGroupto its files (no CSIDriver, orfsGroupPolicy: None, such aslocal-path).devops-cli-service commentedon Nov 28, 2026
Owner question: See Suspected block in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence