Skip to content

Fix the finalizer writes on Modules and their plugin Pods - #1932

Open
TomerNewman wants to merge 1 commit into
rh-ecosystem-edge:mainfrom
TomerNewman:fix-finalizer
Open

TomerNewman wants to merge 1 commit into
rh-ecosystem-edge:mainfrom
TomerNewman:fix-finalizer

Conversation

@TomerNewman

@TomerNewman TomerNewman commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

metadata.finalizers is a list, and a merge patch sends a list whole. A write computed from a read that predates another controller's entry therefore removes that entry along with its own. Both writers of ModuleFinalizer, and the one that takes NodeLabelerFinalizer off a plugin Pod, now carry the resourceVersion they read, so a stale write fails rather than lands.

The Pod node label reconciler also treated a Node that had already gone as an error. Its own finalizer then stayed on the Pod for good, and so did anything waiting for that Pod. A Node that is not there carries no label, so that case is done rather than failed.

fix #1931


/cc @yevgeny-shnaidman
/assign @yevgeny-shnaidman

metadata.finalizers is a list, and a merge patch sends a list whole. A
write computed from a read that predates another controller's entry
therefore removes that entry along with its own. Both writers of
ModuleFinalizer, and the one that takes NodeLabelerFinalizer off a
plugin Pod, now carry the resourceVersion they read, so a stale write
fails rather than lands.

The Pod node label reconciler also treated a Node that had already gone
as an error. Its own finalizer then stayed on the Pod for good, and so
did anything waiting for that Pod. A Node that is not there carries no
label, so that case is done rather than failed.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
@netlify

netlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for openshift-kmm ready!

Name Link
🔨 Latest commit 2d3386d
🔍 Latest deploy log https://app.netlify.com/projects/openshift-kmm/deploys/6ab22da013463300088b258a
😎 Deploy Preview https://deploy-preview-1932--openshift-kmm.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 90e7309b-55df-4c21-bd2f-b595c9012183

📥 Commits

Reviewing files that changed from the base of the PR and between 436d4da and 2d3386d.

📒 Files selected for processing (4)
  • internal/controllers/module_reconciler.go
  • internal/controllers/module_reconciler_test.go
  • internal/controllers/pod_node_label_reconciler.go
  • internal/controllers/pod_node_label_reconciler_test.go

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when multiple controllers update module or pod finalizers concurrently, preserving changes made by other controllers.
    • Pod label reconciliation now completes successfully when the associated node has already been deleted.
    • Finalizer updates now preserve unrelated finalizers and current resource versions, reducing the risk of stale updates overwriting newer changes.

Walkthrough

Module and pod finalizer patches now include optimistic locking. Pod label deletion treats missing nodes as successful. Tests verify resource-version handling, foreign finalizer preservation, and node read failures.

Changes

Controller reconciliation

Layer / File(s) Summary
Module finalizer locking
internal/controllers/module_reconciler.go, internal/controllers/module_reconciler_test.go
Module finalizer addition and removal use optimistic-lock merge patches. Tests verify resource version "7" and preservation of another finalizer.
Pod node and finalizer reconciliation
internal/controllers/pod_node_label_reconciler.go, internal/controllers/pod_node_label_reconciler_test.go
Missing nodes no longer fail label deletion. Other node read errors remain failures. Pod finalizer removal uses optimistic locking and preserves unrelated finalizers.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 2d338

The change prevents stale finalizer writes and allows cleanup after node deletion; the supplied coverage supports merging with normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the changes to finalizer writes on Modules and plugin Pods.
Description check ✅ Passed The description accurately explains optimistic locking for finalizer writes and handling of missing Nodes.

Comment @coderabbitai help to get the list of available commands.

@openshift-ci

openshift-ci Bot commented Sep 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TomerNewman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@TomerNewman

Copy link
Copy Markdown
Member Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cherry-picking error for 91c9362d93f72a0a45a2d3df4527adea056a7d48

3 participants