-
Notifications
You must be signed in to change notification settings - Fork 374
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
Handle ExternalIPPool range changes in Egress controller #6685
Handle ExternalIPPool range changes in Egress controller #6685
Conversation
7aca6af
to
b93c832
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.
LGTM
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, one nit
require.True(t, cache.WaitForCacheSync(stopCh, controller.externalIPAllocator.HasSynced)) | ||
controller.restoreIPAllocations([]*v1beta1.Egress{egress}) | ||
|
||
getEgressIP, _, err := controller.syncEgressIP(egress) |
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.
Could it receive the returned egress and avoid updating the stored egress
at L613 which may cause race condition?
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.
I made the change. By stored egress
, do you mean the object stored by the fake clientset? They make a copy before adding it to the store:
https://github.com/kubernetes/client-go/blob/c5196ebcc18e1bf29561b7a689fdb121913d221b/testing/fixture.go#L534-L537
but based on the comment, the caller shouldn't modify the object anyway
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.
Thanks for the info.
The validation webhook for ExternalIPPools prevents modifications to IP address ranges. However, it is theoretically possible for an ExternalIPPool to be deleted, then recreated immediately with different IP address ranges, and for the Egress controller to only process the Egress resources referencing the pool once, *after* the CREATE event has been handled by the ExternalIPPool controller. This is because the ExternalIPPool controller is in charge of notifying the Egress controller through a callback (event handler) mechanism, and that multiple events for the same ExternalIPPool name can be merged in the workqueue. With this change, we try to ensure the same "observable" behavior for the Egress controller, regardless of whether the DELETE and CREATE events have been merged or not. The stale Egress IP should be removed, and a new Egress IP should be allocated from the new IP ranges (regardless of whether or not the initial Egress IP was specified by the user). Prior to this change, the change of IP address ranges would be silently ignored by the Egress controller. Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
b93c832
to
fc16420
Compare
I think we don't need to backport this given how unlikely it is to happen in practice |
Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
@tnqn I found a bug in my implementation, so I addressed it in the last commit. I also found a better / simpler way of writing the test. |
/test-all |
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, a typo
/test-all |
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
) The validation webhook for ExternalIPPools prevents modifications to IP address ranges. However, it is theoretically possible for an ExternalIPPool to be deleted, then recreated immediately with different IP address ranges, and for the Egress controller to only process the Egress resources referencing the pool once, *after* the CREATE event has been handled by the ExternalIPPool controller. This is because the ExternalIPPool controller is in charge of notifying the Egress controller through a callback (event handler) mechanism, and that multiple events for the same ExternalIPPool name can be merged in the workqueue. With this change, we try to ensure the same "observable" behavior for the Egress controller, regardless of whether the DELETE and CREATE events have been merged or not. The stale Egress IP should be removed, and a new Egress IP should be allocated from the new IP ranges (regardless of whether or not the initial Egress IP was specified by the user). Prior to this change, the change of IP address ranges would be silently ignored by the Egress controller. Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
The validation webhook for ExternalIPPools prevents modifications to IP address ranges. However, it is theoretically possible for an ExternalIPPool to be deleted, then recreated immediately with different IP address ranges, and for the Egress controller to only process the Egress resources referencing the pool once, after the CREATE event has been handled by the ExternalIPPool controller. This is because the ExternalIPPool controller is in charge of notifying the Egress controller through a callback (event handler) mechanism, and that multiple events for the same ExternalIPPool name can be merged in the workqueue.
With this change, we try to ensure the same "observable" behavior for the Egress controller, regardless of whether the DELETE and CREATE events have been merged or not. The stale Egress IP should be removed, and a new Egress IP should be allocated from the new IP ranges (regardless of whether or not the initial Egress IP was specified by the user).
Prior to this change, the change of IP address ranges would be silently ignored by the Egress controller.