Skip to content

[Bug][RayJob] Stop spurious CR updates once the finalizer is removed - #5090

Open
zacheryasc wants to merge 1 commit into
ray-project:masterfrom
zacheryasc:fix/rayjob-finalizer-spurious-update
Open

[Bug][RayJob] Stop spurious CR updates once the finalizer is removed#5090
zacheryasc wants to merge 1 commit into
ray-project:masterfrom
zacheryasc:fix/rayjob-finalizer-spurious-update

Conversation

@zacheryasc

Copy link
Copy Markdown

Why are these changes needed?

On the RayJob deletion path, the reconciler removed its own finalizer and issued an Update unconditionally on every reconcile. When another controller's finalizer keeps the RayJob alive after deletion, KubeRay's finalizer is gone after the first reconcile, yet Update kept firing every requeue, bumping resourceVersion and producing "object has been modified" conflicts for the other controller managing the same RayJob.

Guard the remove+update behind controllerutil.ContainsFinalizer so the Update only fires while the finalizer is still present.

Adds TestReconcileRayJobDeletionFinalizer:

  • own finalizer present: removed once, an external finalizer preserved;
  • own finalizer already absent: no Update is issued.

The new test fails before the guard (expected: 0, actual: 1 Update calls) and passes after.

Related issue number

Closes #1626

Labels

  • If this PR has user-facing changes that require documentation updates at release time, I have added the doc-updates-required label.
  • If this PR contains breaking changes, I have added the breaking-change label.

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested 🙁

On the RayJob deletion path, the reconciler removed its own finalizer and
issued an Update unconditionally on every reconcile. When another
controller's finalizer keeps the RayJob alive after deletion, KubeRay's
finalizer is gone after the first reconcile, yet Update kept firing every
requeue, bumping resourceVersion and producing "object has been modified"
conflicts for the other controller managing the same RayJob.

Guard the remove+update behind controllerutil.ContainsFinalizer so the
Update only fires while the finalizer is still present.

Add TestReconcileRayJobDeletionFinalizer:
- own finalizer present: removed once, an external finalizer preserved;
- own finalizer already absent: no Update is issued.

Closes ray-project#1626

Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
@zacheryasc
zacheryasc force-pushed the fix/rayjob-finalizer-spurious-update branch from 9ba526b to 271b9ba Compare August 7, 2026 08:33
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.

[Bug] KubeRay keep update RayJob CR when external Finalizer added to it.

1 participant