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.
This commit is contained in:
Clayton Coleman 2022-01-25 13:17:03 -05:00
parent 1608fc5e88
commit b4aa9a189e
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -322,22 +322,16 @@ func waitForServiceAccountInNamespace(c clientset.Interface, ns, serviceAccountN
} }
ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout) ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout)
defer cancel() 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) {
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 { switch event.Type {
case watch.Deleted: case watch.Deleted:
return false, apierrors.NewNotFound(schema.GroupResource{Resource: "serviceaccounts"}, "") return false, apierrors.NewNotFound(schema.GroupResource{Resource: "serviceaccounts"}, serviceAccountName)
} case watch.Added, watch.Modified:
switch t := event.Object.(type) { return true, nil
case *v1.ServiceAccount:
return len(t.Secrets) > 0, nil
} }
return false, nil return false, nil
})
return err
} }
// WaitForDefaultServiceAccountInNamespace waits for the default service account to be provisioned // WaitForDefaultServiceAccountInNamespace waits for the default service account to be provisioned