Skip to content

Commit

Permalink
Fix test failure of ServiceExternalIP with LoadBalancerModeDSR
Browse files Browse the repository at this point in the history
Fixes: antrea-io#6992

Signed-off-by: Xu Liu <[email protected]>
  • Loading branch information
xliuxu committed Feb 13, 2025
1 parent 1ee108b commit 929ca8b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/e2e/service_externalip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,26 @@ func testExternalIPAccess(t *testing.T, data *TestData) {
externalIP, host, err := waitExternalIPConfigured(service)
require.NoError(t, err)

// A route to the client IP is required for DSR mode.
nodeInfo := getNodeByName(host)
workerNodeIP := clusterInfo.nodes[nodeInfo.idx].ip()
addRouteToClientIPCmd := []string{"ip", "route", "replace", tt.clientIP, "via", workerNodeIP}
delRouteToClientIPCmd := []string{"ip", "route", "del", tt.clientIP, "via", workerNodeIP}

for idx := range nodes {
node := nodes[idx]
if node == host {
continue
}
stdout, stderr, err := data.RunCommandFromAntreaPodOnNode(node, addRouteToClientIPCmd)
require.NoError(t, err, "Failed to add route to client IP on Node %s, stdout: %s, stderr: %s: cmd: %q", node, stdout, stderr, addRouteToClientIPCmd)

defer func() {
stdout, stderr, err := data.RunCommandFromAntreaPodOnNode(node, delRouteToClientIPCmd)
assert.NoError(t, err, "Failed to delete route to client IP on Node %s, stdout: %s, stderr: %s", node, stdout, stderr)
}()
}

// Create a pod in a different netns with the same subnet of the external IP to mock as another Node in the same subnet.
cmd, netns := getCommandInFakeExternalNetwork("sleep 3600", tt.clientIPMaskLen, tt.clientIP, tt.localIP)

Expand Down

0 comments on commit 929ca8b

Please sign in to comment.