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
Make controller preserve internal state after reboot #2004
Conversation
99f16ca
to
c0c8b0a
Compare
c0c8b0a
to
f758139
Compare
I haven't checked the tests yet but a few comments on the implementation. The implementation works, but it's a bit hacky and could be made more explicit by:
This has the advantage that the flow is clear(er), and the controller implementation is in charge of the mechanism |
@fedepaol without using some kind of manual boolean "isFirstReload" flag, how would you make the pool handler understand if it's the first time we receive a configuration? I mean, the first time we run |
Having the flag is legit I guess, something like "firstConfiguration" to be checked and reset together when we get the first non nil set of pools. |
Ok, thanks for the reply. I was just making sure that this flag wasn't the hacky element of the implementation. |
Nope, what I think is hacky is doing a sequence of actions from the wrapping site (the controller) which has no control on how the items are handled |
As discussed offline, another possible solution is to always loop over the services with an IP first, and those without the IP afterwards. This will remove a lot of the complexity of understanding when to do what, but it has the downside of having this ad hoc logic in the wrapping controller instead of inside the business logic. |
I'll expand on this and say that we drift from the approach of signaling the "firstReload" from within the ReloadEvent struct because it is not normally reachable from the reconcile function and forcing it there will add unnecessary complexity. |
37c06a2
to
fd553b6
Compare
40a5f7c
to
fec81d0
Compare
fec81d0
to
f94dff6
Compare
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.
few nits, will go over the e2es later
9526c3d
to
3593a15
Compare
@oribon the ci failures here are being worked on: |
3c11ae8
to
bc211b9
Compare
bc211b9
to
b3c4265
Compare
This commit changes the behavior of the service reconciler to fix a bug that the controller de-assign an ip for a service after reboot. Make the service reconciler initially ignore the services, up until the first reprocessAll event finishes, where we sort and handle all of the services with assigned IP first. By doing so, we make the controller aware of the LB services with existing external IPs and sync the internal state. Only after we reprocessed all services once, and know what services are allocated and what ips are in use, return to work as normal. Add unit tests for the service controller Add unit test cases to cover the FirstCongifurtaion flag. Testcase 1: Testing the service reconcile with the flag set to true. Testcase 2: Testing the reprocessAll with the flag set to true: validate that the value is modifeid to false by the controller. Signed-off-by: liornoy <lnoy@redhat.com>
* We add a test case where we create 4 services and assert that when the controller restarts, it keeps assigning the first two services the same IPs, and not removing/changing them. * Move functions "validateDesiredLB" and "getIngressIPs" to a different package, to be able to reuse in the l2tests. Signed-off-by: Lior Noy <lnoy@redhat.com>
Make the ConditionStatus function private as it's only being used internally by IsNetworkUnavailable Also switch the order of the functions making the exported one at the top. Signed-off-by: Lior Noy <lnoy@redhat.com>
b3c4265
to
5eb556f
Compare
lgtm, thanks for fixing this! |
This PR changes the behavior of the service reconciler
to fix the following bug:
it loops over the services, sees first the "pending" LB service,
and assigns it the IP that was assigned to the annotated service.
Here we make the reconciler ignore the services, up until the first
reprocessAll event, where we handle only the services with IP assigned
to them already.
fixes #1984