Skip to content

Commit def2909

Browse files
committed
Revert "e2e: connect to host-networked pod from localnet"
This reverts commit b1525c3. Signed-off-by: Surya Seetharaman <[email protected]> (cherry picked from commit 936e621)
1 parent b3760a1 commit def2909

File tree

2 files changed

+17
-95
lines changed

2 files changed

+17
-95
lines changed

test/e2e/multihoming.go

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -331,31 +331,17 @@ var _ = Describe("Multi Homing", func() {
331331
kickstartPod(cs, clientPodConfig)
332332

333333
// Check that the client pod can reach the server pod on the server localnet interface
334-
var serverIPs []string
335-
if serverPodConfig.hostNetwork {
336-
serverIPs, err = podIPsFromStatus(cs, serverPodConfig.namespace, serverPodConfig.name)
337-
} else {
338-
serverIPs, err = podIPsForAttachment(cs, serverPod.Namespace, serverPod.Name, netConfig.name)
339-
340-
}
334+
serverIPs, err := podIPsForAttachment(cs, f.Namespace.Name, serverPod.GetName(), netConfig.name)
341335
Expect(err).NotTo(HaveOccurred())
342-
343336
for _, serverIP := range serverIPs {
344337
By(fmt.Sprintf("asserting the *client* can contact the server pod exposed endpoint: %q on port %q", serverIP, port))
345-
curlArgs := []string{}
346-
pingArgs := []string{}
347-
if clientPodConfig.attachments != nil {
348-
// When the client is attached to a localnet, send probes from the localnet interface
349-
curlArgs = []string{"--interface", "net1"}
350-
pingArgs = []string{"-I", "net1"}
351-
}
352338
Eventually(func() error {
353-
return reachServerPodFromClient(cs, serverPodConfig, clientPodConfig, serverIP, port, curlArgs...)
339+
return reachServerPodFromClient(cs, serverPodConfig, clientPodConfig, serverIP, port)
354340
}, 2*time.Minute, 6*time.Second).Should(Succeed())
355341

356342
By(fmt.Sprintf("asserting the *client* can ping the server pod exposed endpoint: %q", serverIP))
357343
Eventually(func() error {
358-
return pingServerPodFromClient(cs, serverPodConfig, clientPodConfig, serverIP, pingArgs...)
344+
return pingServerPodFromClient(cs, serverPodConfig, clientPodConfig, serverIP)
359345
}, 2*time.Minute, 6*time.Second).Should(Succeed())
360346
}
361347
},
@@ -403,52 +389,6 @@ var _ = Describe("Multi Homing", func() {
403389
},
404390
Label("BUG", "OCPBUGS-43004"),
405391
),
406-
ginkgo.Entry(
407-
"can reach a host-networked pod on a different node",
408-
networkAttachmentConfigParams{
409-
name: secondaryNetworkName,
410-
topology: "localnet",
411-
},
412-
podConfiguration{ // client on localnet
413-
attachments: []nadapi.NetworkSelectionElement{{
414-
Name: secondaryNetworkName,
415-
}},
416-
name: clientPodName,
417-
nodeSelector: map[string]string{nodeHostnameKey: workerOneNodeName},
418-
isPrivileged: true,
419-
needsIPRequestFromHostSubnet: true,
420-
},
421-
podConfiguration{ // server on default network, pod is host-networked
422-
name: podName,
423-
containerCmd: httpServerContainerCmd(port),
424-
nodeSelector: map[string]string{nodeHostnameKey: workerTwoNodeName},
425-
hostNetwork: true,
426-
},
427-
Label("STORY", "SDN-5345"),
428-
),
429-
ginkgo.Entry(
430-
"can reach a host-networked pod on the same node",
431-
networkAttachmentConfigParams{
432-
name: secondaryNetworkName,
433-
topology: "localnet",
434-
},
435-
podConfiguration{ // client on localnet
436-
attachments: []nadapi.NetworkSelectionElement{{
437-
Name: secondaryNetworkName,
438-
}},
439-
name: clientPodName,
440-
nodeSelector: map[string]string{nodeHostnameKey: workerTwoNodeName},
441-
isPrivileged: true,
442-
needsIPRequestFromHostSubnet: true,
443-
},
444-
podConfiguration{ // server on default network, pod is host-networked
445-
name: podName,
446-
containerCmd: httpServerContainerCmd(port),
447-
nodeSelector: map[string]string{nodeHostnameKey: workerTwoNodeName},
448-
hostNetwork: true,
449-
},
450-
Label("STORY", "SDN-5345"),
451-
),
452392
)
453393
})
454394

