Skip to content

Commit

Permalink
Merge pull request kubernetes#120405 from Rei1010/introduceNewMethod
Browse files Browse the repository at this point in the history
using wait.Interrupted instead of deprecated wait.ErrWaitTimeout for apps
  • Loading branch information
k8s-ci-robot authored Sep 21, 2023
2 parents 5ebb9f3 + fc25af7 commit ed55236
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/e2e/apps/daemon_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func updateDaemonSetWithRetries(ctx context.Context, c clientset.Interface, name
updateErr = err
return false, nil
})
if pollErr == wait.ErrWaitTimeout {
if wait.Interrupted(pollErr) {
pollErr = fmt.Errorf("couldn't apply the provided updated to DaemonSet %q: %v", name, updateErr)
}
return ds, pollErr
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/apps/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ func watchRecreateDeployment(ctx context.Context, c clientset.Interface, d *apps
ctxUntil, cancel := context.WithTimeout(ctx, 2*time.Minute)
defer cancel()
_, err := watchtools.Until(ctxUntil, d.ResourceVersion, w, condition)
if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
err = fmt.Errorf("deployment %q never completed: %#v", d.Name, status)
}
return err
Expand All @@ -1573,7 +1573,7 @@ func waitForDeploymentOldRSsNum(ctx context.Context, c clientset.Interface, ns,
}
return len(oldRSs) == desiredRSNum, nil
})
if pollErr == wait.ErrWaitTimeout {
if wait.Interrupted(pollErr) {
pollErr = fmt.Errorf("%d old replica sets were not cleaned up for deployment %q", len(oldRSs)-desiredRSNum, deploymentName)
testutil.LogReplicaSetsOfDeployment(d, oldRSs, nil, framework.Logf)
}
Expand All @@ -1590,7 +1590,7 @@ func waitForReplicaSetDesiredReplicas(ctx context.Context, rsClient appsclient.R
}
return rs.Status.ObservedGeneration >= desiredGeneration && rs.Status.Replicas == *(replicaSet.Spec.Replicas) && rs.Status.Replicas == *(rs.Spec.Replicas), nil
})
if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
err = fmt.Errorf("replicaset %q never had desired number of replicas", replicaSet.Name)
}
return err
Expand All @@ -1606,7 +1606,7 @@ func waitForReplicaSetTargetSpecReplicas(ctx context.Context, c clientset.Interf
}
return rs.Status.ObservedGeneration >= desiredGeneration && *rs.Spec.Replicas == targetReplicaNum, nil
})
if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
err = fmt.Errorf("replicaset %q never had desired number of .spec.replicas", replicaSet.Name)
}
return err
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/apps/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package apps
import (
"context"
"encoding/json"
"errors"
"fmt"
"strconv"
"time"
Expand Down Expand Up @@ -286,7 +287,7 @@ var _ = SIGDescribe("Job", func() {
return false, err
}
return len(pods.Items) > 0, nil
}), wait.ErrWaitTimeout)
}), wait.ErrorInterrupted(errors.New("timed out waiting for the condition")))

ginkgo.By("Checking Job status to observe Suspended state")
job, err = e2ejob.GetJob(ctx, f.ClientSet, f.Namespace.Name, job.Name)
Expand Down
11 changes: 6 additions & 5 deletions test/e2e/apps/rc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package apps
import (
"context"
"encoding/json"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -554,7 +555,7 @@ func testReplicationControllerConditionCheck(ctx context.Context, f *framework.F
quantity := resource.MustParse("2")
return (&podQuota).Cmp(quantity) == 0, nil
})
if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
err = fmt.Errorf("resource quota %q never synced", name)
}
framework.ExpectNoError(err)
Expand All @@ -581,7 +582,7 @@ func testReplicationControllerConditionCheck(ctx context.Context, f *framework.F
cond := replication.GetCondition(rc.Status, v1.ReplicationControllerReplicaFailure)
return cond != nil, nil
})
if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
err = fmt.Errorf("rc manager never added the failure condition for rc %q: %#v", name, conditions)
}
framework.ExpectNoError(err)
Expand Down Expand Up @@ -610,7 +611,7 @@ func testReplicationControllerConditionCheck(ctx context.Context, f *framework.F
cond := replication.GetCondition(rc.Status, v1.ReplicationControllerReplicaFailure)
return cond == nil, nil
})
if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
err = fmt.Errorf("rc manager never removed the failure condition for rc %q: %#v", name, conditions)
}
framework.ExpectNoError(err)
Expand Down Expand Up @@ -732,7 +733,7 @@ func updateReplicationControllerWithRetries(ctx context.Context, c clientset.Int
updateErr = err
return false, nil
})
if pollErr == wait.ErrWaitTimeout {
if wait.Interrupted(pollErr) {
pollErr = fmt.Errorf("couldn't apply the provided updated to rc %q: %v", name, updateErr)
}
return rc, pollErr
Expand Down Expand Up @@ -778,7 +779,7 @@ func watchUntilWithoutRetry(ctx context.Context, watcher watch.Interface, condit
}

case <-ctx.Done():
return lastEvent, wait.ErrWaitTimeout
return lastEvent, wait.ErrorInterrupted(errors.New("timed out waiting for the condition"))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/apps/replica_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func testReplicaSetConditionCheck(ctx context.Context, f *framework.Framework) {
podQuota := quota.Status.Hard[v1.ResourcePods]
return (&podQuota).Cmp(quantity) == 0, nil
})
if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
err = fmt.Errorf("resource quota %q never synced", name)
}
framework.ExpectNoError(err)
Expand Down Expand Up @@ -279,7 +279,7 @@ func testReplicaSetConditionCheck(ctx context.Context, f *framework.Framework) {
return cond != nil, nil

})
if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
err = fmt.Errorf("rs controller never added the failure condition for replica set %q: %#v", name, conditions)
}
framework.ExpectNoError(err)
Expand Down Expand Up @@ -308,7 +308,7 @@ func testReplicaSetConditionCheck(ctx context.Context, f *framework.Framework) {
cond := replicaset.GetCondition(rs.Status, appsv1.ReplicaSetReplicaFailure)
return cond == nil, nil
})
if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
err = fmt.Errorf("rs controller never removed the failure condition for rs %q: %#v", name, conditions)
}
framework.ExpectNoError(err)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/apps/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@ func pollReadWithTimeout(ctx context.Context, statefulPod statefulPodTester, sta
return true, nil
})

if err == wait.ErrWaitTimeout {
if wait.Interrupted(err) {
return fmt.Errorf("timed out when trying to read value for key %v from stateful pod %d", key, statefulPodNumber)
}
return err
Expand Down Expand Up @@ -2058,7 +2058,7 @@ func updateStatefulSetWithRetries(ctx context.Context, c clientset.Interface, na
updateErr = err
return false, nil
})
if pollErr == wait.ErrWaitTimeout {
if wait.Interrupted(pollErr) {
pollErr = fmt.Errorf("couldn't apply the provided updated to stateful set %q: %v", name, updateErr)
}
return statefulSet, pollErr
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/apps/ttl_after_finished.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func updateJobWithRetries(ctx context.Context, c clientset.Interface, namespace,
updateErr = err
return false, nil
})
if pollErr == wait.ErrWaitTimeout {
if wait.Interrupted(pollErr) {
pollErr = fmt.Errorf("couldn't apply the provided updated to job %q: %v", name, updateErr)
}
return job, pollErr
Expand Down

0 comments on commit ed55236

Please sign in to comment.