diff --git a/staging/src/k8s.io/apimachinery/pkg/util/wait/wait.go b/staging/src/k8s.io/apimachinery/pkg/util/wait/wait.go index 3c17d72b41a..4704afd91bd 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/wait/wait.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/wait/wait.go @@ -129,9 +129,6 @@ func Jitter(duration time.Duration, maxFactor float64) time.Duration { // ErrWaitTimeout is returned when the condition exited without success. var ErrWaitTimeout = errors.New("timed out waiting for the condition") -// ErrChannelClosed is returned when the watch channel is closed. -var ErrChannelClosed = errors.New("watch channel closed") - // ConditionFunc returns true if the condition is satisfied, or an error // if the loop should be aborted. type ConditionFunc func() (done bool, err error) diff --git a/staging/src/k8s.io/apimachinery/pkg/watch/until.go b/staging/src/k8s.io/apimachinery/pkg/watch/until.go index 5c340f07176..6e139de5907 100644 --- a/staging/src/k8s.io/apimachinery/pkg/watch/until.go +++ b/staging/src/k8s.io/apimachinery/pkg/watch/until.go @@ -17,6 +17,7 @@ limitations under the License. package watch import ( + "errors" "time" "k8s.io/apimachinery/pkg/util/wait" @@ -28,6 +29,9 @@ import ( // from false to true). type ConditionFunc func(event Event) (bool, error) +// errWatchClosed is returned when the watch channel is closed before timeout in Until. +var errWatchClosed = errors.New("watch closed before Until timeout") + // Until reads items from the watch until each provided condition succeeds, and then returns the last watch // encountered. The first condition that returns an error terminates the watch (and the event is also returned). // If no event has been received, the returned event will be nil. @@ -61,7 +65,7 @@ func Until(timeout time.Duration, watcher Interface, conditions ...ConditionFunc select { case event, ok := <-ch: if !ok { - return lastEvent, wait.ErrChannelClosed + return lastEvent, errWatchClosed } lastEvent = &event