-
Notifications
You must be signed in to change notification settings - Fork 689
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
Convert to controller runtime runnables #4202
Convert to controller runtime runnables #4202
Conversation
- controller runtime manages controllers and other runnables (previously goroutines added to the server workgroup) - leader election now uses a combination of configmap and lease objects, in a future release we can move to just leases - controllers and other components are currently not dependent on leader election - other components (status writers) are set to be dependent on leader election - adds to the leaderelection e2e tests to check on leaderelection configmap in addition to new lease resource and events Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
overrides #4157 |
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Codecov Report
@@ Coverage Diff @@
## main #4202 +/- ##
==========================================
+ Coverage 76.52% 76.59% +0.07%
==========================================
Files 111 114 +3
Lines 9869 9999 +130
==========================================
+ Hits 7552 7659 +107
+ Misses 2150 2149 -1
- Partials 167 191 +24
|
for name, test := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
mockManager := &mocks.Manager{} | ||
|
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.
curious what people think about these tests, they ensure the controller is registered and that it does not require leader election, using a generated mock manager (see mock package and go generate
command above)
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestEventHandlerNotRequireLeaderElection(t *testing.T) { |
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.
curious what people think of these tests for the various components, settled on this after spiking through another option which i wonder what people think of
- new object as thin wrapper around controller-runtime manager
- mainly for testing, can test by mocking controller-runtime manager (see controller tests for example)
- instead of
manager.Add(Runnable)
method, have something likemanager.Add(Runnable, requireLeaderElection bool)
decided against this for a few reasons, mainly bc it ended up being a v thin wrapper (need to expose a lot of things from the base controller-runtime manager) and puts more logic in the main
package, rather than closer to the components themselves which should have the knowledge about whether they need leader election or not
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.
Handful of comments, but overall this is looking nice!
…aderelection Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
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 with @skriss's comments. Nice work @sunjayBhatia!
…aderelection Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
5dc4c52
to
640b248
Compare
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
@sunjayBhatia I was playing with this locally and had a couple issues:
I imagine the first is related to the E2E failures. I haven't had a chance to dig into these any further yet, just wanted to put the reports here. I'll look some more later this AM. |
yep, same issues here, e2e tests do some capturing of the issues but a little worried about other components besides just the main status updater (e.g load balancer status updater), needs a little more work |
|
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
i think fixing my silly channels mistake also helped with shutdown issues |
Yep looks better for me |
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.
One thought on the tests, otherwise I think this looks good, doing some ad-hoc testing locally too
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
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.
👍 local testing all looks good to me, as does the new leader election notification abstraction
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Tests need a small fix to make them more robust now we’re deleting contour and restarting in incluster suite |
Also check new leader pod exists Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
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, not sure if there were any other outstanding threads here though
i think we got everything! |
goroutines added to the server workgroup)
in a future release we can move to just leases
election
configmap in addition to new lease resource and events