-
Notifications
You must be signed in to change notification settings - Fork 462
controllers: refactor code and start informers first, fix template/render race #482
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
controllers: refactor code and start informers first, fix template/render race #482
Conversation
|
/retest |
3194d28 to
21563df
Compare
|
I think with stuff like this it'd help me a lot to have a "reference operator" codebase. There's the kube sample controller but our code is different enough I'm not sure if it's doing the same thing. |
cool, and from that example operator it looks like informers are indeed started before the controller itself https://github.com/kubernetes/sample-controller/blob/master/main.go#L64-L71 - I've rebased this as well /assign @LorbusChris |
a12e170 to
4b7aaf4
Compare
08f1f4a to
33edd4d
Compare
|
/retest |
33edd4d to
bd3e2e8
Compare
17df599 to
d65d8a5
Compare
|
This has been updated (re-read the summary in the first comment) and does fix #338 as well (by waiting on the template controller 🎉 ): |
c3bb896 to
a2ad129
Compare
This patch does various things, all related: - start the informers for controllers before running them to follow what https://github.com/kubernetes/sample-controller/blob/master/main.go#L64-L71 does and to avoid races already spotted in unit tests (openshift#457) - move the clients builder code from cmd/common to a new package just for that under the new internal/ folder so nobody but us can use that - move common controllers code under pkg/controller/common to be reused - create an e2e only clientset, avoiding us to type client version everytime (eg client.CoreV1()..). This is a need cause if in the future the api change, we don't play grep for a week replacing old apis... Signed-off-by: Antonio Murdaca <[email protected]>
The template controller is responsible for generating the initial MCs but the render controller can kick in before the template is done. Add a sync mechanism by looking at the controller config status as that's the souce of truth to understand if a sync is done if the controller config changes and the template controller runs again. Signed-off-by: Antonio Murdaca <[email protected]>
Signed-off-by: Antonio Murdaca <[email protected]>
a2ad129 to
1e381d2
Compare
|
/retest |
|
LGTM! Really like some of the changes here, will leave it to @cgwalters / @LorbusChris to give it one more set of 👀 |
cgwalters
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.
/lgtm
| } | ||
|
|
||
| if cur.Generation != cur.Status.ObservedGeneration { | ||
| return fmt.Errorf("status for ControllerConfig %s is being reported for %d, expecting it for %d", cc[0].GetName(), cur.Status.ObservedGeneration, cur.Generation) |
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.
Feels like this isn't an error but eh.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cgwalters, runcom The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
This patch does various things, all related:
https://github.com/kubernetes/sample-controller/blob/master/main.go#L64-L71
does and to avoid races already spotted in unit tests
(pkg/controller: start informers before populating store in tests #457)
under the new internal/ folder so nobody but us can use that
everytime (eg client.CoreV1()..). This is a need cause if in the future
the api change, we don't play grep for a week replacing old apis...
Closes: #338
Closes: #385
Signed-off-by: Antonio Murdaca [email protected]