Skip to content

Commit dfbd95f

Browse files
committed
Bug 1508061: Fix panic during openshift controller options initialization
1 parent 8fc2fe6 commit dfbd95f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pkg/cmd/server/start/start_kube_controller_manager.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func createRecylerTemplate(recyclerImage string) (string, error) {
217217
}
218218

219219
func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout string, dynamicProvisioningEnabled bool, cmdLineArgs map[string][]string,
220-
recyclerImage string, informers *informers) {
220+
initialized chan struct{}, recyclerImage string, informers *informers) {
221221
controllerapp.CreateControllerContext = newKubeControllerContext(informers)
222222
controllerapp.StartInformers = func(stop <-chan struct{}) {
223223
informers.Start(stop)
@@ -233,6 +233,9 @@ func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCA
233233
f()
234234
}
235235
}()
236+
// At this point do not mutate cmdLineArgs and signal this back to upper
237+
// level.
238+
close(initialized)
236239

237240
if err != nil {
238241
glog.Fatal(err)

pkg/cmd/server/start/start_master.go

+7
Original file line numberDiff line numberDiff line change
@@ -475,16 +475,23 @@ func (m *Master) Start() error {
475475
// continuously run the scheduler while we have the primary lease
476476
go runEmbeddedScheduler(m.config.MasterClients.OpenShiftLoopbackKubeConfig, m.config.KubernetesMasterConfig.SchedulerConfigFile, m.config.KubernetesMasterConfig.SchedulerArguments)
477477

478+
controllerArgumentsInitialized := make(chan struct{})
479+
478480
go runEmbeddedKubeControllerManager(
479481
m.config.MasterClients.OpenShiftLoopbackKubeConfig,
480482
m.config.ServiceAccountConfig.PrivateKeyFile,
481483
m.config.ServiceAccountConfig.MasterCA,
482484
m.config.KubernetesMasterConfig.PodEvictionTimeout,
483485
m.config.VolumeConfig.DynamicProvisioningEnabled,
484486
m.config.KubernetesMasterConfig.ControllerArguments,
487+
controllerArgumentsInitialized,
485488
recyclerImage,
486489
informers)
487490

491+
// Wait for the runEmbeddedKubeControllerManager to mutate the
492+
// ControllerArguments to prevent getOpenshiftControllerOptions from
493+
// panicking because of concurrent read/write access.
494+
<-controllerArgumentsInitialized
488495
openshiftControllerOptions, err := getOpenshiftControllerOptions(m.config.KubernetesMasterConfig.ControllerArguments)
489496
if err != nil {
490497
glog.Fatal(err)

0 commit comments

Comments
 (0)