From c77e17bd3045b3b747e116ecaaf57be6f19cfb33 Mon Sep 17 00:00:00 2001 From: Aman Shrivastava Date: Fri, 27 Sep 2024 12:11:36 +0530 Subject: [PATCH] Fixed #676: Validate conditions immediately upon invocation. Fixed #676: Validate conditions immediately upon invocation. --- pkg/utils/utils.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 94c28ecc..34c3ea8d 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -61,12 +61,11 @@ func PollUntil(pollInterval, timeOut <-chan time.Time, condition func() (bool, e select { case <-timeOut: return fmt.Errorf("timed out while waiting for job to complete") - case <-pollInterval: - if done, err := condition(); err != nil { + default: + if done, err := condition(); err != nil || done { return err - } else if done { - return nil } + <-pollInterval } } }