Fix route deletion for Service ClusterIP and LoadBalancerIP#4711
Merged
Conversation
hongliangl
reviewed
Mar 16, 2023
| // If previous Service which has ClusterIP should be removed, remove ClusterIP routes. | ||
| if svcInfo.ClusterIP() != nil { | ||
| if err := p.routeClient.DeleteClusterIPRoute(pSvcInfo.ClusterIP()); err != nil { | ||
| if pSvcInfo.ClusterIP() != nil { |
| // ServicePort (which is the unit of the processing), a Service IP route may be required by several ServicePorts. | ||
| // With the references, we install a route exactly once as long as it's used by any ServicePorts and uninstall it | ||
| // exactly once when it's no longer used by any ServicePorts. | ||
| // It applies to ClusterIP and LoadBalancerIP. |
Contributor
There was a problem hiding this comment.
If we could merge #3889, I think we could remove the code change for ClusterIP in this PR in the future.
Member
Author
There was a problem hiding this comment.
Previous releases had windows route issue, so better to merge this one before #3889 to make backport easier.
Contributor
|
/test-all |
When proxyAll is enabled, AntreaProxy needs to install routes in the host network namespace to redirect traffic to OVS for load balancing. For a Service with multiple ports, multiple ServicePorts are generated and processed. The previous code installed the route for a ClusterIP or a LoadBalancerIP multiple times when such a Service was created, and uninstalled the route multiple times when it was deleted, leading to a few problems. This patch adds a serviceIPRouteReferences which tracks the references of Service IPs' routes. The key is the Service IP and the value is the the set of ServiceInfo strings. With the references, we install a route exactly once as long as it's used by any ServicePorts and uninstall it exactly once when it's no longer used by any ServicePorts. This patch also fixes an issue that the route for ClusterIP was not removed on Windows Nodes after the Service was removed. Fixes antrea-io#4361 Signed-off-by: Quan Tian <qtian@vmware.com>
hongliangl
approved these changes
Mar 17, 2023
Member
Author
|
/test-all |
This was referenced Mar 24, 2023
jainpulkit22
pushed a commit
to urharshitha/antrea
that referenced
this pull request
Apr 28, 2023
…o#4711) When proxyAll is enabled, AntreaProxy needs to install routes in the host network namespace to redirect traffic to OVS for load balancing. For a Service with multiple ports, multiple ServicePorts are generated and processed. The previous code installed the route for a ClusterIP or a LoadBalancerIP multiple times when such a Service was created, and uninstalled the route multiple times when it was deleted, leading to a few problems. This patch adds a serviceIPRouteReferences which tracks the references of Service IPs' routes. The key is the Service IP and the value is the the set of ServiceInfo strings. With the references, we install a route exactly once as long as it's used by any ServicePorts and uninstall it exactly once when it's no longer used by any ServicePorts. This patch also fixes an issue that the route for ClusterIP was not removed on Windows Nodes after the Service was removed. Fixes antrea-io#4361 Signed-off-by: Quan Tian <qtian@vmware.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When proxyAll is enabled, AntreaProxy needs to install routes in the host network namespace to redirect traffic to OVS for load balancing. For a Service with multiple ports, multiple ServicePorts are generated and processed. The previous code installed the route for a ClusterIP or a LoadBalancerIP multiple times when such a Service was created, and uninstalled the route multiple times when it was deleted, leading to a few problems.
This patch adds a serviceIPRouteReferences which tracks the references of Service IPs' routes. The key is the Service IP and the value is the the set of ServiceInfo strings. With the references, we install a route exactly once as long as it's used by any ServicePorts and uninstall it exactly once when it's no longer used by any ServicePorts.
This patch also fixes an issue that the route for ClusterIP was not removed on Windows Nodes after the Service was removed.
The patch also makes shared LoadBalancerIP work correctly.
Fixes #4361