diff --git a/pkg/cmd/server/start/start_kube_controller_manager.go b/pkg/cmd/server/start/start_kube_controller_manager.go index f45e70a1f997..31be0e3399f0 100644 --- a/pkg/cmd/server/start/start_kube_controller_manager.go +++ b/pkg/cmd/server/start/start_kube_controller_manager.go @@ -217,7 +217,7 @@ func createRecylerTemplate(recyclerImage string) (string, error) { } func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout string, dynamicProvisioningEnabled bool, cmdLineArgs map[string][]string, - recyclerImage string, informers *informers) { + initialized chan struct{}, recyclerImage string, informers *informers) { controllerapp.CreateControllerContext = newKubeControllerContext(informers) controllerapp.StartInformers = func(stop <-chan struct{}) { informers.Start(stop) @@ -233,6 +233,9 @@ func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCA f() } }() + // At this point do not mutate cmdLineArgs and signal this back to upper + // level. + close(initialized) if err != nil { glog.Fatal(err) diff --git a/pkg/cmd/server/start/start_master.go b/pkg/cmd/server/start/start_master.go index 387b39a94e16..9690ef5f2ee0 100644 --- a/pkg/cmd/server/start/start_master.go +++ b/pkg/cmd/server/start/start_master.go @@ -475,6 +475,8 @@ func (m *Master) Start() error { // continuously run the scheduler while we have the primary lease go runEmbeddedScheduler(m.config.MasterClients.OpenShiftLoopbackKubeConfig, m.config.KubernetesMasterConfig.SchedulerConfigFile, m.config.KubernetesMasterConfig.SchedulerArguments) + controllerArgumentsInitialized := make(chan struct{}) + go runEmbeddedKubeControllerManager( m.config.MasterClients.OpenShiftLoopbackKubeConfig, m.config.ServiceAccountConfig.PrivateKeyFile, @@ -482,9 +484,14 @@ func (m *Master) Start() error { m.config.KubernetesMasterConfig.PodEvictionTimeout, m.config.VolumeConfig.DynamicProvisioningEnabled, m.config.KubernetesMasterConfig.ControllerArguments, + controllerArgumentsInitialized, recyclerImage, informers) + // Wait for the runEmbeddedKubeControllerManager to mutate the + // ControllerArguments to prevent getOpenshiftControllerOptions from + // panicking because of concurrent read/write access. + <-controllerArgumentsInitialized openshiftControllerOptions, err := getOpenshiftControllerOptions(m.config.KubernetesMasterConfig.ControllerArguments) if err != nil { glog.Fatal(err)