@@ -908,6 +848,7 @@ var _ = Describe("Multi Homing", func() {
908848
Context("localnet OVN-K secondary network", func() {
909849
const (
910850
clientPodName = "client-pod"
851+
nodeHostnameKey = "kubernetes.io/hostname"
911852
servicePort = 9000
912853
dockerNetworkName = "underlay"
913854
underlayServiceIP = "60.128.0.1"

test/e2e/multihoming_utils.go

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ type podConfiguration struct {
161161
isPrivileged bool
162162
labels map[string]string
163163
requiresExtraNamespace bool
164-
hostNetwork bool
165164
needsIPRequestFromHostSubnet bool
166165
}
167166

@@ -172,7 +171,6 @@ func generatePodSpec(config podConfiguration) *v1.Pod {
172171
}
173172
podSpec.Spec.NodeSelector = config.nodeSelector
174173
podSpec.Labels = config.labels
175-
podSpec.Spec.HostNetwork = config.hostNetwork
176174
if config.isPrivileged {
177175
podSpec.Spec.Containers[0].SecurityContext.Privileged = ptr.To(true)
178176
} else {
@@ -255,19 +253,17 @@ func inRange(cidr string, ip string) error {
255253
return fmt.Errorf("ip [%s] is NOT in range %s", ip, cidr)
256254
}
257255

258-
func connectToServer(clientPodConfig podConfiguration, serverIP string, port int, args ...string) error {
259-
target := net.JoinHostPort(serverIP, fmt.Sprintf("%d", port))
260-
baseArgs := []string{
256+
func connectToServer(clientPodConfig podConfiguration, serverIP string, port int) error {
257+
_, err := e2ekubectl.RunKubectl(
258+
clientPodConfig.namespace,
261259
"exec",
262260
clientPodConfig.name,
263261
"--",
264262
"curl",
265263
"--connect-timeout",
266264
"2",
267-
}
268-
baseArgs = append(baseArgs, args...)
269-
270-
_, err := e2ekubectl.RunKubectl(clientPodConfig.namespace, append(baseArgs, target)...)
265+
net.JoinHostPort(serverIP, fmt.Sprintf("%d", port)),
266+
)
271267
return err
272268
}
273269

@@ -312,19 +308,16 @@ func getSecondaryInterfaceMTU(clientPodConfig podConfiguration) (int, error) {
312308
return mtu, nil
313309
}
314310

315-
func pingServer(clientPodConfig podConfiguration, serverIP string, args ...string) error {
316-
baseArgs := []string{
311+
func pingServer(clientPodConfig podConfiguration, serverIP string) error {
312+
_, err := e2ekubectl.RunKubectl(
313+
clientPodConfig.namespace,
317314
"exec",
318315
clientPodConfig.name,
319316
"--",
320317
"ping",
321318
"-c", "1", // send one ICMP echo request
322319
"-W", "2", // timeout after 2 seconds if no response
323-
}
324-
baseArgs = append(baseArgs, args...)
325-
326-
_, err := e2ekubectl.RunKubectl(clientPodConfig.namespace, append(baseArgs, serverIP)...)
327-
320+
serverIP)
328321
return err
329322
}
330323

@@ -388,18 +381,6 @@ func podIPForAttachment(k8sClient clientset.Interface, podNamespace string, podN
388381
return ips[ipIndex], nil
389382
}
390383

391-
func podIPsFromStatus(k8sClient clientset.Interface, podNamespace string, podName string) ([]string, error) {
392-
pod, err := k8sClient.CoreV1().Pods(podNamespace).Get(context.Background(), podName, metav1.GetOptions{})
393-
if err != nil {
394-
return nil, err
395-
}
396-
podIPs := make([]string, 0, len(pod.Status.PodIPs))
397-
for _, podIP := range pod.Status.PodIPs {
398-
podIPs = append(podIPs, podIP.IP)
399-
}
400-
return podIPs, nil
401-
}
402-
403384
func allowedClient(podName string) string {
404385
return "allowed-" + podName
405386
}
@@ -629,27 +610,27 @@ func allowedTCPPortsForPolicy(allowPorts ...int) []mnpapi.MultiNetworkPolicyPort
629610
return portAllowlist
630611
}
631612

632-
func reachServerPodFromClient(cs clientset.Interface, serverConfig podConfiguration, clientConfig podConfiguration, serverIP string, serverPort int, args ...string) error {
613+
func reachServerPodFromClient(cs clientset.Interface, serverConfig podConfiguration, clientConfig podConfiguration, serverIP string, serverPort int) error {
633614
updatedPod, err := cs.CoreV1().Pods(serverConfig.namespace).Get(context.Background(), serverConfig.name, metav1.GetOptions{})
634615
if err != nil {
635616
return err
636617
}
637618

638619
if updatedPod.Status.Phase == v1.PodRunning {
639-
return connectToServer(clientConfig, serverIP, serverPort, args...)
620+
return connectToServer(clientConfig, serverIP, serverPort)
640621
}
641622

642623
return fmt.Errorf("pod not running. /me is sad")
643624
}
644625

645-
func pingServerPodFromClient(cs clientset.Interface, serverConfig podConfiguration, clientConfig podConfiguration, serverIP string, args ...string) error {
626+
func pingServerPodFromClient(cs clientset.Interface, serverConfig podConfiguration, clientConfig podConfiguration, serverIP string) error {
646627
updatedPod, err := cs.CoreV1().Pods(serverConfig.namespace).Get(context.Background(), serverConfig.name, metav1.GetOptions{})
647628
if err != nil {
648629
return err
649630
}
650631

651632
if updatedPod.Status.Phase == v1.PodRunning {
652-
return pingServer(clientConfig, serverIP, args...)
633+
return pingServer(clientConfig, serverIP)
653634
}
654635

655636
return fmt.Errorf("pod not running. /me is sad")

0 commit comments

Comments
 (0)