Skip to content

fix(vm): tolerate concurrent finalizer changes when releasing PVC protection#2659

Merged
Isteb4k merged 1 commit into
mainfrom
fix/vm/pvc-protection-finalizer
Jul 14, 2026
Merged

fix(vm): tolerate concurrent finalizer changes when releasing PVC protection#2659
Isteb4k merged 1 commit into
mainfrom
fix/vm/pvc-protection-finalizer

Conversation

@Isteb4k

@Isteb4k Isteb4k commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

ProtectionService.RemoveProtection re-reads a fresh copy of the object and
removes only our finalizer under an optimistic lock, retrying on conflict,
instead of resending the whole (possibly stale) finalizers list.

Why do we need it, and what problem does it solve?

On a terminating PVC the built-in pvc-protection controller strips
kubernetes.io/pvc-protection. Patching from a stale copy resent it, and the
API server rejected the update: no new finalizers can be added if the object is being deleted. The VM deletion handler surfaced this as failed to release PVC protection, never removed the VM cleanup finalizer, and VM deletion hung.

What is the expected result?

Deleting a VM whose block-device PVC is terminating completes cleanly; the
errors above no longer appear in the vm-controller log.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vm
type: fix
summary: Release the PVC protection finalizer without resurrecting finalizers dropped from a terminating PVC, so VM deletion no longer hangs.
impact_level: low

…tection

ProtectionService.RemoveProtection built its merge patch from a possibly stale
(informer cache) copy and resent the whole finalizers list. On a terminating
PersistentVolumeClaim this could re-add kubernetes.io/pvc-protection that the
built-in pvc-protection controller had already dropped, which the API server
rejects with 422 ("no new finalizers can be added if the object is being
deleted"). The VM deletion handler surfaced this as "failed to release PVC
protection" and never removed the VM cleanup finalizer, so VM deletion hung.

Re-read a fresh copy and patch it under an optimistic lock, retrying on
conflict, so only our finalizer is removed and no other finalizer is
resurrected.

Signed-off-by: Dmitry Rakitin <dmitry.rakitin@flant.com>
@Isteb4k Isteb4k requested a review from yaroslavborbat as a code owner July 14, 2026 09:08
@Isteb4k Isteb4k added this to the v1.10.0 milestone Jul 14, 2026
@Isteb4k Isteb4k merged commit 7bcf9f5 into main Jul 14, 2026
37 of 42 checks passed
@Isteb4k Isteb4k deleted the fix/vm/pvc-protection-finalizer branch July 14, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants