From 16a8dfef35a132d7f4e7fea64e7506f858f88225 Mon Sep 17 00:00:00 2001 From: Thomas Jungblut Date: Tue, 12 May 2026 17:04:14 +0200 Subject: [PATCH] NO-JIRA: simplify waiting in GetLastKeyMeta This replaces the existing logic with a simpler wait.PollUntilContextTimeout. Signed-off-by: Thomas Jungblut --- test/library/encryption/helpers.go | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/test/library/encryption/helpers.go b/test/library/encryption/helpers.go index efdc4dcf3b..4c263b030d 100644 --- a/test/library/encryption/helpers.go +++ b/test/library/encryption/helpers.go @@ -201,29 +201,16 @@ func GetLastKeyMeta(t testing.TB, kubeClient kubernetes.Interface, namespace, la // in theory the max time we tolerate disruption on an SNO cluster is 60 seconds // so we set the timeout to 5 min just in case - pollTimeout := time.Minute * 5 - - // set the number of step to high value - // we should stop on timeout otherwise the backoff returns after 5 steps - // and we never wait the timeout value - backOff := retry.DefaultBackoff - backOff.Steps = 9999 - - // in theory the max time we tolerate disruption on an SNO cluster is 60 seconds - // so we set the timeout to 5 min just in case - err := onErrorWithTimeout(pollTimeout, backOff, func(err error) bool { - if !transientAPIError(err) { - t.Logf("error = %v is not retriable, failed to get the metadata from the last encryption key", err) - return false - } - return true // retry - }, func() (err error) { - selectedSecrets, err = secretsClient.List(context.TODO(), metav1.ListOptions{LabelSelector: labelSelector}) + err := wait.PollUntilContextTimeout(t.Context(), 30*time.Second, time.Minute*5, true, func(ctx context.Context) (result bool, err error) { + selectedSecrets, err = secretsClient.List(ctx, metav1.ListOptions{LabelSelector: labelSelector}) if err != nil { - t.Logf("failed to list secrets, err = %v", err.Error()) + t.Logf("GetLastKeyMeta: Failed to list secrets: %v", err) + return false, nil } - return + + return true, nil }) + if err != nil { return EncryptionKeyMeta{}, err }