mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	clean up and fix nits
This commit is contained in:
		@@ -131,94 +131,56 @@ var _ = SIGDescribe("[Feature:IPv6DualStackAlphaFeature] [LinuxOnly]", func() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		replicas := int32(len(nodeList.Items))
 | 
							replicas := int32(len(nodeList.Items))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							serverDeploymentSpec := e2edeploy.NewDeployment(serverDeploymentName,
 | 
				
			||||||
 | 
								replicas,
 | 
				
			||||||
 | 
								map[string]string{"test": "dual-stack-server"},
 | 
				
			||||||
 | 
								"dualstack-test-server",
 | 
				
			||||||
 | 
								imageutils.GetE2EImage(imageutils.TestWebserver),
 | 
				
			||||||
 | 
								apps.RollingUpdateDeploymentStrategyType)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// to ensure all the pods land on different nodes and we can thereby
 | 
							// to ensure all the pods land on different nodes and we can thereby
 | 
				
			||||||
		// validate connectivity across all nodes.
 | 
							// validate connectivity across all nodes.
 | 
				
			||||||
		serverDeploymentSpec := &apps.Deployment{
 | 
							serverDeploymentSpec.Spec.Template.Spec.Affinity = &v1.Affinity{
 | 
				
			||||||
			ObjectMeta: metav1.ObjectMeta{
 | 
								PodAntiAffinity: &v1.PodAntiAffinity{
 | 
				
			||||||
				Name:   serverDeploymentName,
 | 
									RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{
 | 
				
			||||||
				Labels: map[string]string{"test": "dualstack-test-server"},
 | 
										{
 | 
				
			||||||
			},
 | 
											LabelSelector: &metav1.LabelSelector{
 | 
				
			||||||
			Spec: apps.DeploymentSpec{
 | 
												MatchExpressions: []metav1.LabelSelectorRequirement{
 | 
				
			||||||
				Replicas: &replicas,
 | 
													{
 | 
				
			||||||
				Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"test": "dualstack-test-server"}},
 | 
														Key:      "test",
 | 
				
			||||||
				Strategy: apps.DeploymentStrategy{
 | 
														Operator: metav1.LabelSelectorOpIn,
 | 
				
			||||||
					Type: apps.RollingUpdateDeploymentStrategyType,
 | 
														Values:   []string{"dualstack-test-server"},
 | 
				
			||||||
				},
 | 
					 | 
				
			||||||
				Template: v1.PodTemplateSpec{
 | 
					 | 
				
			||||||
					ObjectMeta: metav1.ObjectMeta{
 | 
					 | 
				
			||||||
						Labels: map[string]string{"test": "dualstack-test-server"},
 | 
					 | 
				
			||||||
					},
 | 
					 | 
				
			||||||
					Spec: v1.PodSpec{
 | 
					 | 
				
			||||||
						Containers: []v1.Container{
 | 
					 | 
				
			||||||
							{
 | 
					 | 
				
			||||||
								Name:  "dualstack-test-server",
 | 
					 | 
				
			||||||
								Image: imageutils.GetE2EImage(imageutils.TestWebserver),
 | 
					 | 
				
			||||||
							},
 | 
					 | 
				
			||||||
						},
 | 
					 | 
				
			||||||
						Affinity: &v1.Affinity{
 | 
					 | 
				
			||||||
							PodAntiAffinity: &v1.PodAntiAffinity{
 | 
					 | 
				
			||||||
								RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{
 | 
					 | 
				
			||||||
									{
 | 
					 | 
				
			||||||
										LabelSelector: &metav1.LabelSelector{
 | 
					 | 
				
			||||||
											MatchExpressions: []metav1.LabelSelectorRequirement{
 | 
					 | 
				
			||||||
												{
 | 
					 | 
				
			||||||
													Key:      "test",
 | 
					 | 
				
			||||||
													Operator: metav1.LabelSelectorOpIn,
 | 
					 | 
				
			||||||
													Values:   []string{"dualstack-test-server"},
 | 
					 | 
				
			||||||
												},
 | 
					 | 
				
			||||||
											},
 | 
					 | 
				
			||||||
										},
 | 
					 | 
				
			||||||
										TopologyKey: "kubernetes.io/hostname",
 | 
					 | 
				
			||||||
									},
 | 
					 | 
				
			||||||
								},
 | 
													},
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
						},
 | 
											},
 | 
				
			||||||
 | 
											TopologyKey: "kubernetes.io/hostname",
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		clientDeploymentSpec := &apps.Deployment{
 | 
							clientDeploymentSpec := e2edeploy.NewDeployment(clientDeploymentName,
 | 
				
			||||||
			ObjectMeta: metav1.ObjectMeta{
 | 
								replicas,
 | 
				
			||||||
				Name:   clientDeploymentName,
 | 
								map[string]string{"test": "dual-stack-client"},
 | 
				
			||||||
				Labels: map[string]string{"test": "dualstack-test-client"},
 | 
								"dualstack-test-client",
 | 
				
			||||||
			},
 | 
								imageutils.GetE2EImage(imageutils.Agnhost),
 | 
				
			||||||
			Spec: apps.DeploymentSpec{
 | 
								apps.RollingUpdateDeploymentStrategyType)
 | 
				
			||||||
				Replicas: &replicas,
 | 
					
 | 
				
			||||||
				Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"test": "dualstack-test-client"}},
 | 
							clientDeploymentSpec.Spec.Template.Spec.Containers[0].Command = []string{"sleep", "3600"}
 | 
				
			||||||
				Strategy: apps.DeploymentStrategy{
 | 
							clientDeploymentSpec.Spec.Template.Spec.Affinity = &v1.Affinity{
 | 
				
			||||||
					Type: apps.RollingUpdateDeploymentStrategyType,
 | 
								PodAntiAffinity: &v1.PodAntiAffinity{
 | 
				
			||||||
				},
 | 
									RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{
 | 
				
			||||||
				Template: v1.PodTemplateSpec{
 | 
										{
 | 
				
			||||||
					ObjectMeta: metav1.ObjectMeta{
 | 
											LabelSelector: &metav1.LabelSelector{
 | 
				
			||||||
						Labels: map[string]string{"test": "dualstack-test-client"},
 | 
												MatchExpressions: []metav1.LabelSelectorRequirement{
 | 
				
			||||||
					},
 | 
													{
 | 
				
			||||||
					Spec: v1.PodSpec{
 | 
														Key:      "test",
 | 
				
			||||||
						Containers: []v1.Container{
 | 
														Operator: metav1.LabelSelectorOpIn,
 | 
				
			||||||
							{
 | 
														Values:   []string{"dualstack-test-client"},
 | 
				
			||||||
								Name:    "dualstack-test-client",
 | 
					 | 
				
			||||||
								Image:   imageutils.GetE2EImage(imageutils.Agnhost),
 | 
					 | 
				
			||||||
								Command: []string{"sleep", "3600"},
 | 
					 | 
				
			||||||
							},
 | 
					 | 
				
			||||||
						},
 | 
					 | 
				
			||||||
						Affinity: &v1.Affinity{
 | 
					 | 
				
			||||||
							PodAntiAffinity: &v1.PodAntiAffinity{
 | 
					 | 
				
			||||||
								RequiredDuringSchedulingIgnoredDuringExecution: []v1.PodAffinityTerm{
 | 
					 | 
				
			||||||
									{
 | 
					 | 
				
			||||||
										LabelSelector: &metav1.LabelSelector{
 | 
					 | 
				
			||||||
											MatchExpressions: []metav1.LabelSelectorRequirement{
 | 
					 | 
				
			||||||
												{
 | 
					 | 
				
			||||||
													Key:      "test",
 | 
					 | 
				
			||||||
													Operator: metav1.LabelSelectorOpIn,
 | 
					 | 
				
			||||||
													Values:   []string{"dualstack-test-client"},
 | 
					 | 
				
			||||||
												},
 | 
					 | 
				
			||||||
											},
 | 
					 | 
				
			||||||
										},
 | 
					 | 
				
			||||||
										TopologyKey: "kubernetes.io/hostname",
 | 
					 | 
				
			||||||
									},
 | 
					 | 
				
			||||||
								},
 | 
													},
 | 
				
			||||||
							},
 | 
												},
 | 
				
			||||||
						},
 | 
											},
 | 
				
			||||||
 | 
											TopologyKey: "kubernetes.io/hostname",
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@@ -241,18 +203,16 @@ var _ = SIGDescribe("[Feature:IPv6DualStackAlphaFeature] [LinuxOnly]", func() {
 | 
				
			|||||||
		clientPods, err := e2edeploy.GetPodsForDeployment(cs, clientDeployment)
 | 
							clientPods, err := e2edeploy.GetPodsForDeployment(cs, clientDeployment)
 | 
				
			||||||
		framework.ExpectNoError(err)
 | 
							framework.ExpectNoError(err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		assertNetworkConnectivity(f, *serverPods, *clientPods)
 | 
							assertNetworkConnectivity(f, *serverPods, *clientPods, "dualstack-test-client", "80")
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					func assertNetworkConnectivity(f *framework.Framework, serverPods v1.PodList, clientPods v1.PodList, containerName, port string) {
 | 
				
			||||||
	duration     = "10s"
 | 
					 | 
				
			||||||
	pollInterval = "1s"
 | 
					 | 
				
			||||||
	timeout      = 10
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func assertNetworkConnectivity(f *framework.Framework, serverPods v1.PodList, clientPods v1.PodList) {
 | 
					 | 
				
			||||||
	// curl from each client pod to all server pods to assert connectivity
 | 
						// curl from each client pod to all server pods to assert connectivity
 | 
				
			||||||
 | 
						duration := "10s"
 | 
				
			||||||
 | 
						pollInterval := "1s"
 | 
				
			||||||
 | 
						timeout := 10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var serverIPs []string
 | 
						var serverIPs []string
 | 
				
			||||||
	for _, pod := range serverPods.Items {
 | 
						for _, pod := range serverPods.Items {
 | 
				
			||||||
		if pod.Status.PodIPs == nil || len(pod.Status.PodIPs) != 2 {
 | 
							if pod.Status.PodIPs == nil || len(pod.Status.PodIPs) != 2 {
 | 
				
			||||||
@@ -267,17 +227,17 @@ func assertNetworkConnectivity(f *framework.Framework, serverPods v1.PodList, cl
 | 
				
			|||||||
	for _, clientPod := range clientPods.Items {
 | 
						for _, clientPod := range clientPods.Items {
 | 
				
			||||||
		for _, ip := range serverIPs {
 | 
							for _, ip := range serverIPs {
 | 
				
			||||||
			gomega.Consistently(func() error {
 | 
								gomega.Consistently(func() error {
 | 
				
			||||||
				ginkgo.By(fmt.Sprintf("checking connectivity from pod %s to server ip %s", clientPod.Name, ip))
 | 
									ginkgo.By(fmt.Sprintf("checking connectivity from pod %s to serverIP: %s, port: %s", clientPod.Name, ip, port))
 | 
				
			||||||
				cmd := checkNetworkConnectivity(ip, "80")
 | 
									cmd := checkNetworkConnectivity(ip, port, timeout)
 | 
				
			||||||
				_, _, err := f.ExecCommandInContainerWithFullOutput(clientPod.Name, "dualstack-test-client", cmd...)
 | 
									_, _, err := f.ExecCommandInContainerWithFullOutput(clientPod.Name, containerName, cmd...)
 | 
				
			||||||
				return err
 | 
									return err
 | 
				
			||||||
			}, duration, pollInterval).ShouldNot(gomega.HaveOccurred())
 | 
								}, duration, pollInterval).ShouldNot(gomega.HaveOccurred())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func checkNetworkConnectivity(ip, port string) []string {
 | 
					func checkNetworkConnectivity(ip, port string, timeout int) []string {
 | 
				
			||||||
	curl := fmt.Sprintf("curl -g --connect-timeout %v http://%s", 10, net.JoinHostPort(ip, port))
 | 
						curl := fmt.Sprintf("curl -g --connect-timeout %v http://%s", timeout, net.JoinHostPort(ip, port))
 | 
				
			||||||
	cmd := []string{"/bin/sh", "-c", curl}
 | 
						cmd := []string{"/bin/sh", "-c", curl}
 | 
				
			||||||
	return cmd
 | 
						return cmd
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user