Skip to content

Commit 766a973

Browse files
committed
run openshift and kube controllers on different leases
1 parent ce08d2f commit 766a973

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

pkg/cmd/server/start/start_kube_controller_manager.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func newKubeControllerContext(informers *informers) func(s *controlleroptions.CM
3434
return controllerapp.ControllerContext{}, err
3535
}
3636

37-
// Overwrite the informers, because we have our custom generic informers.
37+
// Overwrite the informers, because we have our custom generic informers for quota.
38+
// TODO update quota to create its own informer like garbage collection or if we split this out, actually add our external types to the kube generic informer
3839
ret.InformerFactory = externalKubeInformersWithExtraGenerics{
3940
SharedInformerFactory: informers.GetExternalKubeInformers(),
4041
genericResourceInformer: informers.ToGenericInformer(),
@@ -225,9 +226,6 @@ func createRecylerTemplate(recyclerImage string) (string, error) {
225226
func runEmbeddedKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout string, dynamicProvisioningEnabled bool, cmdLineArgs map[string][]string,
226227
recyclerImage string, informers *informers) {
227228
controllerapp.CreateControllerContext = newKubeControllerContext(informers)
228-
controllerapp.StartInformers = func(stop <-chan struct{}) {
229-
informers.Start(stop)
230-
}
231229

232230
// TODO we need a real identity for this. Right now it's just using the loopback connection like it used to.
233231
controllerManager, cleanupFunctions, err := newKubeControllerManager(kubeconfigFile, saPrivateKeyFile, saRootCAFile, podEvictionTimeout, recyclerImage, dynamicProvisioningEnabled, cmdLineArgs)
@@ -258,3 +256,8 @@ type externalKubeInformersWithExtraGenerics struct {
258256
func (i externalKubeInformersWithExtraGenerics) ForResource(resource schema.GroupVersionResource) (kinformers.GenericInformer, error) {
259257
return i.genericResourceInformer.ForResource(resource)
260258
}
259+
260+
func (i externalKubeInformersWithExtraGenerics) Start(stopCh <-chan struct{}) {
261+
i.SharedInformerFactory.Start(stopCh)
262+
i.genericResourceInformer.Start(stopCh)
263+
}

pkg/cmd/server/start/start_master.go

+21-21
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,6 @@ func (m *Master) Start() error {
391391
if err != nil {
392392
return err
393393
}
394-
kubeControllerInformers, err := NewInformers(*m.config)
395-
if err != nil {
396-
return err
397-
}
398394

399395
_, config, err := configapi.GetExternalKubeClient(m.config.MasterClients.OpenShiftLoopbackKubeConfig, m.config.MasterClients.OpenShiftLoopbackClientConnectionOverrides)
400396
if err != nil {
@@ -470,38 +466,42 @@ func (m *Master) Start() error {
470466
glog.Fatalf("Controller graceful shutdown requested")
471467
}()
472468

469+
go runEmbeddedScheduler(m.config.MasterClients.OpenShiftLoopbackKubeConfig, m.config.KubernetesMasterConfig.SchedulerConfigFile, m.config.KubernetesMasterConfig.SchedulerArguments)
470+
471+
kubeControllerInformers, err := NewInformers(*m.config)
472+
if err != nil {
473+
return err
474+
}
475+
go runEmbeddedKubeControllerManager(
476+
m.config.MasterClients.OpenShiftLoopbackKubeConfig,
477+
m.config.ServiceAccountConfig.PrivateKeyFile,
478+
m.config.ServiceAccountConfig.MasterCA,
479+
m.config.KubernetesMasterConfig.PodEvictionTimeout,
480+
m.config.VolumeConfig.DynamicProvisioningEnabled,
481+
m.config.KubernetesMasterConfig.ControllerArguments,
482+
recyclerImage,
483+
kubeControllerInformers)
484+
473485
go func() {
474486
controllerPlug.WaitForStart()
475487
if err := waitForHealthyAPIServer(kubeExternal.Discovery().RESTClient()); err != nil {
476488
glog.Fatal(err)
477489
}
478490

479-
// continuously run the scheduler while we have the primary lease
480-
go runEmbeddedScheduler(m.config.MasterClients.OpenShiftLoopbackKubeConfig, m.config.KubernetesMasterConfig.SchedulerConfigFile, m.config.KubernetesMasterConfig.SchedulerArguments)
481-
482-
go runEmbeddedKubeControllerManager(
483-
m.config.MasterClients.OpenShiftLoopbackKubeConfig,
484-
m.config.ServiceAccountConfig.PrivateKeyFile,
485-
m.config.ServiceAccountConfig.MasterCA,
486-
m.config.KubernetesMasterConfig.PodEvictionTimeout,
487-
m.config.VolumeConfig.DynamicProvisioningEnabled,
488-
m.config.KubernetesMasterConfig.ControllerArguments,
489-
recyclerImage,
490-
kubeControllerInformers)
491-
492491
openshiftControllerOptions, err := getOpenshiftControllerOptions(m.config.KubernetesMasterConfig.ControllerArguments)
493492
if err != nil {
494493
glog.Fatal(err)
495494
}
496495

497-
controllerContext := newControllerContext(openshiftControllerOptions, m.config.ControllerConfig.Controllers, privilegedLoopbackConfig, kubeExternal, openshiftControllerInformers, utilwait.NeverStop, make(chan struct{}))
496+
stopCh := utilwait.NeverStop
497+
informersStarted := make(chan struct{})
498+
controllerContext := newControllerContext(openshiftControllerOptions, m.config.ControllerConfig.Controllers, privilegedLoopbackConfig, kubeExternal, openshiftControllerInformers, stopCh, informersStarted)
498499
if err := startControllers(*m.config, allocationController, controllerContext); err != nil {
499500
glog.Fatal(err)
500501
}
501502

502-
openshiftControllerInformers.Start(utilwait.NeverStop)
503-
close(controllerContext.InformersStarted)
504-
503+
openshiftControllerInformers.Start(stopCh)
504+
close(informersStarted)
505505
}()
506506
}
507507

0 commit comments

Comments
 (0)