migrate wait.PollImmediate to wait.PollUntilContextTimeout.
Signed-off-by: Lan Liang <gcslyp@gmail.com>
This commit is contained in:
parent
d4c27937c7
commit
5a4539d404
|
@ -68,9 +68,9 @@ func NewKarmadaWaiter(config *rest.Config, client clientset.Interface, timeout t
|
|||
|
||||
// WaitForAPI waits for the API Server's /healthz endpoint to report "ok"
|
||||
func (w *KarmadaWaiter) WaitForAPI() error {
|
||||
return wait.PollImmediate(APICallRetryInterval, w.timeout, func() (bool, error) {
|
||||
return wait.PollUntilContextTimeout(context.TODO(), APICallRetryInterval, w.timeout, true, func(ctx context.Context) (bool, error) {
|
||||
healthStatus := 0
|
||||
w.client.Discovery().RESTClient().Get().AbsPath("/healthz").Do(context.TODO()).StatusCode(&healthStatus)
|
||||
w.client.Discovery().RESTClient().Get().AbsPath("/healthz").Do(ctx).StatusCode(&healthStatus)
|
||||
if healthStatus != http.StatusOK {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ func (w *KarmadaWaiter) WaitForAPIService(name string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
err = wait.PollImmediate(APICallRetryInterval, w.timeout, func() (done bool, err error) {
|
||||
apiService, err := aggregateClient.ApiregistrationV1().APIServices().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
err = wait.PollUntilContextTimeout(context.TODO(), APICallRetryInterval, w.timeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
apiService, err := aggregateClient.ApiregistrationV1().APIServices().Get(ctx, name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -108,9 +108,9 @@ func (w *KarmadaWaiter) WaitForAPIService(name string) error {
|
|||
// reporting status as running.
|
||||
func (w *KarmadaWaiter) WaitForPods(label, namespace string) error {
|
||||
lastKnownPodNumber := -1
|
||||
return wait.PollImmediate(APICallRetryInterval, w.timeout, func() (bool, error) {
|
||||
return wait.PollUntilContextTimeout(context.TODO(), APICallRetryInterval, w.timeout, true, func(ctx context.Context) (bool, error) {
|
||||
listOpts := metav1.ListOptions{LabelSelector: label}
|
||||
pods, err := w.client.CoreV1().Pods(namespace).List(context.TODO(), listOpts)
|
||||
pods, err := w.client.CoreV1().Pods(namespace).List(ctx, listOpts)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -136,9 +136,9 @@ func (w *KarmadaWaiter) WaitForPods(label, namespace string) error {
|
|||
// WaitForSomePods lookup pods with the given label and wait until desired number of pods
|
||||
// reporting status as running.
|
||||
func (w *KarmadaWaiter) WaitForSomePods(label, namespace string, podNum int32) error {
|
||||
return wait.PollImmediate(APICallRetryInterval, w.timeout, func() (bool, error) {
|
||||
return wait.PollUntilContextTimeout(context.TODO(), APICallRetryInterval, w.timeout, true, func(ctx context.Context) (bool, error) {
|
||||
listOpts := metav1.ListOptions{LabelSelector: label}
|
||||
pods, err := w.client.CoreV1().Pods(namespace).List(context.TODO(), listOpts)
|
||||
pods, err := w.client.CoreV1().Pods(namespace).List(ctx, listOpts)
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
|
|
|
@ -448,7 +448,7 @@ func (c *Controller) monitorClusterHealth(ctx context.Context) (err error) {
|
|||
for i := range clusters {
|
||||
cluster := &clusters[i]
|
||||
var observedReadyCondition, currentReadyCondition *metav1.Condition
|
||||
if err = wait.PollImmediate(MonitorRetrySleepTime, MonitorRetrySleepTime*HealthUpdateRetry, func() (bool, error) {
|
||||
if err = wait.PollUntilContextTimeout(ctx, MonitorRetrySleepTime, MonitorRetrySleepTime*HealthUpdateRetry, true, func(ctx context.Context) (bool, error) {
|
||||
// Cluster object may be changed in this function.
|
||||
observedReadyCondition, currentReadyCondition, err = c.tryUpdateClusterHealth(ctx, cluster)
|
||||
if err == nil {
|
||||
|
|
|
@ -30,8 +30,8 @@ import (
|
|||
|
||||
// WaitAPIServiceReady wait the api service condition true
|
||||
func WaitAPIServiceReady(c *aggregator.Clientset, name string, timeout time.Duration) error {
|
||||
if err := wait.PollImmediate(time.Second, timeout, func() (done bool, err error) {
|
||||
apiService, e := c.ApiregistrationV1().APIServices().Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err := wait.PollUntilContextTimeout(context.TODO(), time.Second, timeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
apiService, e := c.ApiregistrationV1().APIServices().Get(ctx, name, metav1.GetOptions{})
|
||||
if e != nil {
|
||||
return false, nil
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ import (
|
|||
// WaitForStatefulSetRollout wait for StatefulSet reaches the ready state or timeout.
|
||||
func WaitForStatefulSetRollout(c kubernetes.Interface, sts *appsv1.StatefulSet, timeoutSeconds int) error {
|
||||
var lastErr error
|
||||
pollError := wait.PollImmediate(time.Second, time.Duration(timeoutSeconds)*time.Second, func() (bool, error) {
|
||||
s, err := c.AppsV1().StatefulSets(sts.GetNamespace()).Get(context.TODO(), sts.GetName(), metav1.GetOptions{})
|
||||
pollError := wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Duration(timeoutSeconds)*time.Second, true, func(ctx context.Context) (bool, error) {
|
||||
s, err := c.AppsV1().StatefulSets(sts.GetNamespace()).Get(ctx, sts.GetName(), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
lastErr = err
|
||||
return false, nil
|
||||
|
@ -62,8 +62,8 @@ func WaitForStatefulSetRollout(c kubernetes.Interface, sts *appsv1.StatefulSet,
|
|||
// WaitForDeploymentRollout wait for Deployment reaches the ready state or timeout.
|
||||
func WaitForDeploymentRollout(c kubernetes.Interface, dep *appsv1.Deployment, timeoutSeconds int) error {
|
||||
var lastErr error
|
||||
pollError := wait.PollImmediate(time.Second, time.Duration(timeoutSeconds)*time.Second, func() (bool, error) {
|
||||
d, err := c.AppsV1().Deployments(dep.GetNamespace()).Get(context.TODO(), dep.GetName(), metav1.GetOptions{})
|
||||
pollError := wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Duration(timeoutSeconds)*time.Second, true, func(ctx context.Context) (bool, error) {
|
||||
d, err := c.AppsV1().Deployments(dep.GetNamespace()).Get(ctx, dep.GetName(), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
lastErr = err
|
||||
return false, nil
|
||||
|
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package e2e
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
|
@ -422,7 +423,7 @@ var _ = ginkgo.Describe("[ClusterAffinities] propagation testing", func() {
|
|||
err := recoverCluster(controlPlaneClient, "member1", originalAPIEndpoint)
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
|
||||
err = wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
err = wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(_ context.Context) (done bool, err error) {
|
||||
currentCluster, err := util.GetCluster(controlPlaneClient, "member1")
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
|
@ -142,7 +142,7 @@ var _ = framework.SerialDescribe("failover testing", func() {
|
|||
err := recoverCluster(controlPlaneClient, disabledCluster, originalAPIEndpoint)
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
// wait for the disabled cluster recovered
|
||||
err = wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
err = wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(_ context.Context) (done bool, err error) {
|
||||
currentCluster, err := util.GetCluster(controlPlaneClient, disabledCluster)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
@ -525,9 +525,9 @@ var _ = framework.SerialDescribe("failover testing", func() {
|
|||
|
||||
// disableCluster will set wrong API endpoint of current cluster
|
||||
func disableCluster(c client.Client, clusterName string) error {
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
clusterObj := &clusterv1alpha1.Cluster{}
|
||||
if err := c.Get(context.TODO(), client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if err := c.Get(ctx, client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ func disableCluster(c client.Client, clusterName string) error {
|
|||
// set the APIEndpoint of matched cluster to a wrong value
|
||||
unavailableAPIEndpoint := "https://172.19.1.3:6443"
|
||||
clusterObj.Spec.APIEndpoint = unavailableAPIEndpoint
|
||||
if err := c.Update(context.TODO(), clusterObj); err != nil {
|
||||
if err := c.Update(ctx, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -549,16 +549,16 @@ func disableCluster(c client.Client, clusterName string) error {
|
|||
|
||||
// taintCluster will taint cluster
|
||||
func taintCluster(c client.Client, clusterName string, taint corev1.Taint) error {
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
clusterObj := &clusterv1alpha1.Cluster{}
|
||||
if err := c.Get(context.TODO(), client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if err := c.Get(ctx, client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
clusterObj.Spec.Taints = append(clusterObj.Spec.Taints, taint)
|
||||
if err := c.Update(context.TODO(), clusterObj); err != nil {
|
||||
if err := c.Update(ctx, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -571,16 +571,16 @@ func taintCluster(c client.Client, clusterName string, taint corev1.Taint) error
|
|||
|
||||
// recoverTaintedCluster will recover the taint of the disabled cluster
|
||||
func recoverTaintedCluster(c client.Client, clusterName string, taint corev1.Taint) error {
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
clusterObj := &clusterv1alpha1.Cluster{}
|
||||
if err := c.Get(context.TODO(), client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if err := c.Get(ctx, client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
clusterObj.Spec.Taints = helper.SetCurrentClusterTaints(nil, []*corev1.Taint{&taint}, clusterObj)
|
||||
if err := c.Update(context.TODO(), clusterObj); err != nil {
|
||||
if err := c.Update(ctx, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -593,13 +593,13 @@ func recoverTaintedCluster(c client.Client, clusterName string, taint corev1.Tai
|
|||
|
||||
// recoverCluster will recover API endpoint of the disable cluster
|
||||
func recoverCluster(c client.Client, clusterName string, originalAPIEndpoint string) error {
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
clusterObj := &clusterv1alpha1.Cluster{}
|
||||
if err := c.Get(context.TODO(), client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if err := c.Get(ctx, client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
return false, err
|
||||
}
|
||||
clusterObj.Spec.APIEndpoint = originalAPIEndpoint
|
||||
if err := c.Update(context.TODO(), clusterObj); err != nil {
|
||||
if err := c.Update(ctx, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
|
|
@ -220,9 +220,9 @@ func newClusterClientSet(controlPlaneClient client.Client, c *clusterv1alpha1.Cl
|
|||
|
||||
// setClusterLabel set cluster label of E2E
|
||||
func setClusterLabel(c client.Client, clusterName string) error {
|
||||
err := wait.PollImmediate(2*time.Second, 10*time.Second, func() (done bool, err error) {
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 10*time.Second, true, func(ctx context.Context) (done bool, err error) {
|
||||
clusterObj := &clusterv1alpha1.Cluster{}
|
||||
if err := c.Get(context.TODO(), client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if err := c.Get(ctx, client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ func setClusterLabel(c client.Client, clusterName string) error {
|
|||
if clusterObj.Spec.SyncMode == clusterv1alpha1.Push {
|
||||
clusterObj.Labels["sync-mode"] = "Push"
|
||||
}
|
||||
if err := c.Update(context.TODO(), clusterObj); err != nil {
|
||||
if err := c.Update(ctx, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -333,9 +333,9 @@ func LoadRESTClientConfig(kubeconfig string, context string) (*rest.Config, erro
|
|||
|
||||
// SetClusterRegion sets .Spec.Region field for Cluster object.
|
||||
func SetClusterRegion(c client.Client, clusterName string, regionName string) error {
|
||||
return wait.PollImmediate(2*time.Second, 10*time.Second, func() (done bool, err error) {
|
||||
return wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 10*time.Second, true, func(ctx context.Context) (done bool, err error) {
|
||||
clusterObj := &clusterv1alpha1.Cluster{}
|
||||
if err := c.Get(context.TODO(), client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if err := c.Get(ctx, client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ func SetClusterRegion(c client.Client, clusterName string, regionName string) er
|
|||
}
|
||||
|
||||
clusterObj.Spec.Region = regionName
|
||||
if err := c.Update(context.TODO(), clusterObj); err != nil {
|
||||
if err := c.Update(ctx, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
|
|
@ -330,8 +330,8 @@ var _ = ginkgo.Describe("Multi-Cluster Service testing", func() {
|
|||
framework.CreatePropagationPolicy(karmadaClient, importPolicy)
|
||||
|
||||
ginkgo.By(fmt.Sprintf("Wait derived-service(%s/%s) exist in %s cluster", demoService.Namespace, names.GenerateDerivedServiceName(demoService.Name), serviceImportClusterName), func() {
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
_, err = importClusterClient.CoreV1().Services(demoService.Namespace).Get(context.TODO(), names.GenerateDerivedServiceName(demoService.Name), metav1.GetOptions{})
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
_, err = importClusterClient.CoreV1().Services(demoService.Namespace).Get(ctx, names.GenerateDerivedServiceName(demoService.Name), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
|
|
|
@ -151,8 +151,8 @@ var _ = ginkgo.Describe("[namespace auto-provision] namespace auto-provision tes
|
|||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
clusterClient, err := util.NewClusterClientSet(clusterJoined.Name, controlPlaneClient, nil)
|
||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||
err = wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
_, err = clusterClient.KubeClient.CoreV1().Namespaces().Get(context.TODO(), namespaceName, metav1.GetOptions{})
|
||||
err = wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
_, err = clusterClient.KubeClient.CoreV1().Namespaces().Get(ctx, namespaceName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
|
|
|
@ -285,8 +285,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
|||
gomega.Expect(clusterDynamicClient).ShouldNot(gomega.BeNil())
|
||||
|
||||
klog.Infof("Waiting for cr(%s/%s) present on cluster(%s)", crNamespace, crName, cluster.Name)
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crGVR).Namespace(crNamespace).Get(context.TODO(), crName, metav1.GetOptions{})
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crGVR).Namespace(crNamespace).Get(ctx, crName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
|
@ -320,8 +320,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
|||
gomega.Expect(clusterDynamicClient).ShouldNot(gomega.BeNil())
|
||||
|
||||
klog.Infof("Waiting for cr(%s/%s) synced on cluster(%s)", crNamespace, crName, cluster.Name)
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
cr, err := clusterDynamicClient.Resource(crGVR).Namespace(crNamespace).Get(context.TODO(), crName, metav1.GetOptions{})
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
cr, err := clusterDynamicClient.Resource(crGVR).Namespace(crNamespace).Get(ctx, crName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -351,8 +351,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
|||
gomega.Expect(clusterDynamicClient).ShouldNot(gomega.BeNil())
|
||||
|
||||
klog.Infof("Waiting for cr(%s/%s) disappear on cluster(%s)", crNamespace, crName, cluster.Name)
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crGVR).Namespace(crNamespace).Get(context.TODO(), crName, metav1.GetOptions{})
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crGVR).Namespace(crNamespace).Get(ctx, crName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return true, nil
|
||||
|
|
|
@ -197,7 +197,7 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
|
|||
|
||||
wantedReplicas := *workload.Spec.Replicas * int32(len(framework.Clusters()))
|
||||
klog.Infof("Waiting for workload(%s/%s) collecting correctly status", workloadNamespace, workloadName)
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(_ context.Context) (done bool, err error) {
|
||||
currentWorkload := framework.GetWorkload(dynamicClient, workloadNamespace, workloadName)
|
||||
|
||||
klog.Infof("workload(%s/%s) readyReplicas: %d, wanted replicas: %d", workloadNamespace, workloadName, currentWorkload.Status.ReadyReplicas, wantedReplicas)
|
||||
|
@ -484,8 +484,8 @@ end
|
|||
gomega.Expect(clusterDynamicClient).ShouldNot(gomega.BeNil())
|
||||
|
||||
klog.Infof("Waiting for dependency cr(%s/%s) present on cluster(%s)", crNamespaceDep, crNameDep, cluster.Name)
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crGVRDep).Namespace(crNamespaceDep).Get(context.TODO(), crNameDep, metav1.GetOptions{})
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crGVRDep).Namespace(crNamespaceDep).Get(ctx, crNameDep, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
|
@ -519,8 +519,8 @@ end
|
|||
gomega.Expect(clusterDynamicClient).ShouldNot(gomega.BeNil())
|
||||
|
||||
klog.Infof("Waiting for cr(%s/%s) synced on cluster(%s)", crNamespaceDep, crNameDep, cluster.Name)
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
cr, err := clusterDynamicClient.Resource(crGVRDep).Namespace(crNamespaceDep).Get(context.TODO(), crNameDep, metav1.GetOptions{})
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
cr, err := clusterDynamicClient.Resource(crGVRDep).Namespace(crNamespaceDep).Get(ctx, crNameDep, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -550,8 +550,8 @@ end
|
|||
gomega.Expect(clusterDynamicClient).ShouldNot(gomega.BeNil())
|
||||
|
||||
klog.Infof("Waiting for dependency cr(%s/%s) disappear on cluster(%s)", crNamespaceDep, crNameDep, cluster.Name)
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crGVRDep).Namespace(crNamespaceDep).Get(context.TODO(), crNameDep, metav1.GetOptions{})
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crGVRDep).Namespace(crNamespaceDep).Get(ctx, crNameDep, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return true, nil
|
||||
|
|
|
@ -227,8 +227,8 @@ var _ = ginkgo.Describe("propagation with label and group constraints testing",
|
|||
gomega.Expect(clusterDynamicClient).ShouldNot(gomega.BeNil())
|
||||
|
||||
klog.Infof("Waiting for crd(%s) present on cluster(%s)", crd.Name, targetClusterName)
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crdGVR).Namespace(crd.Namespace).Get(context.TODO(), crd.Name, metav1.GetOptions{})
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
_, err = clusterDynamicClient.Resource(crdGVR).Namespace(crd.Namespace).Get(ctx, crd.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
|
|
|
@ -241,16 +241,16 @@ func deleteCluster(clusterName, kubeConfigPath string) error {
|
|||
|
||||
// deleteClusterLabel delete cluster label of E2E
|
||||
func deleteClusterLabel(c client.Client, clusterName string) error {
|
||||
err := wait.PollImmediate(2*time.Second, 10*time.Second, func() (done bool, err error) {
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), 2*time.Second, 10*time.Second, true, func(ctx context.Context) (done bool, err error) {
|
||||
clusterObj := &clusterv1alpha1.Cluster{}
|
||||
if err := c.Get(context.TODO(), client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if err := c.Get(ctx, client.ObjectKey{Name: clusterName}, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
delete(clusterObj.Labels, "location")
|
||||
if err := c.Update(context.TODO(), clusterObj); err != nil {
|
||||
if err := c.Update(ctx, clusterObj); err != nil {
|
||||
if apierrors.IsConflict(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ const (
|
|||
func GetTokenFromServiceAccount(client kubernetes.Interface, saNamespace, saName string) (string, error) {
|
||||
klog.Infof("Get serviceAccount(%s/%s)'s refer secret", saNamespace, saName)
|
||||
var token string
|
||||
err := wait.PollImmediate(pollInterval, pollTimeout, func() (done bool, err error) {
|
||||
saRefSecret, err := client.CoreV1().Secrets(saNamespace).Get(context.TODO(), saName, metav1.GetOptions{})
|
||||
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, true, func(ctx context.Context) (done bool, err error) {
|
||||
saRefSecret, err := client.CoreV1().Secrets(saNamespace).Get(ctx, saName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
|
|
Loading…
Reference in New Issue