mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
remove secondary client retries in e2e tests
This commit is contained in:
parent
4bbf4111e2
commit
64c099d670
@ -23,6 +23,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/onsi/ginkgo"
|
||||||
|
"github.com/onsi/gomega"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
@ -39,10 +41,6 @@ import (
|
|||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
||||||
e2eresource "k8s.io/kubernetes/test/e2e/framework/resource"
|
e2eresource "k8s.io/kubernetes/test/e2e/framework/resource"
|
||||||
testutils "k8s.io/kubernetes/test/utils"
|
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
|
||||||
"github.com/onsi/gomega"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -69,9 +67,6 @@ func updateDaemonSetWithRetries(c clientset.Interface, namespace, name string, a
|
|||||||
var updateErr error
|
var updateErr error
|
||||||
pollErr := wait.PollImmediate(10*time.Millisecond, 1*time.Minute, func() (bool, error) {
|
pollErr := wait.PollImmediate(10*time.Millisecond, 1*time.Minute, func() (bool, error) {
|
||||||
if ds, err = daemonsets.Get(context.TODO(), name, metav1.GetOptions{}); err != nil {
|
if ds, err = daemonsets.Get(context.TODO(), name, metav1.GetOptions{}); err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
// Apply the update, then attempt to push it to the apiserver.
|
// Apply the update, then attempt to push it to the apiserver.
|
||||||
|
@ -34,7 +34,6 @@ import (
|
|||||||
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
|
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
|
||||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||||
e2essh "k8s.io/kubernetes/test/e2e/framework/ssh"
|
e2essh "k8s.io/kubernetes/test/e2e/framework/ssh"
|
||||||
testutils "k8s.io/kubernetes/test/utils"
|
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
@ -391,7 +390,7 @@ func waitForServiceWithSelector(c clientset.Interface, namespace string, selecto
|
|||||||
case len(services.Items) == 0:
|
case len(services.Items) == 0:
|
||||||
framework.Logf("Service with %s in namespace %s disappeared.", selector.String(), namespace)
|
framework.Logf("Service with %s in namespace %s disappeared.", selector.String(), namespace)
|
||||||
return !exist, nil
|
return !exist, nil
|
||||||
case !testutils.IsRetryableAPIError(err):
|
case err != nil:
|
||||||
framework.Logf("Non-retryable failure while listing service.")
|
framework.Logf("Non-retryable failure while listing service.")
|
||||||
return false, err
|
return false, err
|
||||||
default:
|
default:
|
||||||
|
@ -193,9 +193,6 @@ func waitForDaemonSets(c clientset.Interface, ns string, allowedNotReadyNodes in
|
|||||||
dsList, err := c.AppsV1().DaemonSets(ns).List(context.TODO(), metav1.ListOptions{})
|
dsList, err := c.AppsV1().DaemonSets(ns).List(context.TODO(), metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Logf("Error getting daemonsets in namespace: '%s': %v", ns, err)
|
framework.Logf("Error getting daemonsets in namespace: '%s': %v", ns, err)
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
var notReadyDaemonSets []string
|
var notReadyDaemonSets []string
|
||||||
|
@ -732,9 +732,6 @@ func (j *TestJig) WaitForIngressAddress(c clientset.Interface, ns, ingName strin
|
|||||||
ipOrNameList, err := getIngressAddress(c, ns, ingName, j.Class)
|
ipOrNameList, err := getIngressAddress(c, ns, ingName, j.Class)
|
||||||
if err != nil || len(ipOrNameList) == 0 {
|
if err != nil || len(ipOrNameList) == 0 {
|
||||||
j.Logger.Errorf("Waiting for Ingress %s/%s to acquire IP, error: %v, ipOrNameList: %v", ns, ingName, err, ipOrNameList)
|
j.Logger.Errorf("Waiting for Ingress %s/%s to acquire IP, error: %v, ipOrNameList: %v", ns, ingName, err, ipOrNameList)
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
address = ipOrNameList[0]
|
address = ipOrNameList[0]
|
||||||
@ -892,9 +889,6 @@ func getPortURL(client clientset.Interface, ns, name string, svcPort int) (strin
|
|||||||
"spec.unschedulable": "false",
|
"spec.unschedulable": "false",
|
||||||
}.AsSelector().String()})
|
}.AsSelector().String()})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -22,7 +22,6 @@ go_library(
|
|||||||
"//test/e2e/framework/pod:go_default_library",
|
"//test/e2e/framework/pod:go_default_library",
|
||||||
"//test/e2e/framework/skipper:go_default_library",
|
"//test/e2e/framework/skipper:go_default_library",
|
||||||
"//test/e2e/framework/ssh:go_default_library",
|
"//test/e2e/framework/ssh:go_default_library",
|
||||||
"//test/utils:go_default_library",
|
|
||||||
"//test/utils/image:go_default_library",
|
"//test/utils/image:go_default_library",
|
||||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -44,7 +44,6 @@ import (
|
|||||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
|
||||||
e2essh "k8s.io/kubernetes/test/e2e/framework/ssh"
|
e2essh "k8s.io/kubernetes/test/e2e/framework/ssh"
|
||||||
testutils "k8s.io/kubernetes/test/utils"
|
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1050,7 +1049,7 @@ func WaitForService(c clientset.Interface, namespace, name string, exist bool, i
|
|||||||
case apierrors.IsNotFound(err):
|
case apierrors.IsNotFound(err):
|
||||||
framework.Logf("Service %s in namespace %s disappeared.", name, namespace)
|
framework.Logf("Service %s in namespace %s disappeared.", name, namespace)
|
||||||
return !exist, nil
|
return !exist, nil
|
||||||
case !testutils.IsRetryableAPIError(err):
|
case err != nil:
|
||||||
framework.Logf("Non-retryable failure while getting service.")
|
framework.Logf("Non-retryable failure while getting service.")
|
||||||
return false, err
|
return false, err
|
||||||
default:
|
default:
|
||||||
|
@ -24,7 +24,6 @@ go_library(
|
|||||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/util/retry:go_default_library",
|
"//staging/src/k8s.io/client-go/util/retry:go_default_library",
|
||||||
"//test/e2e/framework/log:go_default_library",
|
"//test/e2e/framework/log:go_default_library",
|
||||||
"//test/utils:go_default_library",
|
|
||||||
"//test/utils/image:go_default_library",
|
"//test/utils/image:go_default_library",
|
||||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||||
@ -38,7 +37,6 @@ go_test(
|
|||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library",
|
"//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library",
|
||||||
|
@ -28,7 +28,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
||||||
testutils "k8s.io/kubernetes/test/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const sleepTime = 20 * time.Second
|
const sleepTime = 20 * time.Second
|
||||||
@ -57,9 +56,6 @@ func WaitForTotalHealthy(c clientset.Interface, timeout time.Duration) error {
|
|||||||
// It should be OK to list unschedulable Nodes here.
|
// It should be OK to list unschedulable Nodes here.
|
||||||
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{ResourceVersion: "0"})
|
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{ResourceVersion: "0"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
for _, node := range nodes.Items {
|
for _, node := range nodes.Items {
|
||||||
@ -184,9 +180,6 @@ func waitListSchedulableNodes(c clientset.Interface) (*v1.NodeList, error) {
|
|||||||
"spec.unschedulable": "false",
|
"spec.unschedulable": "false",
|
||||||
}.AsSelector().String()})
|
}.AsSelector().String()})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
@ -219,9 +212,6 @@ func CheckReadyForTests(c clientset.Interface, nonblockingTaints string, allowed
|
|||||||
allNodes, err := c.CoreV1().Nodes().List(context.TODO(), opts)
|
allNodes, err := c.CoreV1().Nodes().List(context.TODO(), opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Logf("Unexpected error listing nodes: %v", err)
|
e2elog.Logf("Unexpected error listing nodes: %v", err)
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
for _, node := range allNodes.Items {
|
for _, node := range allNodes.Items {
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
@ -155,10 +154,6 @@ func TestCheckReadyForTests(t *testing.T) {
|
|||||||
nodeListErr: errors.New("Forced error"),
|
nodeListErr: errors.New("Forced error"),
|
||||||
expected: false,
|
expected: false,
|
||||||
expectedErr: "Forced error",
|
expectedErr: "Forced error",
|
||||||
}, {
|
|
||||||
desc: "Retryable errors from node list are reported but still return false",
|
|
||||||
nodeListErr: apierrors.NewTimeoutError("Retryable error", 10),
|
|
||||||
expected: false,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,9 +476,6 @@ func CreateExecPodOrFail(client clientset.Interface, ns, generateName string, tw
|
|||||||
err = wait.PollImmediate(poll, 5*time.Minute, func() (bool, error) {
|
err = wait.PollImmediate(poll, 5*time.Minute, func() (bool, error) {
|
||||||
retrievedPod, err := client.CoreV1().Pods(execPod.Namespace).Get(context.TODO(), execPod.Name, metav1.GetOptions{})
|
retrievedPod, err := client.CoreV1().Pods(execPod.Namespace).Get(context.TODO(), execPod.Name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return retrievedPod.Status.Phase == v1.PodRunning, nil
|
return retrievedPod.Status.Phase == v1.PodRunning, nil
|
||||||
|
@ -128,9 +128,6 @@ func WaitForPodsRunningReady(c clientset.Interface, ns string, minPods, allowedN
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Logf("Error getting replication controllers in namespace '%s': %v", ns, err)
|
e2elog.Logf("Error getting replication controllers in namespace '%s': %v", ns, err)
|
||||||
lastAPIError = err
|
lastAPIError = err
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
for _, rc := range rcList.Items {
|
for _, rc := range rcList.Items {
|
||||||
@ -142,9 +139,6 @@ func WaitForPodsRunningReady(c clientset.Interface, ns string, minPods, allowedN
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
lastAPIError = err
|
lastAPIError = err
|
||||||
e2elog.Logf("Error getting replication sets in namespace %q: %v", ns, err)
|
e2elog.Logf("Error getting replication sets in namespace %q: %v", ns, err)
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
for _, rs := range rsList.Items {
|
for _, rs := range rsList.Items {
|
||||||
@ -156,9 +150,6 @@ func WaitForPodsRunningReady(c clientset.Interface, ns string, minPods, allowedN
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
lastAPIError = err
|
lastAPIError = err
|
||||||
e2elog.Logf("Error getting pods in namespace '%s': %v", ns, err)
|
e2elog.Logf("Error getting pods in namespace '%s': %v", ns, err)
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
nOk := int32(0)
|
nOk := int32(0)
|
||||||
@ -406,9 +397,6 @@ func WaitForPodToDisappear(c clientset.Interface, ns, podName string, label labe
|
|||||||
options := metav1.ListOptions{LabelSelector: label.String()}
|
options := metav1.ListOptions{LabelSelector: label.String()}
|
||||||
pods, err := c.CoreV1().Pods(ns).List(context.TODO(), options)
|
pods, err := c.CoreV1().Pods(ns).List(context.TODO(), options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
found := false
|
found := false
|
||||||
@ -459,9 +447,6 @@ func WaitForPodsWithLabel(c clientset.Interface, ns string, label labels.Selecto
|
|||||||
options := metav1.ListOptions{LabelSelector: label.String()}
|
options := metav1.ListOptions{LabelSelector: label.String()}
|
||||||
pods, err = c.CoreV1().Pods(ns).List(context.TODO(), options)
|
pods, err = c.CoreV1().Pods(ns).List(context.TODO(), options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(pods.Items) > 0 {
|
if len(pods.Items) > 0 {
|
||||||
@ -483,9 +468,6 @@ func WaitForPodsWithLabelRunningReady(c clientset.Interface, ns string, label la
|
|||||||
pods, err = WaitForPodsWithLabel(c, ns, label)
|
pods, err = WaitForPodsWithLabel(c, ns, label)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Logf("Failed to list pods: %v", err)
|
e2elog.Logf("Failed to list pods: %v", err)
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
current = 0
|
current = 0
|
||||||
|
@ -12,7 +12,6 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||||
"//test/e2e/framework/log:go_default_library",
|
"//test/e2e/framework/log:go_default_library",
|
||||||
"//test/utils:go_default_library",
|
|
||||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||||
"//vendor/golang.org/x/crypto/ssh:go_default_library",
|
"//vendor/golang.org/x/crypto/ssh:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -36,7 +36,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
||||||
testutils "k8s.io/kubernetes/test/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -393,9 +392,6 @@ func waitListSchedulableNodes(c clientset.Interface) (*v1.NodeList, error) {
|
|||||||
"spec.unschedulable": "false",
|
"spec.unschedulable": "false",
|
||||||
}.AsSelector().String()})
|
}.AsSelector().String()})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -1121,9 +1121,6 @@ func AllNodesReady(c clientset.Interface, timeout time.Duration) error {
|
|||||||
// It should be OK to list unschedulable Nodes here.
|
// It should be OK to list unschedulable Nodes here.
|
||||||
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
|
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
for i := range nodes.Items {
|
for i := range nodes.Items {
|
||||||
|
@ -70,9 +70,6 @@ func addOrUpdateAvoidPodOnNode(c clientset.Interface, nodeName string, avoidPods
|
|||||||
err := wait.PollImmediate(framework.Poll, framework.SingleCallTimeout, func() (bool, error) {
|
err := wait.PollImmediate(framework.Poll, framework.SingleCallTimeout, func() (bool, error) {
|
||||||
node, err := c.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
|
node, err := c.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,9 +99,6 @@ func removeAvoidPodsOffNode(c clientset.Interface, nodeName string) {
|
|||||||
err := wait.PollImmediate(framework.Poll, framework.SingleCallTimeout, func() (bool, error) {
|
err := wait.PollImmediate(framework.Poll, framework.SingleCallTimeout, func() (bool, error) {
|
||||||
node, err := c.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
|
node, err := c.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ package framework
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
@ -90,7 +90,7 @@ func (p *IntegrationTestNodePreparer) PrepareNodes(nextNodeIndex int) error {
|
|||||||
var err error
|
var err error
|
||||||
for retry := 0; retry < retries; retry++ {
|
for retry := 0; retry < retries; retry++ {
|
||||||
_, err = p.client.CoreV1().Nodes().Create(context.TODO(), baseNode, metav1.CreateOptions{})
|
_, err = p.client.CoreV1().Nodes().Create(context.TODO(), baseNode, metav1.CreateOptions{})
|
||||||
if err == nil || !testutils.IsRetryableAPIError(err) {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
@ -34,7 +34,6 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
|
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
|
||||||
nodectlr "k8s.io/kubernetes/pkg/controller/nodelifecycle"
|
nodectlr "k8s.io/kubernetes/pkg/controller/nodelifecycle"
|
||||||
testutils "k8s.io/kubernetes/test/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -101,9 +100,6 @@ func waitListSchedulableNodes(c clientset.Interface) (*v1.NodeList, error) {
|
|||||||
"spec.unschedulable": "false",
|
"spec.unschedulable": "false",
|
||||||
}.AsSelector().String()})
|
}.AsSelector().String()})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if testutils.IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -49,7 +49,6 @@ go_library(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/json:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/json:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
|
||||||
|
@ -27,10 +27,9 @@ import (
|
|||||||
batch "k8s.io/api/batch/v1"
|
batch "k8s.io/api/batch/v1"
|
||||||
storage "k8s.io/api/storage/v1"
|
storage "k8s.io/api/storage/v1"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
)
|
)
|
||||||
@ -54,19 +53,6 @@ func RetryWithExponentialBackOff(fn wait.ConditionFunc) error {
|
|||||||
return wait.ExponentialBackoff(backoff, fn)
|
return wait.ExponentialBackoff(backoff, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsRetryableAPIError(err error) bool {
|
|
||||||
// These errors may indicate a transient error that we can retry in tests.
|
|
||||||
if apierrors.IsInternalError(err) || apierrors.IsTimeout(err) || apierrors.IsServerTimeout(err) ||
|
|
||||||
apierrors.IsTooManyRequests(err) || utilnet.IsProbableEOF(err) || utilnet.IsConnectionReset(err) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
// If the error sends the Retry-After header, we respect it as an explicit confirmation we should retry.
|
|
||||||
if _, shouldRetry := apierrors.SuggestsClientDelay(err); shouldRetry {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreatePodWithRetries(c clientset.Interface, namespace string, obj *v1.Pod) error {
|
func CreatePodWithRetries(c clientset.Interface, namespace string, obj *v1.Pod) error {
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
return fmt.Errorf("Object provided to create is empty")
|
return fmt.Errorf("Object provided to create is empty")
|
||||||
@ -76,9 +62,6 @@ func CreatePodWithRetries(c clientset.Interface, namespace string, obj *v1.Pod)
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -93,9 +76,6 @@ func CreateRCWithRetries(c clientset.Interface, namespace string, obj *v1.Replic
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -110,9 +90,6 @@ func CreateReplicaSetWithRetries(c clientset.Interface, namespace string, obj *a
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -127,9 +104,6 @@ func CreateDeploymentWithRetries(c clientset.Interface, namespace string, obj *a
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -144,9 +118,6 @@ func CreateDaemonSetWithRetries(c clientset.Interface, namespace string, obj *ap
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -161,9 +132,6 @@ func CreateJobWithRetries(c clientset.Interface, namespace string, obj *batch.Jo
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -178,9 +146,6 @@ func CreateSecretWithRetries(c clientset.Interface, namespace string, obj *v1.Se
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -195,9 +160,6 @@ func CreateConfigMapWithRetries(c clientset.Interface, namespace string, obj *v1
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -212,9 +174,6 @@ func CreateServiceWithRetries(c clientset.Interface, namespace string, obj *v1.S
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -229,9 +188,6 @@ func CreateStorageClassWithRetries(c clientset.Interface, obj *storage.StorageCl
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -246,9 +202,6 @@ func CreateResourceQuotaWithRetries(c clientset.Interface, namespace string, obj
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -263,9 +216,6 @@ func CreatePersistentVolumeWithRetries(c clientset.Interface, obj *v1.Persistent
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
@ -280,9 +230,6 @@ func CreatePersistentVolumeClaimWithRetries(c clientset.Interface, namespace str
|
|||||||
if err == nil || apierrors.IsAlreadyExists(err) {
|
if err == nil || apierrors.IsAlreadyExists(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to create object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(createFunc)
|
return RetryWithExponentialBackOff(createFunc)
|
||||||
|
@ -63,9 +63,6 @@ func DeleteResourceWithRetries(c clientset.Interface, kind schema.GroupKind, nam
|
|||||||
if err == nil || apierrors.IsNotFound(err) {
|
if err == nil || apierrors.IsNotFound(err) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
if IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return false, fmt.Errorf("Failed to delete object with non-retriable error: %v", err)
|
return false, fmt.Errorf("Failed to delete object with non-retriable error: %v", err)
|
||||||
}
|
}
|
||||||
return RetryWithExponentialBackOff(deleteFunc)
|
return RetryWithExponentialBackOff(deleteFunc)
|
||||||
|
@ -38,9 +38,6 @@ const (
|
|||||||
func RetryErrorCondition(condition wait.ConditionFunc) wait.ConditionFunc {
|
func RetryErrorCondition(condition wait.ConditionFunc) wait.ConditionFunc {
|
||||||
return func() (bool, error) {
|
return func() (bool, error) {
|
||||||
done, err := condition()
|
done, err := condition()
|
||||||
if err != nil && IsRetryableAPIError(err) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return done, err
|
return done, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user