Skip to content
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

[release-4.17] SDN-4930: Don't modify pod routes in tests #29250

Open
wants to merge 1 commit into
base: release-4.17
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions test/extended/networking/network_segmentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,34 +287,6 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User
//By("checking non-kubelet default network host process can't reach the UDN pod")

By("asserting UDN pod can't reach host via default network interface")
// tweak pod route to use default network interface as default
podAnno, err := unmarshalPodAnnotation(udnPod.Annotations, "default")
Expect(err).NotTo(HaveOccurred())
for _, podIP := range podAnno.IPs {
ipCommand := []string{"exec", udnPod.Name, "--", "ip"}
if podIP.IP.To4() == nil {
ipCommand = append(ipCommand, "-6")
}
// 1. Find current default route and delete it
defRoute, err := e2ekubectl.RunKubectl(udnPod.Namespace,
append(ipCommand, "route", "show", "default")...)
Expect(err).NotTo(HaveOccurred())
defRoute = strings.TrimSpace(defRoute)
if defRoute == "" {
continue
}
framework.Logf("Found default route %v, deleting", defRoute)
cmd := append(ipCommand, "route", "del")
_, err = e2ekubectl.RunKubectl(udnPod.Namespace,
append(cmd, strings.Split(defRoute, " ")...)...)
Expect(err).NotTo(HaveOccurred())

// 2. Add a new default route to use default network interface
gatewayIP := NextIP(Network(podIP).IP)
_, err = e2ekubectl.RunKubectl(udnPod.Namespace,
append(ipCommand, "route", "add", "default", "via", gatewayIP.String(), "dev", "eth0")...)
Expect(err).NotTo(HaveOccurred())
}
// Now try to reach the host from the UDN pod
defaultPodHostIP := udnPod.Status.HostIPs
for _, hostIP := range defaultPodHostIP {
Expand All @@ -325,7 +297,7 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User
}
Consistently(func() bool {
_, err := e2ekubectl.RunKubectl(udnPod.Namespace, "exec", udnPod.Name, "--",
ping, "-c", "1", "-W", "1", hostIP.IP,
ping, "-I", "eth0", "-c", "1", "-W", "1", hostIP.IP,
)
return err == nil
}, 4*time.Second).Should(BeFalse())
Expand Down