fix occasional restarts of kruise controller manager#2382
fix occasional restarts of kruise controller manager#2382PersistentJZH wants to merge 1 commit intoopenkruise:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR addresses intermittent kruise-controller-manager restarts during startup by preventing field index registration for ImagePullJob (v1alpha1) until the corresponding CRD/version is discoverable, avoiding “no matches for kind” errors when CRDs are established slightly later than the controller starts.
Changes:
- Guard
ImagePullJob(apps.kruise.io/v1alpha1) ownerReference field index registration behindutildiscovery.DiscoverObject. - Align v1alpha1
ImagePullJobownerRef index registration behavior with other CRD-gated index registrations already present inRegisterFieldIndexes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if utildiscovery.DiscoverObject(&appsv1alpha1.ImagePullJob{}) { | ||
| if err = c.IndexField(context.TODO(), &appsv1alpha1.ImagePullJob{}, IndexNameForOwnerRefUID, ownerIndexFunc); err != nil { | ||
| return | ||
| } | ||
| } |
There was a problem hiding this comment.
DiscoverObject(&appsv1alpha1.ImagePullJob{}) is now called here and again later in RegisterFieldIndexes (for the isActive index). Because DiscoverObject can retry with exponential backoff, calling it multiple times for the same GVK can noticeably slow startup in CRD-not-ready scenarios and can also lead to inconsistent registration (e.g., ownerRef index registered but isActive skipped, or vice versa). Consider computing the discovery result once (e.g., hasImagePullJobV1Alpha1 := utildiscovery.DiscoverObject(...)) and reusing it for all ImagePullJob v1alpha1 index registrations (and similarly for v1beta1).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2382 +/- ##
==========================================
+ Coverage 48.66% 48.68% +0.01%
==========================================
Files 324 324
Lines 27920 27921 +1
==========================================
+ Hits 13587 13592 +5
+ Misses 12794 12791 -3
+ Partials 1539 1538 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: PersistentJZH <zhihao.kan17@gmail.com> - fix occasional restarts of kruise-controller-manager
efaf2dc to
669dbb7
Compare
|
/cc @zmberg @furykerry |
Ⅰ. Describe what this PR does
fix occasional restarts of kruise controller manager
root cause: The CRD installation was completed later than the CRD index registration time during the start of kruise-controller-manager.
Ⅱ. Does this pull request fix one issue?
Fix: #2380
Ⅲ. Describe how to verify it
Ⅳ. Special notes for reviews