@@ -580,42 +580,48 @@ func (c *completedConfig) bootstrapSCC(context genericapiserver.PostStartHookCon
580580 ns := bootstrappolicy .DefaultOpenShiftInfraNamespace
581581 bootstrapSCCGroups , bootstrapSCCUsers := bootstrappolicy .GetBoostrapSCCAccess (ns )
582582
583- // ClusterResourceQuota is served using CRD resource any status update must use JSON
583+ // SCC is served using CRD resource any status update must use JSON
584584 jsonLoopbackClientConfig := rest .CopyConfig (c .ExtraConfig .KubeAPIServerClientConfig )
585585 jsonLoopbackClientConfig .ContentConfig .AcceptContentTypes = "application/json"
586586 jsonLoopbackClientConfig .ContentConfig .ContentType = "application/json"
587-
588- var securityClient securityv1client.SecurityV1Interface
589- err := wait .Poll (1 * time .Second , 30 * time .Second , func () (bool , error ) {
590- var err error
591- securityClient , err = securityv1client .NewForConfig (jsonLoopbackClientConfig )
592- if err != nil {
593- utilruntime .HandleError (fmt .Errorf ("unable to initialize client: %v" , err ))
594- return false , nil
595- }
596- return true , nil
597- })
587+ securityClient , err := securityv1client .NewForConfig (jsonLoopbackClientConfig )
598588 if err != nil {
599589 utilruntime .HandleError (fmt .Errorf ("error getting client: %v" , err ))
600590 return err
601591 }
602592
603- for _ , scc := range bootstrappolicy .GetBootstrapSecurityContextConstraints (bootstrapSCCGroups , bootstrapSCCUsers ) {
604- _ , err := securityClient .SecurityContextConstraints ().Create (scc )
605- if kapierror .IsAlreadyExists (err ) {
593+ // all SCC must exist before we report success
594+ err = wait .PollUntil (1 * time .Second , func () (bool , error ) {
595+ anySCCMissing := false
596+ for _ , scc := range bootstrappolicy .GetBootstrapSecurityContextConstraints (bootstrapSCCGroups , bootstrapSCCUsers ) {
597+ _ , err := securityClient .SecurityContextConstraints ().Create (scc )
598+ if err == nil {
599+ klog .Infof ("Created default security context constraint %s" , scc .Name )
600+ continue
601+ }
602+ if kapierror .IsAlreadyExists (err ) {
603+ klog .V (4 ).Infof ("default security context constraint %s, already exists" , scc .Name )
604+ continue
605+ }
606+ anySCCMissing = true
607+ utilruntime .HandleError (fmt .Errorf ("unable to create default security context constraint %s; %v" , scc .Name , err ))
606608 continue
607609 }
608- if err != nil {
609- utilruntime .HandleError (fmt .Errorf ("unable to create default security context constraint %s. Got error: %v" , scc .Name , err ))
610- continue
610+ if anySCCMissing {
611+ return false , nil
611612 }
612- klog .Infof ("Created default security context constraint %s" , scc .Name )
613+
614+ return true , nil
615+ }, context .StopCh )
616+ if err != nil {
617+ utilruntime .HandleError (fmt .Errorf ("error creating SCC: %v" , err ))
618+ return err
613619 }
614620
615621 // until we only use the CRD, this has to be done twice. Once for CRD creation, once when aggregated APIs take over. Remove after we
616622 // switch
617623 go func () {
618- wait .PollUntil (10 * time .Second , func () (bool , error ) {
624+ wait .PollUntil (5 * time .Second , func () (bool , error ) {
619625 for _ , scc := range bootstrappolicy .GetBootstrapSecurityContextConstraints (bootstrapSCCGroups , bootstrapSCCUsers ) {
620626 _ , err := securityClient .SecurityContextConstraints ().Create (scc )
621627 if kapierror .IsAlreadyExists (err ) {
0 commit comments