You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perform the RBAC propagation in parallel across namespaces (#343)
* perform the RBAC propagation in parallel across namespaces
Signed-off-by: YuChen <[email protected]>
* perform roles copied for SA in parallel in single namespace
Signed-off-by: YuChen <[email protected]>
---------
Signed-off-by: YuChen <[email protected]>
roleList, err:=r.GetRolesFromServiceAccount(ctx, sa, fromNs)
497
+
wg.Add(1)
475
498
476
-
klog.V(2).Infof("Roles waiting to be copied: %v", roleList)
499
+
gofunc(sastring) {
500
+
deferwg.Done()
477
501
478
-
iferr!=nil {
479
-
returnerr
480
-
}
502
+
roleList, err:=r.GetRolesFromServiceAccount(ctx, sa, fromNs)
503
+
iferr!=nil {
504
+
errorChannel<-err
505
+
}
481
506
482
-
iferr:=r.CreateRole(ctx, roleList, labels, sa, fromNs, toNs); err!=nil {
483
-
iferrors.IsForbidden(err) {
484
-
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)
507
+
klog.V(2).Infof("Roles waiting to be copied for SA %s: %v", sa, roleList)
508
+
509
+
iferr:=r.CreateRole(ctx, roleList, labels, sa, fromNs, toNs); err!=nil {
510
+
iferrors.IsForbidden(err) {
511
+
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)
512
+
}
513
+
errorChannel<-err
485
514
}
486
-
returnerr
487
-
}
488
-
iferr:=r.CreateRoleBinding(ctx, roleList, labels, sa, fromNs, toNs); err!=nil {
489
-
iferrors.IsForbidden(err) {
490
-
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)
515
+
516
+
iferr:=r.CreateRoleBinding(ctx, roleList, labels, sa, fromNs, toNs); err!=nil {
517
+
iferrors.IsForbidden(err) {
518
+
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)
0 commit comments