@@ -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-
403384func 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