@@ -672,7 +672,15 @@ func (c *OpenshiftAPIConfig) bootstrapSCC(context genericapiserver.PostStartHook
672
672
func (c * OpenshiftAPIConfig ) ensureOpenShiftInfraNamespace (context genericapiserver.PostStartHookContext ) error {
673
673
ns := bootstrappolicy .DefaultOpenShiftInfraNamespace
674
674
675
- ensureNamespaceServiceAccountRoleBindings (context , ns )
675
+ ensureNamespaceServiceAccountRoleBindings (
676
+ context ,
677
+ ns ,
678
+ & rbacrest.PolicyData {
679
+ RoleBindings : map [string ][]rbac.RoleBinding {
680
+ ns : bootstrappolicy .GetBootstrapServiceAccountProjectRoleBindings (ns ),
681
+ },
682
+ },
683
+ )
676
684
677
685
var coreClient coreclient.CoreInterface
678
686
err := wait .Poll (1 * time .Second , 30 * time .Second , func () (bool , error ) {
@@ -692,20 +700,29 @@ func (c *OpenshiftAPIConfig) ensureOpenShiftInfraNamespace(context genericapiser
692
700
// Ensure we have the bootstrap SA for Nodes
693
701
_ , err = coreClient .ServiceAccounts (ns ).Create (& kapi.ServiceAccount {ObjectMeta : metav1.ObjectMeta {Name : bootstrappolicy .InfraNodeBootstrapServiceAccountName }})
694
702
if err != nil && ! kapierror .IsAlreadyExists (err ) {
695
- glog .Errorf ("Error creating service account %s/%s: %v" , ns , bootstrappolicy .InfraNodeBootstrapServiceAccountName , err )
703
+ utilruntime .HandleError (fmt .Errorf ("Error creating service account %s/%s: %v" , ns , bootstrappolicy .InfraNodeBootstrapServiceAccountName , err ))
704
+ return err
696
705
}
697
706
698
707
return nil
699
708
}
700
709
701
710
// ensureDefaultNamespaceServiceAccountRoles initializes roles for service accounts in the default namespace
702
711
func (c * OpenshiftAPIConfig ) ensureDefaultNamespaceServiceAccountRoles (context genericapiserver.PostStartHookContext ) error {
703
- ensureNamespaceServiceAccountRoleBindings (context , metav1 .NamespaceDefault )
712
+ ensureNamespaceServiceAccountRoleBindings (
713
+ context ,
714
+ metav1 .NamespaceDefault ,
715
+ & rbacrest.PolicyData {
716
+ RoleBindings : map [string ][]rbac.RoleBinding {
717
+ metav1 .NamespaceDefault : bootstrappolicy .GetBootstrapServiceAccountProjectRoleBindings (metav1 .NamespaceDefault ),
718
+ },
719
+ },
720
+ )
704
721
return nil
705
722
}
706
723
707
724
// ensureNamespaceServiceAccountRoleBindings initializes roles for service accounts in the namespace
708
- func ensureNamespaceServiceAccountRoleBindings (context genericapiserver.PostStartHookContext , namespaceName string ) {
725
+ func ensureNamespaceServiceAccountRoleBindings (context genericapiserver.PostStartHookContext , namespaceName string , policyData * rbacrest. PolicyData ) {
709
726
const ServiceAccountRolesInitializedAnnotation = "openshift.io/sa.initialized-roles"
710
727
711
728
var coreClient coreclient.CoreInterface
@@ -742,11 +759,6 @@ func ensureNamespaceServiceAccountRoleBindings(context genericapiserver.PostStar
742
759
return
743
760
}
744
761
745
- policyData := & rbacrest.PolicyData {
746
- RoleBindings : map [string ][]rbac.RoleBinding {
747
- namespace .Name : bootstrappolicy .GetBootstrapServiceAccountProjectRoleBindings (namespace .Name ),
748
- },
749
- }
750
762
if err := policyData .EnsureRBACPolicy ()(context ); err != nil {
751
763
utilruntime .HandleError (err )
752
764
return
0 commit comments