-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
Wait until stores are filled before processing service account token events #8494
Conversation
@lavalamp PTAL. If there's a better way to coordinate two stores, I'd be happy to switch to it |
Yeah-- I know there's a general need to tell when a store has been initially populated. This particular solution is not one I'd like to see copied everywhere (you know people will do that if it shows up in the codebase somewhere). (Also--I'm pretty sure the race detector is going to flag this.) I have two ideas:
|
3cd33bb
to
3b9ba54
Compare
I combined your ideas and created |
You win the data race prediction:
|
3b9ba54
to
1bc4472
Compare
Guarded the |
@@ -112,6 +115,9 @@ type TokensController struct { | |||
// Since we join two objects, we'll watch both of them with controllers. | |||
serviceAccountController *framework.Controller | |||
secretController *framework.Controller | |||
|
|||
serviceAccountsSynced func() bool |
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: // These are here so tests can inject a 'return true'.
LGTM, but you should fix the (still remaining) data race. |
I thought I was the only one writing controllers that needed to work against more than one store :-) Sent from my iPhone
|
1bc4472
to
3cc930d
Compare
3cc930d
to
49ceb82
Compare
needed a mutex around the reflector nil check in HasSynced(). Added and testing comment added |
Travis flaked on |
LGTM |
Wait until stores are filled before processing service account token events
Since the service account tokens controller makes use of two stores, getting
update
events from the initiallist
operations caused misses if the other store wasn't populated yet. This adds a gate to prevent that.