Skip to content

Commit 546774c

Browse files
Merge pull request #16088 from deads2k/controller-09-disable-hpa
Automatic merge from submit-queue (batch tested with PRs 15995, 16094, 16088) stop overwriting the HPA controller and just write our own This removes the last customization of the upstream controller init functions, disables the kube hpa init, and runs our own hpa init
2 parents a0c7479 + caa579c commit 546774c

File tree

6 files changed

+27
-60
lines changed

6 files changed

+27
-60
lines changed

Diff for: pkg/cmd/server/kubernetes/master/controller/config.go

-44
This file was deleted.

Diff for: pkg/cmd/server/kubernetes/master/controller/hpa.go renamed to pkg/cmd/server/origin/controller/autoscaling.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
osclient "github.com/openshift/origin/pkg/client"
88
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
99
clientgoclientset "k8s.io/client-go/kubernetes"
10-
kubecontroller "k8s.io/kubernetes/cmd/kube-controller-manager/app"
1110
kubeclientset "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
1211
)
1312

@@ -18,7 +17,9 @@ type HorizontalPodAutoscalerControllerConfig struct {
1817
HeapsterNamespace string
1918
}
2019

21-
func (c *HorizontalPodAutoscalerControllerConfig) RunController(ctx kubecontroller.ControllerContext) (bool, error) {
20+
func (c *HorizontalPodAutoscalerControllerConfig) RunController(originCtx ControllerContext) (bool, error) {
21+
ctx := originCtx.KubeControllerContext
22+
2223
hpaClientConfig := ctx.ClientBuilder.ConfigOrDie(bootstrappolicy.InfraHorizontalPodAutoscalerControllerServiceAccountName)
2324

2425
hpaClient, err := kubeclientset.NewForConfig(hpaClientConfig)

Diff for: pkg/cmd/server/origin/controller/config.go

+11
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ type OpenshiftControllerConfig struct {
5858
IngressIPControllerConfig IngressIPControllerConfig
5959

6060
ClusterQuotaReconciliationControllerConfig ClusterQuotaReconciliationControllerConfig
61+
62+
HorizontalPodAutoscalerControllerConfig HorizontalPodAutoscalerControllerConfig
6163
}
6264

6365
func (c *OpenshiftControllerConfig) GetControllerInitializers() (map[string]InitFunc, error) {
@@ -88,6 +90,10 @@ func (c *OpenshiftControllerConfig) GetControllerInitializers() (map[string]Init
8890
ret["openshift.io/resourcequota"] = RunResourceQuotaManager
8991
ret["openshift.io/cluster-quota-reconciliation"] = c.ClusterQuotaReconciliationControllerConfig.RunController
9092

93+
// overrides the Kube HPA controller config, so that we can point it at an HTTPS Heapster
94+
// in openshift-infra, and pass it a scale client that knows how to scale DCs
95+
ret["openshift.io/horizontalpodautoscaling"] = c.HorizontalPodAutoscalerControllerConfig.RunController
96+
9197
return ret, nil
9298
}
9399

@@ -218,5 +224,10 @@ func BuildOpenshiftControllerConfig(options configapi.MasterConfig) (*OpenshiftC
218224
DefaultReplenishmentSyncPeriod: 12 * time.Hour,
219225
}
220226

227+
// TODO this goes away with a truly generic autoscaler
228+
ret.HorizontalPodAutoscalerControllerConfig = HorizontalPodAutoscalerControllerConfig{
229+
HeapsterNamespace: options.PolicyConfig.OpenShiftInfrastructureNamespace,
230+
}
231+
221232
return ret, nil
222233
}

Diff for: pkg/cmd/server/kubernetes/master/controller/volumes.go renamed to pkg/cmd/server/start/start_kube_controller_manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package controller
1+
package start
22

33
import (
44
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"

Diff for: pkg/cmd/server/start/start_master.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ import (
2727
clientgoclientset "k8s.io/client-go/kubernetes"
2828
"k8s.io/client-go/tools/cache"
2929
aggregatorinstall "k8s.io/kube-aggregator/pkg/apis/apiregistration/install"
30+
kubecontroller "k8s.io/kubernetes/cmd/kube-controller-manager/app"
3031
kapi "k8s.io/kubernetes/pkg/api"
3132
"k8s.io/kubernetes/pkg/capabilities"
3233
kinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions"
3334
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
3435
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
3536
kubelettypes "k8s.io/kubernetes/pkg/kubelet/types"
3637
"k8s.io/kubernetes/pkg/master"
38+
"k8s.io/kubernetes/pkg/volume"
3739
kutilerrors "k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/errors"
3840

3941
assetapiserver "github.com/openshift/origin/pkg/assets/apiserver"
@@ -46,7 +48,6 @@ import (
4648
"github.com/openshift/origin/pkg/cmd/server/etcd"
4749
"github.com/openshift/origin/pkg/cmd/server/etcd/etcdserver"
4850
kubernetes "github.com/openshift/origin/pkg/cmd/server/kubernetes/master"
49-
kubecontrollers "github.com/openshift/origin/pkg/cmd/server/kubernetes/master/controller"
5051
"github.com/openshift/origin/pkg/cmd/server/origin"
5152
origincontrollers "github.com/openshift/origin/pkg/cmd/server/origin/controller"
5253
originrest "github.com/openshift/origin/pkg/cmd/server/origin/rest"
@@ -406,11 +407,13 @@ func (m *Master) Start() error {
406407
return err
407408
}
408409

409-
// you can't double run healthz, so only do this next bit if we aren't starting the API
410+
imageTemplate := variable.NewDefaultImageTemplate()
411+
imageTemplate.Format = m.config.ImageConfig.Format
412+
imageTemplate.Latest = m.config.ImageConfig.Latest
413+
volume.NewPersistentVolumeRecyclerPodTemplate = newPersistentVolumeRecyclerPodTemplate(imageTemplate.ExpandOrDie("recycler"))
414+
410415
if !m.api {
411-
imageTemplate := variable.NewDefaultImageTemplate()
412-
imageTemplate.Format = m.config.ImageConfig.Format
413-
imageTemplate.Latest = m.config.ImageConfig.Latest
416+
// you can't double run healthz, so only do this next bit if we aren't starting the API
414417

415418
glog.Infof("Starting controllers on %s (%s)", m.config.ServingInfo.BindAddress, version.Get().String())
416419
if len(m.config.DisabledFeatures) > 0 {
@@ -655,10 +658,6 @@ func startControllers(options configapi.MasterConfig, allocationController origi
655658
if err != nil {
656659
return err
657660
}
658-
kubeControllerConfig, err := kubecontrollers.BuildKubeControllerConfig(options)
659-
if err != nil {
660-
return err
661-
}
662661

663662
// We need to start the serviceaccount-tokens controller first as it provides token
664663
// generation for other controllers.
@@ -703,10 +702,8 @@ func startControllers(options configapi.MasterConfig, allocationController origi
703702

704703
allocationController.RunSecurityAllocationController()
705704

706-
kubernetesControllerInitializers, err := kubeControllerConfig.GetControllerInitializers()
707-
if err != nil {
708-
return err
709-
}
705+
// set the upstream default until it is configurable
706+
kubernetesControllerInitializers := kubecontroller.NewControllerInitializers()
710707
openshiftControllerInitializers, err := openshiftControllerConfig.GetControllerInitializers()
711708
if err != nil {
712709
return err
@@ -757,6 +754,8 @@ func getExcludedControllers(options configapi.MasterConfig) sets.String {
757754
"ttl",
758755
"bootstrapsigner",
759756
"tokencleaner",
757+
// remove the HPA controller until it is generic
758+
"horizontalpodautoscaling",
760759
)
761760
if !configapi.IsBuildEnabled(&options) {
762761
excludedControllers.Insert("openshift.io/build")

0 commit comments

Comments
 (0)