Skip to content

Commit 464be26

Browse files
committed
test cleanup
1 parent 1e1307d commit 464be26

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

test/e2e/framework/auth/helpers.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ func BindClusterRole(ctx context.Context, c bindingsGetter, clusterRole, ns stri
108108
return nil
109109
}
110110

111-
// Since the namespace names are unique, we can leave this lying around so we don't have to race any caches
112-
_, err := c.ClusterRoleBindings().Create(ctx, &rbacv1.ClusterRoleBinding{
111+
clusterRoleBinding, err := c.ClusterRoleBindings().Create(ctx, &rbacv1.ClusterRoleBinding{
113112
ObjectMeta: metav1.ObjectMeta{
114-
Name: ns + "--" + clusterRole,
113+
Name: clusterRole,
115114
},
116115
RoleRef: rbacv1.RoleRef{
117116
APIGroup: "rbac.authorization.k8s.io",
@@ -125,6 +124,10 @@ func BindClusterRole(ctx context.Context, c bindingsGetter, clusterRole, ns stri
125124
return fmt.Errorf("binding clusterrole/%s for %q for %v: %w", clusterRole, ns, subjects, err)
126125
}
127126

127+
defer func() {
128+
framework.ExpectNoError(c.ClusterRoleBindings().Delete(ctx, clusterRoleBinding.Name, metav1.DeleteOptions{}))
129+
}()
130+
128131
return nil
129132
}
130133

test/e2e/node/kubelet_authz.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ func runKubeletAuthzTest(ctx context.Context, f *framework.Framework, endpoint,
8787
},
8888
}, metav1.CreateOptions{})
8989
framework.ExpectNoError(err)
90+
defer func() {
91+
framework.ExpectNoError(f.ClientSet.RbacV1().ClusterRoles().Delete(ctx, clusterRole.Name, metav1.DeleteOptions{}))
92+
}()
9093

9194
subject := rbacv1.Subject{
9295
Kind: rbacv1.ServiceAccountKind,

0 commit comments

Comments
 (0)