mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-19 15:39:17 +00:00
feat(ccm): introduce metric route_controller_route_sync_total
This metric tracks the amount of times routes are synced with the cloud provider. This metric is mainly used for A/B tests on the feature gate `CloudControllerManagerWatchBasedRoutesReconciliation` introduced in Kubernetes v1.35.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"k8s.io/component-base/metrics"
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
)
|
||||
|
||||
const (
|
||||
// subsystem is the name of this subsystem used for prometheus metrics.
|
||||
subsystem = "route_controller"
|
||||
)
|
||||
|
||||
var registration sync.Once
|
||||
|
||||
var (
|
||||
routeSyncCount = metrics.NewCounter(&metrics.CounterOpts{
|
||||
Name: "route_sync_total",
|
||||
Subsystem: subsystem,
|
||||
Help: "A metric counting the amount of times routes have been synced with the cloud provider.",
|
||||
StabilityLevel: metrics.BETA,
|
||||
})
|
||||
)
|
||||
|
||||
func registerMetrics() {
|
||||
registration.Do(func() {
|
||||
legacyregistry.MustRegister(routeSyncCount)
|
||||
})
|
||||
}
|
||||
@@ -87,6 +87,8 @@ func New(
|
||||
clusterName string,
|
||||
clusterCIDRs []*net.IPNet,
|
||||
) (*RouteController, error) {
|
||||
registerMetrics()
|
||||
|
||||
if len(clusterCIDRs) == 0 {
|
||||
klog.Fatal("RouteController: Must specify clusterCIDR.")
|
||||
}
|
||||
@@ -247,6 +249,8 @@ func (rc *RouteController) processNextWorkItem(ctx context.Context) bool {
|
||||
}
|
||||
|
||||
func (rc *RouteController) reconcileNodeRoutes(ctx context.Context) error {
|
||||
routeSyncCount.Inc()
|
||||
|
||||
routeList, err := rc.routes.ListRoutes(ctx, rc.clusterName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error listing routes: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user