Skip to content

fix(k8s): patch bound Delete volumes and recreate StatefulSets #6752

Done

Description

@devops-cli-service

Split from #6341.

The manifest change points new volumes at local-path-retain. It does not change a bound volume or a live StatefulSet. The API server refuses a change of storageClassName on a bound claim and a change of volumeClaimTemplates on a StatefulSet. The live cluster needs a patch of the 8 bound Delete volumes and a recreation of each live StatefulSet. The pull request cannot run these steps: they need cluster access and a maintenance window, and they change data-bearing resources. A person runs them after the manifest sync. Acceptance criteria: each bound PersistentVolume of a devops-cli workload with persistentVolumeReclaimPolicy: Delete gets Retain with `kubectl patch pv <name> -p '{% raw %}{

Proposed design

Problem statement

The manifest change in #6341 points new volumes at local-path-retain. The live cluster still has 8 bound PersistentVolumes with reclaim policy Delete and StatefulSets whose volumeClaimTemplates name local-path. Kubernetes refuses an in-place change of a bound claim's storageClassName and of a StatefulSet's volumeClaimTemplates. The pull request delivers the ordered runbook that a person runs in a maintenance window. The live execution is deferred to a new issue.

Acceptance criteria

Requirement: Retain migration section

The k8s/README.md SHALL include a Local-Path Retain Migration section that gives the ordered commands to patch bound PersistentVolumes and recreate StatefulSets.

Scenario: Section and order

  • WHEN The new documentation test runs.
  • THEN It passes and asserts the section holds the kubectl patch pv step before the kubectl delete statefulset --cascade=orphan step.

Requirement: Patch command

The section SHALL give the exact kubectl patch pv <name> -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}' command and a kubectl get pv listing command that filters on persistentVolumeReclaimPolicy: Delete.

Scenario: Exact patch command

  • WHEN The new documentation test runs.
  • THEN It passes and asserts both commands appear in the section.

Requirement: StatefulSet recreation command

The section SHALL give the exact kubectl delete statefulset <name> --cascade=orphan command and a verification command that waits for the StatefulSet and its pod to be Ready.

Scenario: Exact StatefulSet command

  • WHEN The new documentation test runs.
  • THEN It passes and asserts both commands appear in the section.

Requirement: Documentation check

The documentation change MUST pass the repository documentation check.

Scenario: Documentation check

  • WHEN uv run devops ci --check --only docs runs.
  • THEN The command exits 0.

Existing Tool Considered

No alternatives check has run. kubectl is the open, maintained tool that covers the need: it patches a PersistentVolume's reclaim policy and deletes a StatefulSet with --cascade=orphan. It lacks one ordered, guarded runbook for the 8 volumes and the StatefulSets; this proposal adds that runbook and its verification steps.

Key questions

  • Where does the migration runbook live?: In k8s/README.md. That file already holds the environment-specific local-path decisions and the StatefulSet recreation procedure. (best practice) [sources: CONTEXT.md, k8s/README.md:433, k8s/README.md:448]
    • Chosen: k8s/README.md. It holds the environment tree's cluster decisions and the existing StatefulSet recreation steps.
    • Rejected: docs/commands/k8s.md. It is the command reference, not the runbook for one environment.
    • Rejected: A new docs/runbooks/ page. The repository has no runbook folder, and the environment README already holds this procedure.
  • Should the change add a new CLI command for the migration?: No. kubectl covers the patch and the orphan deletion. The migration is one-time and data-bearing, so the pull request adds a runbook, not code. (best practice) [sources: k8s/README.md:448, src/devops_cli/k8s/volume_move.py, docs/commands/k8s.md:1002]
    • Chosen: kubectl runbook. kubectl is the open, maintained tool for the two operations, and the migration runs once.
    • Rejected: New devops k8s command. It adds code and tests to keep for a one-time, data-bearing procedure.
    • Rejected: Kubernetes Job manifest. The issue says the pull request cannot run the data-bearing steps, and a person must choose the maintenance window.
  • What order do the steps take?: Patch each bound PersistentVolume to Retain first. Then delete each live StatefulSet with --cascade=orphan. Then let Argo CD or the operator recreate it. Then verify the claim and the pod. (best practice) [sources: k8s/README.md:433, k8s/README.md:448, k8s/README.md:516]
    • Chosen: Patch PVs before StatefulSet deletion. A deleted StatefulSet must not leave a Delete volume that the API server can remove.
    • Rejected: Delete StatefulSets first. It risks data loss if a claim still uses a Delete volume.
  • How does the runbook identify the 8 bound volumes?: It gives a kubectl get pv command that filters on persistentVolumeReclaimPolicy: Delete and a claimRef that names a devops-cli workload. The exact names stay live. (best practice) [sources: k8s/README.md:35, k8s/README.md:433]
    • Chosen: List with kubectl. The bound volume names are live state and change with the cluster.
    • Rejected: Commit the 8 names. The names are environment-specific and become stale.
  • Does the migration need a rollback?: No. Setting Retain is non-destructive. Deleting a StatefulSet with --cascade=orphan keeps the pods and the claims. The runbook verifies each step before the next. (best practice) [sources: k8s/README.md:433, k8s/README.md:448]
    • Chosen: No rollback. The steps keep the data and the pods, and the runbook verifies each step.
    • Rejected: Add rollback to Delete. It would risk the data that the migration protects.
  • Which check proves the runbook?: A new test tests/k8s/test_k8s_retain_migration_docs.py asserts the section holds the exact commands and their order. The repository documentation check also runs. (best practice) [sources: tests/k8s/test_k8s_volume_move.py, CONTEXT.md]
    • Chosen: New doc test plus docs check. The test asserts the commands and their order, and the docs check validates the document.
    • Rejected: Only docs check. It does not assert that the exact commands are present.
    • Rejected: Only manual review. It is not an offline check.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/k8s
    source/agent
    status/new
    effort/medium
    value/high
    on Nov 22, 2026
  2. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    ContributorAuthor
    • Priority: P1-High. Bound volumes with Delete reclaim policy risk data loss if a claim is deleted.
    • Related: fix(k8s): put new stateful volumes on local-path-retain #6341, which asks for a different change. Both move stateful volumes to local-path-retain; #6341 changes the manifest for new volumes, the candidate patches existing bound volumes and recreates live StatefulSets.
  3. added
    priority/p1-high
    on Nov 22, 2026
  4. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  5. added
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 23, 2026
  6. added
    status/in-review
    and removed
    status/in-progress
    on Nov 23, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p1-highscope/k8ssource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions