controller/engine: sync informers on controller start#641
Merged
negz merged 1 commit intocrossplane:masterfrom Jan 23, 2024
Merged
controller/engine: sync informers on controller start#641negz merged 1 commit intocrossplane:masterfrom
negz merged 1 commit intocrossplane:masterfrom
Conversation
87a306c to
534acbf
Compare
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@upbound.io>
534acbf to
7f21c79
Compare
negz
reviewed
Jan 17, 2024
Comment on lines
+274
to
+277
| if synced := c.ca.WaitForCacheSync(ctx); !synced { | ||
| c.e.done(c.name, errors.New(errCrashCache)) | ||
| return | ||
| } |
Member
There was a problem hiding this comment.
I think this is already happening inside of controller-runtime (at least for the non-realtime case). I find their code hard to follow due to all the returning of interfaces, but AFAICT:
- Our
e.Createcallsctrl.Watch, withsource.Kind(ca, ...)as an argument. This adds the source to the controller's internalstartWatchesslice of watches to start whenctrl.Startis called. - When
ctrl.Startis called it iterates overstartWatches, calling each source'sStartmethod. - The source should be an
internal.Kind, and itsStartmethod calls its cache'sWaitForCacheSyncmethod.
That's not guaranteed to be the case when using TriggeredBy though.
Assuming it doesn't hurt to call WaitForCacheSync multiple times I think it's a good idea to add this regardless.
negz
approved these changes
Jan 17, 2024
negz
added a commit
to negz/crossplane
that referenced
this pull request
Jan 23, 2024
Bring in crossplane/crossplane-runtime#641 to see whether it helps with crossplane#5228. Signed-off-by: Nic Cope <nicc@rk0n.org>
This was referenced Jan 23, 2024
negz
added a commit
to negz/crossplane
that referenced
this pull request
Jan 31, 2024
Bring in crossplane/crossplane-runtime#641 to see whether it helps with crossplane#5228. Signed-off-by: Nic Cope <nicc@rk0n.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
Fixes crossplane/crossplane#5151.
Before this, there was no wait for informers when starting the XR controller. This PR is supposed to ensure that all informers are in sync before XRs are reconciled.
I have:
make reviewable testto ensure this PR is ready for review.How has this code been tested
Mostly by reading the code carefully. Waiting for feedback from crossplane/crossplane#5151.