Skip to content

Commit de603b0

Browse files
authored
add early return in goroutine for each SA (#345)
Signed-off-by: YuChen <[email protected]>
1 parent 51cbfa7 commit de603b0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

controllers/namespacescope_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ func (r *NamespaceScopeReconciler) generateRBACToNamespace(ctx context.Context,
502502
roleList, err := r.GetRolesFromServiceAccount(ctx, sa, fromNs)
503503
if err != nil {
504504
errorChannel <- err
505+
return
505506
}
506507

507508
klog.V(2).Infof("Roles waiting to be copied for SA %s: %v", sa, roleList)
@@ -511,13 +512,15 @@ func (r *NamespaceScopeReconciler) generateRBACToNamespace(ctx context.Context,
511512
r.Recorder.Eventf(instance, corev1.EventTypeWarning, "Forbidden", "cannot create resource roles in API group rbac.authorization.k8s.io in the namespace %s. Please authorize service account ibm-namespace-scope-operator namespace admin permission of %s namespace", toNs, toNs)
512513
}
513514
errorChannel <- err
515+
return
514516
}
515517

516518
if err := r.CreateRoleBinding(ctx, roleList, labels, sa, fromNs, toNs); err != nil {
517519
if errors.IsForbidden(err) {
518520
r.Recorder.Eventf(instance, corev1.EventTypeWarning, "Forbidden", "cannot create resource rolebindings in API group rbac.authorization.k8s.io in the namespace %s. Please authorize service account ibm-namespace-scope-operator namespace admin permission of %s namespace", toNs, toNs)
519521
}
520522
errorChannel <- err
523+
return
521524
}
522525
}(sa)
523526
}

0 commit comments

Comments
 (0)