mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 11:28:58 +00:00
Fix the pod startup timeout in the NoSNAT test
It was using a hardcoded timeout of 1 minute, as opposed to framework.PodStartTimeout, which is 5 minutes, which is likely the cause of some recent flakes. Also, use a helper function.
This commit is contained in:
@@ -18,15 +18,13 @@ package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
@@ -84,31 +82,12 @@ var _ = common.SIGDescribe("NoSNAT", func() {
|
||||
}
|
||||
|
||||
ginkgo.By("waiting for all of the no-snat-test pods to be scheduled and running")
|
||||
err = wait.PollImmediate(10*time.Second, 1*time.Minute, func() (bool, error) {
|
||||
pods, err := pc.List(ctx, metav1.ListOptions{LabelSelector: noSNATTestName})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// check all pods are running
|
||||
for _, pod := range pods.Items {
|
||||
if pod.Status.Phase != v1.PodRunning {
|
||||
if pod.Status.Phase != v1.PodPending {
|
||||
return false, fmt.Errorf("expected pod to be in phase \"Pending\" or \"Running\"")
|
||||
}
|
||||
return false, nil // pod is still pending
|
||||
}
|
||||
}
|
||||
return true, nil // all pods are running
|
||||
})
|
||||
pods, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, cs, f.Namespace.Name, labels.Set{noSNATTestName: ""}.AsSelector(), len(nodes.Items), framework.PodStartTimeout)
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
ginkgo.By("sending traffic from each pod to the others and checking that SNAT does not occur")
|
||||
pods, err := pc.List(ctx, metav1.ListOptions{LabelSelector: noSNATTestName})
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
// hit the /clientip endpoint on every other Pods to check if source ip is preserved
|
||||
// this test is O(n^2) but it doesn't matter because we only run this test on small clusters (~3 nodes)
|
||||
// this test is O(n^2) but it doesn't matter because we only run it on a max of 3 pods
|
||||
for _, sourcePod := range pods.Items {
|
||||
for _, targetPod := range pods.Items {
|
||||
if targetPod.Name == sourcePod.Name {
|
||||
|
||||
Reference in New Issue
Block a user