fix: remove the incorrect RBAC rule merging logic (#6209)

Signed-off-by: hongming <coder.scala@gmail.com>
This commit is contained in:
hongming
2024-09-26 16:13:18 +08:00
committed by GitHub
parent e50de15ec9
commit 083927137d
5 changed files with 11 additions and 8 deletions

View File

@@ -140,7 +140,7 @@ func (r *Reconciler) reconcileWorkspaceOwnerReference(ctx context.Context, names
return nil
}
if !metav1.IsControlledBy(namespace, workspace) {
if !metav1.IsControlledBy(namespace, workspace) && namespace.Labels[constants.KubeSphereManagedLabel] == "true" {
namespace = namespace.DeepCopy()
if err := controllerutil.SetControllerReference(workspace, namespace, scheme.Scheme); err != nil {
return err

View File

@@ -42,8 +42,11 @@ var _ = Describe("Namespace", func() {
It("Should create successfully", func() {
namespace := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: "test-namespace",
Labels: map[string]string{tenantv1beta1.WorkspaceLabel: workspace.Name},
Name: "test-namespace",
Labels: map[string]string{
tenantv1beta1.WorkspaceLabel: workspace.Name,
constants.KubeSphereManagedLabel: "true",
},
},
}

View File

@@ -96,9 +96,9 @@ func (r *Reconciler) syncToKubernetes(ctx context.Context, role *iamv1beta1.Role
})
if err != nil {
r.logger.Error(err, "sync role failed", "role", role.Name)
r.logger.Error(err, "sync role failed", "namespace", role.Namespace, "role", role.Name)
}
r.logger.V(4).Info("sync role to K8s", "role", role.Name, "op", op)
r.logger.V(4).Info("sync role to K8s", "namespace", role.Namespace, "role", role.Name, "op", op)
return nil
}