Skip to content

Commit

Permalink
Bug 1508061: Fix panic during openshift controller options initializa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
mfojtik committed Nov 1, 2017
1 parent 8fc2fe6 commit 4ce220b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
28 changes: 15 additions & 13 deletions pkg/cmd/server/start/start_kube_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,7 @@ func createRecylerTemplate(recyclerImage string) (string, error) {
return filename, nil
}

func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout string, dynamicProvisioningEnabled bool, cmdLineArgs map[string][]string,
recyclerImage string, informers *informers) {
controllerapp.CreateControllerContext = newKubeControllerContext(informers)
controllerapp.StartInformers = func(stop <-chan struct{}) {
informers.Start(stop)
}

// TODO we need a real identity for this. Right now it's just using the loopback connection like it used to.
controllerManager, cleanupFunctions, err := newKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout, recyclerImage, dynamicProvisioningEnabled, cmdLineArgs)
func runEmbeddedKubeControllerManager(controllerManager *controlleroptions.CMServer, cleanupFunctions []func()) {
defer func() {
// Clean up any temporary files and similar stuff.
// TODO: Make sure this defer is actually called - controllerapp.Run()
Expand All @@ -233,17 +225,27 @@ func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCA
f()
}
}()

if err != nil {
glog.Fatal(err)
}
// this does a second leader election, but doing the second leader election will allow us to move out process in
// 3.8 if we so choose.
if err := controllerapp.Run(controllerManager); err != nil {
glog.Fatal(err)
}
}

func setupEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout string, dynamicProvisioningEnabled bool, cmdLineArgs map[string][]string,
recyclerImage string, informers *informers) (*controlleroptions.CMServer, []func()) {
controllerapp.CreateControllerContext = newKubeControllerContext(informers)
controllerapp.StartInformers = func(stop <-chan struct{}) {
informers.Start(stop)
}
// TODO we need a real identity for this. Right now it's just using the loopback connection like it used to.
controllerManager, cleanupFunctions, err := newKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout, recyclerImage, dynamicProvisioningEnabled, cmdLineArgs)
if err != nil {
glog.Fatal(err)
}
return controllerManager, cleanupFunctions
}

type GenericResourceInformer interface {
ForResource(resource schema.GroupVersionResource) (kinformers.GenericInformer, error)
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/cmd/server/start/start_master.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +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)

go runEmbeddedKubeControllerManager(
// this mutates the ControllerArguments
controllerManager, cleanupFunctions := setupEmbeddedKubeControllerManager(
m.config.MasterClients.OpenShiftLoopbackKubeConfig,
m.config.ServiceAccountConfig.PrivateKeyFile,
m.config.ServiceAccountConfig.MasterCA,
Expand All @@ -485,6 +486,8 @@ func (m *Master) Start() error {
recyclerImage,
informers)

go runEmbeddedKubeControllerManager(controllerManager, cleanupFunctions)

openshiftControllerOptions, err := getOpenshiftControllerOptions(m.config.KubernetesMasterConfig.ControllerArguments)
if err != nil {
glog.Fatal(err)
Expand Down

0 comments on commit 4ce220b

Please sign in to comment.