Skip to content

Commit 4ce220b

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

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

pkg/cmd/server/start/start_kube_controller_manager.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,7 @@ func createRecylerTemplate(recyclerImage string) (string, error) {
216216
return filename, nil
217217
}
218218

219-
func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout string, dynamicProvisioningEnabled bool, cmdLineArgs map[string][]string,
220-
recyclerImage string, informers *informers) {
221-
controllerapp.CreateControllerContext = newKubeControllerContext(informers)
222-
controllerapp.StartInformers = func(stop <-chan struct{}) {
223-
informers.Start(stop)
224-
}
225-
226-
// TODO we need a real identity for this. Right now it's just using the loopback connection like it used to.
227-
controllerManager, cleanupFunctions, err := newKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout, recyclerImage, dynamicProvisioningEnabled, cmdLineArgs)
219+
func runEmbeddedKubeControllerManager(controllerManager *controlleroptions.CMServer, cleanupFunctions []func()) {
228220
defer func() {
229221
// Clean up any temporary files and similar stuff.
230222
// TODO: Make sure this defer is actually called - controllerapp.Run()
@@ -233,17 +225,27 @@ func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCA
233225
f()
234226
}
235227
}()
236-
237-
if err != nil {
238-
glog.Fatal(err)
239-
}
240228
// this does a second leader election, but doing the second leader election will allow us to move out process in
241229
// 3.8 if we so choose.
242230
if err := controllerapp.Run(controllerManager); err != nil {
243231
glog.Fatal(err)
244232
}
245233
}
246234

235+
func setupEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout string, dynamicProvisioningEnabled bool, cmdLineArgs map[string][]string,
236+
recyclerImage string, informers *informers) (*controlleroptions.CMServer, []func()) {
237+
controllerapp.CreateControllerContext = newKubeControllerContext(informers)
238+
controllerapp.StartInformers = func(stop <-chan struct{}) {
239+
informers.Start(stop)
240+
}
241+
// TODO we need a real identity for this. Right now it's just using the loopback connection like it used to.
242+
controllerManager, cleanupFunctions, err := newKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout, recyclerImage, dynamicProvisioningEnabled, cmdLineArgs)
243+
if err != nil {
244+
glog.Fatal(err)
245+
}
246+
return controllerManager, cleanupFunctions
247+
}
248+
247249
type GenericResourceInformer interface {
248250
ForResource(resource schema.GroupVersionResource) (kinformers.GenericInformer, error)
249251
}

pkg/cmd/server/start/start_master.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ 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-
go runEmbeddedKubeControllerManager(
478+
// this mutates the ControllerArguments
479+
controllerManager, cleanupFunctions := setupEmbeddedKubeControllerManager(
479480
m.config.MasterClients.OpenShiftLoopbackKubeConfig,
480481
m.config.ServiceAccountConfig.PrivateKeyFile,
481482
m.config.ServiceAccountConfig.MasterCA,
@@ -485,6 +486,8 @@ func (m *Master) Start() error {
485486
recyclerImage,
486487
informers)
487488

489+
go runEmbeddedKubeControllerManager(controllerManager, cleanupFunctions)
490+
488491
openshiftControllerOptions, err := getOpenshiftControllerOptions(m.config.KubernetesMasterConfig.ControllerArguments)
489492
if err != nil {
490493
glog.Fatal(err)

0 commit comments

Comments
 (0)