Skip to content

refactor(k8s): replace the volume move copy with pv-migrate - #7518

Merged
dan-petty merged 2 commits into
mainfrom
refactor/7498-volume-move-pv-migrate
Nov 28, 2026
Merged

dan-petty merged 2 commits into
mainfrom
refactor/7498-volume-move-pv-migrate

Conversation

@dan-petty

@dan-petty dan-petty commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

devops k8s volume move copied a claim with its own copy pods, a NetworkPolicy, a Perl listener, GNU tar over bash /dev/tcp, a retry and a bash digest compare, the cause of about 5 of its 14 bugs in 30 days. The copy step now runs pv-migrate (Apache-2.0) with the clusterip strategy: an sshd pod with the old claim on its node and an rsync pod with the new claim on the target node. rsync checks each file that it sends, so the compare goes. In a namespace that enforces Pod Security restricted, the copy adds --non-root and --rsync-extra-args=--no-perms (user 10000 cannot chmod the root folder of the new volume), and the plan refuses a workload or a class with no fsGroup. The plan refuses a move when pv-migrate is not on PATH (dan-petty/devtools#118). When the run stops pv-migrate, the undo runs pv-migrate cleanup first. The copy measure and the CronJob devops/volume-move go.

Closes #7498

Change: openspec/changes/archive/2026-11-28-7498-volume-move-pv-migrate/

@dan-petty

Copy link
Copy Markdown
Owner Author

Live test of head 3d0baf5 on 2026-11-28 (owner approved), with temporary objects only (namespaces t-7518-*, busybox writers, pv-migrate v3.8.0 from a checksum-verified scratch binary):

Move Mode Result
t-7518-root/data 200 MiB, condor → bombas, local-path root pass, 53 s: 22/22 checksums, owned-by-1234 1234:5678 0600, modes 0640/0750, both symlinks, a write
same claim, local-path → longhorn root pass, 71 s, same checks
t-7518-root/scratch 600 MiB, gemini → bombas root pass, 62/62 checksums
t-7518-root/scratch → condor, SIGINT to the move's process group during step 4 root undo correct: workload back on its volume, 62/62 checksums, scratch-move deleted; pv-migrate's own objects gone within 20 s
t-7518-restricted/data → longhorn (Pod Security restricted, --non-root) non-root fail (2 runs): rsync exit 23 in each of 11 attempts; the undo was correct both times (workload back on local-path, checksums pass)

Cause of the failure, from the rsync pod log: pv-migrate runs rsync -av ... --no-o --no-g, and rsync reports [generator] failed to set permissions on "/dest/.": Operation not permitted (1). The root folder of the new volume belongs to root, and uid 10000 may not chmod it, so the -p of -a fails on . only. So the restricted path does not work as built.

t-7518-root and its 5 volumes are deleted. t-7518-restricted stays for the re-test of the fix.

@dan-petty
dan-petty force-pushed the refactor/7498-volume-move-pv-migrate branch from 3d0baf5 to caa153f Compare November 28, 2026 02:47
@dan-petty

Copy link
Copy Markdown
Owner Author

Re-test of head caa153f on 2026-11-28: t-7518-restricted/data (Pod Security restricted, workload uid 1000 / gid 3000 / fsGroup 2000) to --storage-class longhorn: pass, 84 s.

  • The plan printed "pv-migrate runs with --non-root, and rsync with --no-perms"; the rsync pod ran rsync -av ... --no-o --no-g --omit-dir-times --no-perms.
  • After the move, inside the pod on bombas, class longhorn: 22/22 checksums pass, both symlinks keep their targets, a write as uid 1000 succeeds.
  • Owners and modes: files and folders belong to 10000:2000. Files show 0664 and folders 2775, also leaf.txt, which was 0444 at the source. rsync keeps 0444 (--no-perms gives new files the source mode under umask 022); the kubelet then applies the fsGroup of the pod to the longhorn volume and ORs 0660 into each file and the setgid bit into each folder (SetVolumeOwnership). So on a class with fsGroup support, a moved file is group-writable whatever its source mode. The design text should say this.

Cleanup: t-7518-restricted, its 2 volumes and the Longhorn volume are deleted; no t-7518 namespace, volume or pv-migrate object is left in the cluster.

devops k8s volume move copied a claim with its own copy pods, a
NetworkPolicy, a Perl listener, GNU tar over bash /dev/tcp, a retry and a
digest compare in bash. The copy step now runs pv-migrate (Apache-2.0)
with the clusterip strategy: an sshd pod with the old claim on its node
and an rsync pod with the new claim on the target node. rsync checks each
file that it sends, so the compare step goes. In a namespace that
enforces Pod Security restricted, the copy adds --non-root, and the plan
refuses a workload with no fsGroup and a class whose volumes get no
fsGroup. The plan refuses a move when pv-migrate is not on PATH. When the
run stops pv-migrate, the undo runs pv-migrate cleanup first. The copy
measure and the CronJob devops/volume-move go.
@dan-petty
dan-petty force-pushed the refactor/7498-volume-move-pv-migrate branch from caa153f to 26b673c Compare November 28, 2026 03:01
@dan-petty
dan-petty marked this pull request as ready for review November 28, 2026 03:09
@dan-petty
dan-petty merged commit 2669c9e into main Nov 28, 2026
29 checks passed
@dan-petty
dan-petty deleted the refactor/7498-volume-move-pv-migrate branch November 28, 2026 03:17
dan-petty-release Bot added a commit that referenced this pull request Nov 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.232.3](v0.232.2...v0.232.3)
(2026-11-28)


### Code Refactoring

* **k8s:** replace the volume move copy with pv-migrate
([#7518](#7518))
([2669c9e](2669c9e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/k8s Kubernetes commands, Helm charts, pods, services, and policies type/refactor Type refactor: a new structure, same behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(k8s): replace the volume move copy with pv-migrate

1 participant