Skip to content
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

controller/engine: sync informers on controller start #641

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

sttts
Copy link
Contributor

@sttts sttts commented Jan 9, 2024

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:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to 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.

Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@upbound.io>
Comment on lines +274 to +277
if synced := c.ca.WaitForCacheSync(ctx); !synced {
c.e.done(c.name, errors.New(errCrashCache))
return
}
Copy link
Member

@negz negz Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Our e.Create calls ctrl.Watch, with source.Kind(ca, ...) as an argument. This adds the source to the controller's internal startWatches slice of watches to start when ctrl.Start is called.
  2. When ctrl.Start is called it iterates over startWatches, calling each source's Start method.
  3. The source should be an internal.Kind, and its Start method calls its cache's WaitForCacheSync method.

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 negz merged commit 87cb2d8 into crossplane:master Jan 23, 2024
8 checks passed
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>
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>
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.

cannot get composite resource
2 participants