Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't start template informer unless templateservicebroker is enabled #14579

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions pkg/cmd/server/origin/controller/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
deployercontroller "github.com/openshift/origin/pkg/deploy/controller/deployer"
deployconfigcontroller "github.com/openshift/origin/pkg/deploy/controller/deploymentconfig"
triggercontroller "github.com/openshift/origin/pkg/deploy/controller/generictrigger"
templatecontroller "github.com/openshift/origin/pkg/template/controller"
)

type DeployerControllerConfig struct {
Expand All @@ -26,9 +25,6 @@ type DeploymentTriggerControllerConfig struct {
Codec runtime.Codec
}

type TemplateInstanceControllerConfig struct {
}

func (c *DeployerControllerConfig) RunController(ctx ControllerContext) (bool, error) {
internalDeployerKubeClient, err := ctx.ClientBuilder.KubeInternalClient(bootstrappolicy.InfraDeployerControllerServiceAccountName)
if err != nil {
Expand Down Expand Up @@ -91,31 +87,3 @@ func (c *DeploymentTriggerControllerConfig) RunController(ctx ControllerContext)

return true, nil
}

func (c *TemplateInstanceControllerConfig) RunController(ctx ControllerContext) (bool, error) {
saName := bootstrappolicy.InfraTemplateInstanceControllerServiceAccountName

internalKubeClient, err := ctx.ClientBuilder.KubeInternalClient(saName)
if err != nil {
return true, err
}

deprecatedOcClient, err := ctx.ClientBuilder.DeprecatedOpenshiftClient(saName)
if err != nil {
return true, err
}

templateClient, err := ctx.ClientBuilder.OpenshiftTemplateClient(saName)
if err != nil {
return true, err
}

go templatecontroller.NewTemplateInstanceController(
deprecatedOcClient,
internalKubeClient,
templateClient.Template(),
ctx.TemplateInformers.Template().InternalVersion().TemplateInstances(),
).Run(5, ctx.Stop)

return true, nil
}
37 changes: 37 additions & 0 deletions pkg/cmd/server/origin/controller/template.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package controller

import (
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
templatecontroller "github.com/openshift/origin/pkg/template/controller"
)

type TemplateInstanceControllerConfig struct {
}

func (c *TemplateInstanceControllerConfig) RunController(ctx ControllerContext) (bool, error) {
saName := bootstrappolicy.InfraTemplateInstanceControllerServiceAccountName

internalKubeClient, err := ctx.ClientBuilder.KubeInternalClient(saName)
if err != nil {
return true, err
}

deprecatedOcClient, err := ctx.ClientBuilder.DeprecatedOpenshiftClient(saName)
if err != nil {
return true, err
}

templateClient, err := ctx.ClientBuilder.OpenshiftTemplateClient(saName)
if err != nil {
return true, err
}

go templatecontroller.NewTemplateInstanceController(
deprecatedOcClient,
internalKubeClient,
templateClient.Template(),
ctx.TemplateInformers.Template().InternalVersion().TemplateInstances(),
).Run(5, ctx.Stop)

return true, nil
}
16 changes: 9 additions & 7 deletions pkg/cmd/server/origin/master_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,15 @@ func BuildMasterConfig(options configapi.MasterConfig) (*MasterConfig, error) {
templateInformers := templateinformer.NewSharedInformerFactory(templateClient, defaultInformerResyncPeriod)
informerFactory := shared.NewInformerFactory(internalkubeInformerFactory, externalkubeInformerFactory, privilegedLoopbackKubeClientsetInternal, privilegedLoopbackOpenShiftClient, customListerWatchers, defaultInformerResyncPeriod)

err = templateInformers.Template().InternalVersion().Templates().Informer().AddIndexers(cache.Indexers{
templateapi.TemplateUIDIndex: func(obj interface{}) ([]string, error) {
return []string{string(obj.(*templateapi.Template).UID)}, nil
},
})
if err != nil {
return nil, err
if options.TemplateServiceBrokerConfig != nil {
err = templateInformers.Template().InternalVersion().Templates().Informer().AddIndexers(cache.Indexers{
templateapi.TemplateUIDIndex: func(obj interface{}) ([]string, error) {
return []string{string(obj.(*templateapi.Template).UID)}, nil
},
})
if err != nil {
return nil, err
}
}

imageTemplate := variable.NewDefaultImageTemplate()
Expand Down