mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Merge pull request #44696 from justinsb/fix_44695
Automatic merge from submit-queue (batch tested with PRs 42272, 44696) e2e test fix: Wait longer when first creating ELB On any cloud (GCE or AWS), a lag between creating the LoadBalancer and having it actually start serving traffic is expected. On AWS the lag is larger, and we weren't correctly using the longer wait on our first request. Use a longer wait period on our first request. Fix #44695 ```release-note NONE ```
This commit is contained in:
commit
33bdec3f22
@ -594,9 +594,9 @@ func (config *NetworkingTestConfig) getNamespacesClient() coreclientset.Namespac
|
||||
return config.f.ClientSet.Core().Namespaces()
|
||||
}
|
||||
|
||||
func CheckReachabilityFromPod(expectToBeReachable bool, namespace, pod, target string) {
|
||||
func CheckReachabilityFromPod(expectToBeReachable bool, timeout time.Duration, namespace, pod, target string) {
|
||||
cmd := fmt.Sprintf("wget -T 5 -qO- %q", target)
|
||||
err := wait.PollImmediate(Poll, 2*time.Minute, func() (bool, error) {
|
||||
err := wait.PollImmediate(Poll, timeout, func() (bool, error) {
|
||||
_, err := RunHostCmd(namespace, pod, cmd)
|
||||
if expectToBeReachable && err != nil {
|
||||
Logf("Expect target to be reachable. But got err: %v. Retry until timeout", err)
|
||||
|
@ -1167,6 +1167,10 @@ var _ = framework.KubeDescribe("Services", func() {
|
||||
// this feature currently supported only on GCE/GKE/AWS
|
||||
framework.SkipUnlessProviderIs("gce", "gke", "aws")
|
||||
|
||||
loadBalancerLagTimeout := framework.LoadBalancerLagTimeoutDefault
|
||||
if framework.ProviderIs("aws") {
|
||||
loadBalancerLagTimeout = framework.LoadBalancerLagTimeoutAWS
|
||||
}
|
||||
loadBalancerCreateTimeout := framework.LoadBalancerCreateTimeoutDefault
|
||||
if nodes := framework.GetReadySchedulableNodesOrDie(cs); len(nodes.Items) > framework.LargeClusterMinNodesNumber {
|
||||
loadBalancerCreateTimeout = framework.LoadBalancerCreateTimeoutLarge
|
||||
@ -1182,7 +1186,7 @@ var _ = framework.KubeDescribe("Services", func() {
|
||||
acceptPodName := framework.CreateExecPodOrFail(cs, namespace, "execpod-accept", nil)
|
||||
dropPodName := framework.CreateExecPodOrFail(cs, namespace, "execpod-drop", nil)
|
||||
|
||||
accpetPod, err := cs.Core().Pods(namespace).Get(acceptPodName, metav1.GetOptions{})
|
||||
acceptPod, err := cs.Core().Pods(namespace).Get(acceptPodName, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
dropPod, err := cs.Core().Pods(namespace).Get(dropPodName, metav1.GetOptions{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -1194,7 +1198,7 @@ var _ = framework.KubeDescribe("Services", func() {
|
||||
// Create loadbalancer service with source range from node[0] and podAccept
|
||||
svc := jig.CreateTCPServiceOrFail(namespace, func(svc *v1.Service) {
|
||||
svc.Spec.Type = v1.ServiceTypeLoadBalancer
|
||||
svc.Spec.LoadBalancerSourceRanges = []string{accpetPod.Status.PodIP + "/32"}
|
||||
svc.Spec.LoadBalancerSourceRanges = []string{acceptPod.Status.PodIP + "/32"}
|
||||
})
|
||||
|
||||
// Clean up loadbalancer service
|
||||
@ -1209,25 +1213,30 @@ var _ = framework.KubeDescribe("Services", func() {
|
||||
svc = jig.WaitForLoadBalancerOrFail(namespace, serviceName, loadBalancerCreateTimeout)
|
||||
jig.SanityCheckService(svc, v1.ServiceTypeLoadBalancer)
|
||||
|
||||
// timeout when we haven't just created the load balancer
|
||||
normalReachabilityTimeout := 2 * time.Minute
|
||||
|
||||
By("check reachability from different sources")
|
||||
svcIP := framework.GetIngressPoint(&svc.Status.LoadBalancer.Ingress[0])
|
||||
framework.CheckReachabilityFromPod(true, namespace, acceptPodName, svcIP)
|
||||
framework.CheckReachabilityFromPod(false, namespace, dropPodName, svcIP)
|
||||
// Wait longer as this is our first request after creation. We can't check using a separate method,
|
||||
// because the LB should only be reachable from the "accept" pod
|
||||
framework.CheckReachabilityFromPod(true, loadBalancerLagTimeout, namespace, acceptPodName, svcIP)
|
||||
framework.CheckReachabilityFromPod(false, normalReachabilityTimeout, namespace, dropPodName, svcIP)
|
||||
|
||||
By("Update service LoadBalancerSourceRange and check reachability")
|
||||
jig.UpdateServiceOrFail(svc.Namespace, svc.Name, func(svc *v1.Service) {
|
||||
// only allow access from dropPod
|
||||
svc.Spec.LoadBalancerSourceRanges = []string{dropPod.Status.PodIP + "/32"}
|
||||
})
|
||||
framework.CheckReachabilityFromPod(false, namespace, acceptPodName, svcIP)
|
||||
framework.CheckReachabilityFromPod(true, namespace, dropPodName, svcIP)
|
||||
framework.CheckReachabilityFromPod(false, normalReachabilityTimeout, namespace, acceptPodName, svcIP)
|
||||
framework.CheckReachabilityFromPod(true, normalReachabilityTimeout, namespace, dropPodName, svcIP)
|
||||
|
||||
By("Delete LoadBalancerSourceRange field and check reachability")
|
||||
jig.UpdateServiceOrFail(svc.Namespace, svc.Name, func(svc *v1.Service) {
|
||||
svc.Spec.LoadBalancerSourceRanges = nil
|
||||
})
|
||||
framework.CheckReachabilityFromPod(true, namespace, acceptPodName, svcIP)
|
||||
framework.CheckReachabilityFromPod(true, namespace, dropPodName, svcIP)
|
||||
framework.CheckReachabilityFromPod(true, normalReachabilityTimeout, namespace, acceptPodName, svcIP)
|
||||
framework.CheckReachabilityFromPod(true, normalReachabilityTimeout, namespace, dropPodName, svcIP)
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user