Skip to content

Commit d3c7585

Browse files
committed
Switch to PollUntilContextTimeout in wait functions
1 parent 2dba689 commit d3c7585

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

pkg/k8s/wait.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ import (
1919
// - There are no unavailable replicas
2020
// - All pods associated with the deployment are running
2121
func WaitForDeploymentAvailable(ctx context.Context, clientset *kubernetes.Clientset, namespace, deploymentName string, timeout time.Duration) error {
22-
ctx, cancel := context.WithTimeout(ctx, timeout)
23-
defer cancel()
24-
25-
return wait.PollUntilContextCancel(ctx, 1*time.Second, true, func(ctx context.Context) (bool, error) {
22+
return wait.PollUntilContextTimeout(ctx, 1*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
2623
deployment, err := clientset.AppsV1().Deployments(namespace).Get(ctx, deploymentName, metav1.GetOptions{})
2724
if err != nil {
2825
return false, err
@@ -33,10 +30,7 @@ func WaitForDeploymentAvailable(ctx context.Context, clientset *kubernetes.Clien
3330
}
3431

3532
func WaitForDeploymentAvailableBySelector(ctx context.Context, clientset *kubernetes.Clientset, namespace, selector string, timeout time.Duration) error {
36-
ctx, cancel := context.WithTimeout(ctx, timeout)
37-
defer cancel()
38-
39-
return wait.PollUntilContextCancel(ctx, 1*time.Second, true, func(ctx context.Context) (bool, error) {
33+
return wait.PollUntilContextTimeout(ctx, 1*time.Second, timeout, true, func(ctx context.Context) (bool, error) {
4034
deployments, err := clientset.AppsV1().Deployments(namespace).List(ctx, metav1.ListOptions{
4135
LabelSelector: selector,
4236
})

0 commit comments

Comments
 (0)