From b4aa9a189ead272a3f6dd62562f7a355932c57fa Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Tue, 25 Jan 2022 13:17:03 -0500 Subject: [PATCH] e2e: Wait only for the service account Now that projected service account tokens do not require the secret to be created, exclude the wait condition on the token and simply wait for the service account. --- test/e2e/framework/util.go | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 8d4ee0754bc..137dcaa8cb3 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -322,24 +322,18 @@ func waitForServiceAccountInNamespace(c clientset.Interface, ns, serviceAccountN } ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout) defer cancel() - _, err := watchtools.UntilWithSync(ctx, lw, &v1.ServiceAccount{}, nil, serviceAccountHasSecrets) + _, err := watchtools.UntilWithSync(ctx, lw, &v1.ServiceAccount{}, nil, func(event watch.Event) (bool, error) { + switch event.Type { + case watch.Deleted: + return false, apierrors.NewNotFound(schema.GroupResource{Resource: "serviceaccounts"}, serviceAccountName) + case watch.Added, watch.Modified: + return true, nil + } + return false, nil + }) return err } -// serviceAccountHasSecrets returns true if the service account has at least one secret, -// false if it does not, or an error. -func serviceAccountHasSecrets(event watch.Event) (bool, error) { - switch event.Type { - case watch.Deleted: - return false, apierrors.NewNotFound(schema.GroupResource{Resource: "serviceaccounts"}, "") - } - switch t := event.Object.(type) { - case *v1.ServiceAccount: - return len(t.Secrets) > 0, nil - } - return false, nil -} - // WaitForDefaultServiceAccountInNamespace waits for the default service account to be provisioned // the default service account is what is associated with pods when they do not specify a service account // as a result, pods are not able to be provisioned in a namespace until the service account is provisioned