Skip to content

Commit dca9439

Browse files
committed
use wait.PollUntilContextTimeout instead of wait.Poll
1 parent c942829 commit dca9439

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ require (
6060
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6161
github.com/pelletier/go-toml v1.9.5 // indirect
6262
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
63+
github.com/pmezard/go-difflib v1.0.0 // indirect
6364
github.com/russross/blackfriday/v2 v2.1.0 // indirect
6465
github.com/spf13/afero v1.9.3 // indirect
6566
github.com/spf13/cast v1.5.0 // indirect
6667
github.com/spf13/jwalterweatherman v1.1.0 // indirect
68+
github.com/stretchr/testify v1.8.1 // indirect
6769
github.com/subosito/gotenv v1.4.1 // indirect
6870
golang.org/x/net v0.8.0 // indirect
6971
golang.org/x/oauth2 v0.3.0 // indirect

pkg/client/delete.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (c *SonobuoyClient) Delete(cfg *DeleteConfig) error {
8585

8686
if cfg.Wait > time.Duration(0) {
8787
lastProgress := ""
88-
allConditions := func() (bool, error) {
88+
allConditions := func(ctx context.Context) (bool, error) {
8989
for _, condition := range conditions {
9090
progress, done, err := condition()
9191
if cfg.WaitOutput == progressMode {
@@ -111,7 +111,7 @@ func (c *SonobuoyClient) Delete(cfg *DeleteConfig) error {
111111
s.Start()
112112
defer s.Stop()
113113
}
114-
if err := wait.Poll(pollFreq, cfg.Wait, allConditions); err != nil {
114+
if err := wait.PollUntilContextTimeout(context.TODO(), pollFreq, cfg.Wait, false, allConditions); err != nil {
115115
return errors.Wrap(err, "waiting for delete conditions to be met")
116116
}
117117
}

pkg/client/run.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package client
1818

1919
import (
2020
"bytes"
21+
"context"
2122
"fmt"
2223
"io"
2324
"os"
@@ -138,7 +139,7 @@ func (c *SonobuoyClient) WaitForRun(cfg *RunConfig) error {
138139
lastMsg = s
139140
}
140141
}
141-
runCondition := func() (bool, error) {
142+
runCondition := func(ctx context.Context) (bool, error) {
142143

143144
// Get the Aggregator pod and check if its status is completed or terminated.
144145
status, pod, err := c.GetStatusPod(&StatusConfig{Namespace: ns})
@@ -186,7 +187,7 @@ func (c *SonobuoyClient) WaitForRun(cfg *RunConfig) error {
186187
// handled by conditionFunc since it has to be part of the polling.
187188
// Could use channels but that will lead to future issues.
188189
}
189-
err := wait.Poll(pollInterval, cfg.Wait, runCondition)
190+
err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, cfg.Wait, false, runCondition)
190191
if err != nil {
191192
return errors.Wrap(err, "waiting for run to finish")
192193
}

0 commit comments

Comments
 (0)