-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip manifest changes if item is in exponential backoff #225
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,61 @@ | ||||||
/* | ||||||
Copyright 2023. | ||||||
|
||||||
Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
you may not use this file except in compliance with the License. | ||||||
You may obtain a copy of the License at | ||||||
|
||||||
http://www.apache.org/licenses/LICENSE-2.0 | ||||||
|
||||||
Unless required by applicable law or agreed to in writing, software | ||||||
distributed under the License is distributed on an "AS IS" BASIS, | ||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
See the License for the specific language governing permissions and | ||||||
limitations under the License. | ||||||
*/ | ||||||
|
||||||
package handler | ||||||
|
||||||
import ( | ||||||
"context" | ||||||
|
||||||
"k8s.io/client-go/util/workqueue" | ||||||
"sigs.k8s.io/controller-runtime/pkg/event" | ||||||
crthandler "sigs.k8s.io/controller-runtime/pkg/handler" | ||||||
) | ||||||
|
||||||
type requeueFilter struct { | ||||||
crthandler.EventHandler | ||||||
} | ||||||
|
||||||
// RequeueFilter wraps the EventHandler and skips the event if it was requeued for the given object | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
func RequeueFilter(delegate crthandler.EventHandler) crthandler.EventHandler { | ||||||
return &requeueFilter{EventHandler: delegate} | ||||||
} | ||||||
|
||||||
func (r *requeueFilter) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { | ||||||
r.EventHandler.Create(ctx, evt, &delegatingQueue{RateLimitingInterface: q}) | ||||||
} | ||||||
|
||||||
func (r *requeueFilter) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { | ||||||
r.EventHandler.Update(ctx, evt, &delegatingQueue{RateLimitingInterface: q}) | ||||||
} | ||||||
|
||||||
func (r *requeueFilter) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { | ||||||
r.EventHandler.Delete(ctx, evt, &delegatingQueue{RateLimitingInterface: q}) | ||||||
} | ||||||
|
||||||
func (r *requeueFilter) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { | ||||||
r.EventHandler.Generic(ctx, evt, &delegatingQueue{RateLimitingInterface: q}) | ||||||
} | ||||||
|
||||||
type delegatingQueue struct { | ||||||
workqueue.RateLimitingInterface | ||||||
} | ||||||
|
||||||
func (q *delegatingQueue) Add(item interface{}) { | ||||||
if q.RateLimitingInterface.NumRequeues(item) > 0 { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The documentation is rather terse on exact semantics of |
||||||
return | ||||||
} | ||||||
q.RateLimitingInterface.Add(item) | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.