Skip to content

Commit b4aa9a1

Browse files
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.
1 parent 1608fc5 commit b4aa9a1

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

test/e2e/framework/util.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -322,24 +322,18 @@ func waitForServiceAccountInNamespace(c clientset.Interface, ns, serviceAccountN
322322
}
323323
ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), timeout)
324324
defer cancel()
325-
_, err := watchtools.UntilWithSync(ctx, lw, &v1.ServiceAccount{}, nil, serviceAccountHasSecrets)
325+
_, err := watchtools.UntilWithSync(ctx, lw, &v1.ServiceAccount{}, nil, func(event watch.Event) (bool, error) {
326+
switch event.Type {
327+
case watch.Deleted:
328+
return false, apierrors.NewNotFound(schema.GroupResource{Resource: "serviceaccounts"}, serviceAccountName)
329+
case watch.Added, watch.Modified:
330+
return true, nil
331+
}
332+
return false, nil
333+
})
326334
return err
327335
}
328336

329-
// serviceAccountHasSecrets returns true if the service account has at least one secret,
330-
// false if it does not, or an error.
331-
func serviceAccountHasSecrets(event watch.Event) (bool, error) {
332-
switch event.Type {
333-
case watch.Deleted:
334-
return false, apierrors.NewNotFound(schema.GroupResource{Resource: "serviceaccounts"}, "")
335-
}
336-
switch t := event.Object.(type) {
337-
case *v1.ServiceAccount:
338-
return len(t.Secrets) > 0, nil
339-
}
340-
return false, nil
341-
}
342-
343337
// WaitForDefaultServiceAccountInNamespace waits for the default service account to be provisioned
344338
// the default service account is what is associated with pods when they do not specify a service account
345339
// as a result, pods are not able to be provisioned in a namespace until the service account is provisioned

0 commit comments

Comments
 (0)