-
Notifications
You must be signed in to change notification settings - Fork 522
Add ability to watch secondary resources #117
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
Conversation
chatton
left a comment
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.
Very clean implementation! I only had 2 small comments, nice work!
pkg/controller/watch/watch.go
Outdated
| } | ||
|
|
||
| // Add will add a new object to watch. | ||
| func (w ResourceWatcher) Add(watchedName, dependentName types.NamespacedName) { |
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.
[nit] The name Add is a bit misleading, I think maybe something like EnsureAdded or EnsureWatched would be more accurate, what do you think?
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.
I agree that Add is a bit misleading but I'm not sure including Ensure adds much. How about Watch? Feels natural that you would Watch with a Watcher!
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.
I think I'm okay with Watch!
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.
Renamed!
pkg/controller/watch/watch.go
Outdated
| for _, existingName := range existing { | ||
| if dependentName == existingName { | ||
| return | ||
| } | ||
| } |
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.
we cloud maybe add a contains.NamespacedName(nsNames, nsName) for this.
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.
True, added!
| func NamespacedName(nsNames []types.NamespacedName, nsName types.NamespacedName) bool { | ||
| for _, elem := range nsNames { | ||
| if elem == nsName { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } |
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.
👍
All Submissions:
This PR implements a custom
handler.EventHandlercalledResourceWatcher. This will allow us to watch for changes to specific secondary resources outside of the main MDB CRD. This PR is part of the work to implement support for TLS certificate rotations. The idea is to have oneResourceWatcheron theReconcilerfor each resource type we want to watch. If we for example have asecretWatcheron ourReconcilerwe can register it like:Resource to watch can then be added from the reconciliation loop using:
r.secretWatcher.Watch(objectToWatch, dependentObject).