Skip to content

Commit

Permalink
Merge pull request #113340 from Richabanker/cloud-cm-metrics-slis
Browse files Browse the repository at this point in the history
add metrics/slis to cloud-controller-manager health checks
  • Loading branch information
k8s-ci-robot committed Nov 8, 2022
2 parents 81bd249 + 187a340 commit 83fe3aa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions staging/src/k8s.io/cloud-provider/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apiserver/pkg/server/healthz"
utilfeature "k8s.io/apiserver/pkg/util/feature"
cacheddiscovery "k8s.io/client-go/discovery/cached"
"k8s.io/client-go/informers"
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
Expand All @@ -46,7 +47,9 @@ import (
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/cli/globalflag"
"k8s.io/component-base/configz"
"k8s.io/component-base/metrics/features"
controllersmetrics "k8s.io/component-base/metrics/prometheus/controllers"
"k8s.io/component-base/metrics/prometheus/slis"
"k8s.io/component-base/term"
"k8s.io/component-base/version"
"k8s.io/component-base/version/verflag"
Expand All @@ -59,6 +62,10 @@ import (
"k8s.io/klog/v2"
)

func init() {
utilruntime.Must(features.AddFeatureGates(utilfeature.DefaultMutableFeatureGate))
}

const (
// ControllerStartJitter is the jitter value used when starting controller managers.
ControllerStartJitter = 1.0
Expand Down Expand Up @@ -168,6 +175,9 @@ func Run(c *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface
// Start the controller manager HTTP server
if c.SecureServing != nil {
unsecuredMux := genericcontrollermanager.NewBaseHandler(&c.ComponentConfig.Generic.Debugging, healthzHandler)
if utilfeature.DefaultFeatureGate.Enabled(features.ComponentSLIs) {
slis.SLIMetricsWithReset{}.Install(unsecuredMux)
}
handler := genericcontrollermanager.BuildHandlerChain(unsecuredMux, &c.Authorization, &c.Authentication)
// TODO: handle stoppedCh and listenerStoppedCh returned by c.SecureServing.Serve
if _, _, err := c.SecureServing.Serve(handler, 0, stopCh); err != nil {
Expand Down

0 comments on commit 83fe3aa

Please sign in to comment.