Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tolerate disabled RBAC in ServiceAccountIssuerDiscovery test #98813

Merged
merged 1 commit into from Feb 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions test/e2e/auth/service_accounts.go
Expand Up @@ -676,10 +676,12 @@ var _ = SIGDescribe("ServiceAccounts", func() {
ginkgo.It("ServiceAccountIssuerDiscovery should support OIDC discovery of service account issuer", func() {
// Allow the test pod access to the OIDC discovery non-resource URLs.
// The role should have already been automatically created as part of the
// bootstrap policy, but not the role binding.
// RBAC bootstrap policy, but not the role binding. If RBAC is disabled,
// we skip creating the binding. We also make sure we clean up the
// binding after the test.
const clusterRoleName = "system:service-account-issuer-discovery"
crbName := fmt.Sprintf("%s-%s", f.Namespace.Name, clusterRoleName)
if _, err := f.ClientSet.RbacV1().ClusterRoleBindings().Create(
if crb, err := f.ClientSet.RbacV1().ClusterRoleBindings().Create(
context.TODO(),
&rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -699,8 +701,16 @@ var _ = SIGDescribe("ServiceAccounts", func() {
Kind: "ClusterRole",
},
},
metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) {
framework.Failf("Unexpected err creating ClusterRoleBinding %s: %v", crbName, err)
metav1.CreateOptions{}); err != nil {
// Tolerate RBAC not being enabled
framework.Logf("error granting ClusterRoleBinding %s: %v", crbName, err)
} else {
defer func() {
framework.ExpectNoError(
f.ClientSet.RbacV1().ClusterRoleBindings().Delete(
context.TODO(),
crb.Name, metav1.DeleteOptions{}))
}()
}

// Create the pod with tokens.
Expand Down