From dfc84441ef6d1ee6031e61e89c95aaaf85d1bc8d Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Mon, 28 Jul 2025 17:01:25 +0200 Subject: [PATCH 1/6] add metrics for logical clusters count On-behalf-of: @SAP karol.szwaj@sap.com Signed-off-by: Karol Szwaj --- .../logicalcluster_controller.go | 43 +++++++++++++---- pkg/server/controllers.go | 1 + pkg/server/metrics/metrics.go | 47 +++++++++++++++++++ 3 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 pkg/server/metrics/metrics.go diff --git a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go index 535d1d12384..b89944a86cc 100644 --- a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go +++ b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go @@ -20,8 +20,15 @@ import ( "context" "encoding/json" "fmt" + "sync" "time" + kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" + kcprbacinformers "github.com/kcp-dev/client-go/informers/rbac/v1" + kcpkubernetesclientset "github.com/kcp-dev/client-go/kubernetes" + kcprbaclisters "github.com/kcp-dev/client-go/listers/rbac/v1" + kcpmetrics "github.com/kcp-dev/kcp/pkg/server/metrics" + "github.com/kcp-dev/logicalcluster/v3" authenticationv1 "k8s.io/api/authentication/v1" rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/api/equality" @@ -33,11 +40,6 @@ import ( "k8s.io/client-go/util/workqueue" "k8s.io/klog/v2" - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" - kcprbacinformers "github.com/kcp-dev/client-go/informers/rbac/v1" - kcpkubernetesclientset "github.com/kcp-dev/client-go/kubernetes" - kcprbaclisters "github.com/kcp-dev/client-go/listers/rbac/v1" - "github.com/kcp-dev/kcp/pkg/logging" "github.com/kcp-dev/kcp/pkg/reconciler/events" corev1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" @@ -58,6 +60,7 @@ func NewController( kubeClusterClient kcpkubernetesclientset.ClusterInterface, logicalClusterInformer corev1alpha1informers.LogicalClusterClusterInformer, clusterRoleBindingInformer kcprbacinformers.ClusterRoleBindingClusterInformer, + shardName string, ) *Controller { c := &Controller{ queue: workqueue.NewTypedRateLimitingQueueWithConfig( @@ -69,6 +72,8 @@ func NewController( kubeClusterClient: kubeClusterClient, logicalClusterLister: logicalClusterInformer.Lister(), clusterRoleBindingLister: clusterRoleBindingInformer.Lister(), + shardName: shardName, + countedClusters: make(map[string]bool), } _, _ = logicalClusterInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ @@ -104,6 +109,9 @@ type Controller struct { logicalClusterLister corev1alpha1listers.LogicalClusterClusterLister clusterRoleBindingLister kcprbaclisters.ClusterRoleBindingClusterLister + mu sync.Mutex + countedClusters map[string]bool + shardName string } func (c *Controller) enqueue(obj interface{}) { @@ -186,11 +194,18 @@ func (c *Controller) process(ctx context.Context, key string) error { logicalCluster, err := c.logicalClusterLister.Cluster(clusterName).Get(corev1alpha1.LogicalClusterName) if err != nil { - if !apierrors.IsNotFound(err) { + if apierrors.IsNotFound(err) { + c.mu.Lock() + if c.countedClusters[clusterName.String()] { + delete(c.countedClusters, clusterName.String()) + kcpmetrics.DecrementLogicalClusterCount(c.shardName) + logger.V(4).Info("LogicalCluster deleted, decremented metrics", "cluster", clusterName) + } + c.mu.Unlock() + } else { logger.Error(err, "failed to get LogicalCluster from lister", "cluster", clusterName) } - - return nil // nothing we can do here + return nil } logger = logging.WithObject(logger, logicalCluster) @@ -201,6 +216,18 @@ func (c *Controller) process(ctx context.Context, key string) error { return nil } + c.mu.Lock() + clusterKey := string(logicalcluster.From(logicalCluster)) + alreadyCounted := c.countedClusters[clusterKey] + if logicalCluster.Status.Phase == corev1alpha1.LogicalClusterPhaseReady && !alreadyCounted { + c.countedClusters[clusterKey] = true + kcpmetrics.IncrementLogicalClusterCount(c.shardName) + } else if logicalCluster.Status.Phase != corev1alpha1.LogicalClusterPhaseReady && alreadyCounted { + delete(c.countedClusters, clusterKey) + kcpmetrics.DecrementLogicalClusterCount(c.shardName) + } + c.mu.Unlock() + // need to create ClusterRoleBinding for owner. ownerAnnotation := logicalCluster.Annotations[tenancyv1alpha1.ExperimentalWorkspaceOwnerAnnotationKey] // some older installations of kcp might have produced an annotation with empty value, so we should diff --git a/pkg/server/controllers.go b/pkg/server/controllers.go index 22e70f094ea..d7826fdaec3 100644 --- a/pkg/server/controllers.go +++ b/pkg/server/controllers.go @@ -435,6 +435,7 @@ func (s *Server) installTenancyLogicalClusterController(ctx context.Context, con kubeClusterClient, s.KcpSharedInformerFactory.Core().V1alpha1().LogicalClusters(), s.KubeSharedInformerFactory.Rbac().V1().ClusterRoleBindings(), + s.Options.Extra.ShardName, ) return s.registerController(&controllerWrapper{ diff --git a/pkg/server/metrics/metrics.go b/pkg/server/metrics/metrics.go new file mode 100644 index 00000000000..57a23beccc2 --- /dev/null +++ b/pkg/server/metrics/metrics.go @@ -0,0 +1,47 @@ +/* +Copyright 2025 The KCP Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" +) + +var ( + logicalClusterCount = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Name: "kcp_logicalcluster_count", + Help: "Number of logical clusters currently running on this shard.", + StabilityLevel: metrics.ALPHA, + }, + []string{"shard"}, + ) +) + +func init() { + legacyregistry.MustRegister(logicalClusterCount) +} + +// IncrementLogicalClusterCount increments the count for the given shard +func IncrementLogicalClusterCount(shardName string) { + logicalClusterCount.WithLabelValues(shardName).Inc() +} + +// DecrementLogicalClusterCount decrements the count for the given shard +func DecrementLogicalClusterCount(shardName string) { + logicalClusterCount.WithLabelValues(shardName).Dec() +} From b172e3abc73dfdde58fac29c3b8beb57f7e20e24 Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Fri, 8 Aug 2025 17:23:17 +0200 Subject: [PATCH 2/6] add event handlers for metrics Signed-off-by: Karol Szwaj On-behalf-of: @SAP karol.szwaj@sap.com --- .../logicalcluster_controller.go | 100 +++++++++++------- pkg/server/metrics/metrics.go | 4 +- 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go index b89944a86cc..32e0eb835ad 100644 --- a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go +++ b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go @@ -23,12 +23,6 @@ import ( "sync" "time" - kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" - kcprbacinformers "github.com/kcp-dev/client-go/informers/rbac/v1" - kcpkubernetesclientset "github.com/kcp-dev/client-go/kubernetes" - kcprbaclisters "github.com/kcp-dev/client-go/listers/rbac/v1" - kcpmetrics "github.com/kcp-dev/kcp/pkg/server/metrics" - "github.com/kcp-dev/logicalcluster/v3" authenticationv1 "k8s.io/api/authentication/v1" rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/api/equality" @@ -40,8 +34,15 @@ import ( "k8s.io/client-go/util/workqueue" "k8s.io/klog/v2" + kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache" + kcprbacinformers "github.com/kcp-dev/client-go/informers/rbac/v1" + kcpkubernetesclientset "github.com/kcp-dev/client-go/kubernetes" + kcprbaclisters "github.com/kcp-dev/client-go/listers/rbac/v1" + "github.com/kcp-dev/logicalcluster/v3" + "github.com/kcp-dev/kcp/pkg/logging" "github.com/kcp-dev/kcp/pkg/reconciler/events" + kcpmetrics "github.com/kcp-dev/kcp/pkg/server/metrics" corev1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1" tenancyv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/tenancy/v1alpha1" corev1alpha1informers "github.com/kcp-dev/kcp/sdk/client/informers/externalversions/core/v1alpha1" @@ -77,13 +78,21 @@ func NewController( } _, _ = logicalClusterInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { c.enqueue(obj) }, - UpdateFunc: func(obj, _ interface{}) { c.enqueue(obj) }, - DeleteFunc: func(obj interface{}) { c.enqueue(obj) }, + AddFunc: func(obj any) { + c.enqueue(obj) + c.handleMetrics(obj) + }, + UpdateFunc: func(oldObj, newObj any) { + c.enqueue(newObj) + c.handleMetrics(newObj) + }, + DeleteFunc: func(obj any) { + c.enqueue(obj) + c.handleMetricsOnDelete(obj) + }, }) - _, _ = clusterRoleBindingInformer.Informer().AddEventHandler(events.WithoutSyncs(cache.FilteringResourceEventHandler{ - FilterFunc: func(obj interface{}) bool { + FilterFunc: func(obj any) bool { crb, ok := obj.(*rbacv1.ClusterRoleBinding) if !ok { return false @@ -91,9 +100,9 @@ func NewController( return crb.Name == workspaceAdminClusterRoleBindingName }, Handler: cache.ResourceEventHandlerFuncs{ - AddFunc: func(obj interface{}) { c.enqueueCRB(obj) }, - UpdateFunc: func(obj, _ interface{}) { c.enqueueCRB(obj) }, - DeleteFunc: func(obj interface{}) { c.enqueueCRB(obj) }, + AddFunc: func(obj any) { c.enqueueCRB(obj) }, + UpdateFunc: func(obj, _ any) { c.enqueueCRB(obj) }, + DeleteFunc: func(obj any) { c.enqueueCRB(obj) }, }, })) @@ -114,7 +123,7 @@ type Controller struct { shardName string } -func (c *Controller) enqueue(obj interface{}) { +func (c *Controller) enqueue(obj any) { key, err := kcpcache.DeletionHandlingMetaClusterNamespaceKeyFunc(obj) if err != nil { utilruntime.HandleError(err) @@ -125,7 +134,7 @@ func (c *Controller) enqueue(obj interface{}) { c.queue.Add(key) } -func (c *Controller) enqueueCRB(obj interface{}) { +func (c *Controller) enqueueCRB(obj any) { key, err := kcpcache.DeletionHandlingMetaClusterNamespaceKeyFunc(obj) if err != nil { utilruntime.HandleError(err) @@ -195,14 +204,6 @@ func (c *Controller) process(ctx context.Context, key string) error { logicalCluster, err := c.logicalClusterLister.Cluster(clusterName).Get(corev1alpha1.LogicalClusterName) if err != nil { if apierrors.IsNotFound(err) { - c.mu.Lock() - if c.countedClusters[clusterName.String()] { - delete(c.countedClusters, clusterName.String()) - kcpmetrics.DecrementLogicalClusterCount(c.shardName) - logger.V(4).Info("LogicalCluster deleted, decremented metrics", "cluster", clusterName) - } - c.mu.Unlock() - } else { logger.Error(err, "failed to get LogicalCluster from lister", "cluster", clusterName) } return nil @@ -216,18 +217,6 @@ func (c *Controller) process(ctx context.Context, key string) error { return nil } - c.mu.Lock() - clusterKey := string(logicalcluster.From(logicalCluster)) - alreadyCounted := c.countedClusters[clusterKey] - if logicalCluster.Status.Phase == corev1alpha1.LogicalClusterPhaseReady && !alreadyCounted { - c.countedClusters[clusterKey] = true - kcpmetrics.IncrementLogicalClusterCount(c.shardName) - } else if logicalCluster.Status.Phase != corev1alpha1.LogicalClusterPhaseReady && alreadyCounted { - delete(c.countedClusters, clusterKey) - kcpmetrics.DecrementLogicalClusterCount(c.shardName) - } - c.mu.Unlock() - // need to create ClusterRoleBinding for owner. ownerAnnotation := logicalCluster.Annotations[tenancyv1alpha1.ExperimentalWorkspaceOwnerAnnotationKey] // some older installations of kcp might have produced an annotation with empty value, so we should @@ -279,3 +268,42 @@ func (c *Controller) process(ctx context.Context, key string) error { _, err = c.kubeClusterClient.Cluster(clusterName.Path()).RbacV1().ClusterRoleBindings().Update(ctx, newBinding, metav1.UpdateOptions{}) return err } + +func (c *Controller) handleMetrics(obj any) { + logicalCluster, ok := obj.(*corev1alpha1.LogicalCluster) + if !ok { + return + } + + if logicalCluster.Status.Phase == corev1alpha1.LogicalClusterPhaseReady { + c.mu.Lock() + clusterKey := string(logicalcluster.From(logicalCluster)) + if !c.countedClusters[clusterKey] { + c.countedClusters[clusterKey] = true + kcpmetrics.IncrementLogicalClusterCount(c.shardName) + } + c.mu.Unlock() + } +} + +func (c *Controller) handleMetricsOnDelete(obj any) { + logicalCluster, ok := obj.(*corev1alpha1.LogicalCluster) + if !ok { + if tombstone, ok := obj.(cache.DeletedFinalStateUnknown); ok { + logicalCluster, ok = tombstone.Obj.(*corev1alpha1.LogicalCluster) + if !ok { + return + } + } else { + return + } + } + + c.mu.Lock() + clusterKey := string(logicalcluster.From(logicalCluster)) + if c.countedClusters[clusterKey] { + delete(c.countedClusters, clusterKey) + kcpmetrics.DecrementLogicalClusterCount(c.shardName) + } + c.mu.Unlock() +} diff --git a/pkg/server/metrics/metrics.go b/pkg/server/metrics/metrics.go index 57a23beccc2..27a6be0ebbd 100644 --- a/pkg/server/metrics/metrics.go +++ b/pkg/server/metrics/metrics.go @@ -36,12 +36,12 @@ func init() { legacyregistry.MustRegister(logicalClusterCount) } -// IncrementLogicalClusterCount increments the count for the given shard +// IncrementLogicalClusterCount increments the count for the given shard. func IncrementLogicalClusterCount(shardName string) { logicalClusterCount.WithLabelValues(shardName).Inc() } -// DecrementLogicalClusterCount decrements the count for the given shard +// DecrementLogicalClusterCount decrements the count for the given shard. func DecrementLogicalClusterCount(shardName string) { logicalClusterCount.WithLabelValues(shardName).Dec() } From 9ccda86847742aa8bbf22a0ba8224a18d07a6c74 Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Mon, 11 Aug 2025 16:58:42 +0200 Subject: [PATCH 3/6] add logical cluster count for all clusters, despite their readiness Signed-off-by: Karol Szwaj On-behalf-of: @SAP karol.szwaj@sap.com --- .../logicalcluster_controller.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go index 32e0eb835ad..34d016d693a 100644 --- a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go +++ b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go @@ -203,10 +203,10 @@ func (c *Controller) process(ctx context.Context, key string) error { logicalCluster, err := c.logicalClusterLister.Cluster(clusterName).Get(corev1alpha1.LogicalClusterName) if err != nil { - if apierrors.IsNotFound(err) { + if !apierrors.IsNotFound(err) { logger.Error(err, "failed to get LogicalCluster from lister", "cluster", clusterName) } - return nil + return nil // nothing we can do here } logger = logging.WithObject(logger, logicalCluster) @@ -275,15 +275,13 @@ func (c *Controller) handleMetrics(obj any) { return } - if logicalCluster.Status.Phase == corev1alpha1.LogicalClusterPhaseReady { - c.mu.Lock() - clusterKey := string(logicalcluster.From(logicalCluster)) - if !c.countedClusters[clusterKey] { - c.countedClusters[clusterKey] = true - kcpmetrics.IncrementLogicalClusterCount(c.shardName) - } - c.mu.Unlock() + c.mu.Lock() + clusterKey := string(logicalcluster.From(logicalCluster)) + if !c.countedClusters[clusterKey] { + c.countedClusters[clusterKey] = true + kcpmetrics.IncrementLogicalClusterCount(c.shardName) } + c.mu.Unlock() } func (c *Controller) handleMetricsOnDelete(obj any) { From 37ba8e9faa265fabf2541e7940888bcc5e012725 Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Thu, 14 Aug 2025 11:24:41 +0200 Subject: [PATCH 4/6] add phase label for count metric and process it Signed-off-by: Karol Szwaj On-behalf-of: @SAP karol.szwaj@sap.com --- .../logicalcluster_controller.go | 56 +++++++++++++++---- pkg/server/metrics/metrics.go | 16 +++--- 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go index 34d016d693a..0ca3f4adb30 100644 --- a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go +++ b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go @@ -74,7 +74,7 @@ func NewController( logicalClusterLister: logicalClusterInformer.Lister(), clusterRoleBindingLister: clusterRoleBindingInformer.Lister(), shardName: shardName, - countedClusters: make(map[string]bool), + countedClusters: make(map[string]string), } _, _ = logicalClusterInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ @@ -84,7 +84,7 @@ func NewController( }, UpdateFunc: func(oldObj, newObj any) { c.enqueue(newObj) - c.handleMetrics(newObj) + c.handleMetricsOnUpdate(oldObj, newObj) }, DeleteFunc: func(obj any) { c.enqueue(obj) @@ -119,7 +119,7 @@ type Controller struct { clusterRoleBindingLister kcprbaclisters.ClusterRoleBindingClusterLister mu sync.Mutex - countedClusters map[string]bool + countedClusters map[string]string shardName string } @@ -276,12 +276,45 @@ func (c *Controller) handleMetrics(obj any) { } c.mu.Lock() + defer c.mu.Unlock() + clusterKey := string(logicalcluster.From(logicalCluster)) - if !c.countedClusters[clusterKey] { - c.countedClusters[clusterKey] = true - kcpmetrics.IncrementLogicalClusterCount(c.shardName) + phase := string(logicalCluster.Status.Phase) + if _, exists := c.countedClusters[clusterKey]; !exists { + c.countedClusters[clusterKey] = phase + if phase != "" { + kcpmetrics.IncrementLogicalClusterCount(c.shardName, phase) + } + } +} + +func (c *Controller) handleMetricsOnUpdate(oldObj, newObj any) { + oldLogicalCluster, ok := oldObj.(*corev1alpha1.LogicalCluster) + if !ok { + return + } + + newLogicalCluster, ok := newObj.(*corev1alpha1.LogicalCluster) + if !ok { + return + } + + c.mu.Lock() + defer c.mu.Unlock() + + clusterKey := string(logicalcluster.From(newLogicalCluster)) + oldPhase := string(oldLogicalCluster.Status.Phase) + newPhase := string(newLogicalCluster.Status.Phase) + + if oldPhase != newPhase { + if oldPhase != "" { + kcpmetrics.DecrementLogicalClusterCount(c.shardName, oldPhase) + } + if newPhase != "" { + kcpmetrics.IncrementLogicalClusterCount(c.shardName, newPhase) + } + c.countedClusters[clusterKey] = newPhase } - c.mu.Unlock() } func (c *Controller) handleMetricsOnDelete(obj any) { @@ -298,10 +331,13 @@ func (c *Controller) handleMetricsOnDelete(obj any) { } c.mu.Lock() + defer c.mu.Unlock() + clusterKey := string(logicalcluster.From(logicalCluster)) - if c.countedClusters[clusterKey] { + if phase, exists := c.countedClusters[clusterKey]; exists { delete(c.countedClusters, clusterKey) - kcpmetrics.DecrementLogicalClusterCount(c.shardName) + if phase != "" { + kcpmetrics.DecrementLogicalClusterCount(c.shardName, phase) + } } - c.mu.Unlock() } diff --git a/pkg/server/metrics/metrics.go b/pkg/server/metrics/metrics.go index 27a6be0ebbd..28489fe1423 100644 --- a/pkg/server/metrics/metrics.go +++ b/pkg/server/metrics/metrics.go @@ -25,10 +25,10 @@ var ( logicalClusterCount = metrics.NewGaugeVec( &metrics.GaugeOpts{ Name: "kcp_logicalcluster_count", - Help: "Number of logical clusters currently running on this shard.", + Help: "Number of logical clusters currently running with specific phases on this shard.", StabilityLevel: metrics.ALPHA, }, - []string{"shard"}, + []string{"shard", "phase"}, ) ) @@ -36,12 +36,12 @@ func init() { legacyregistry.MustRegister(logicalClusterCount) } -// IncrementLogicalClusterCount increments the count for the given shard. -func IncrementLogicalClusterCount(shardName string) { - logicalClusterCount.WithLabelValues(shardName).Inc() +// IncrementLogicalClusterCount increments the count for the given shard and phase. +func IncrementLogicalClusterCount(shardName string, phase string) { + logicalClusterCount.WithLabelValues(shardName, phase).Inc() } -// DecrementLogicalClusterCount decrements the count for the given shard. -func DecrementLogicalClusterCount(shardName string) { - logicalClusterCount.WithLabelValues(shardName).Dec() +// DecrementLogicalClusterCount decrements the count for the given shard and phase. +func DecrementLogicalClusterCount(shardName string, phase string) { + logicalClusterCount.WithLabelValues(shardName, phase).Dec() } From f18404136f0aecb65a74bd1f1f22fda5c0f24a48 Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Thu, 28 Aug 2025 13:22:47 +0200 Subject: [PATCH 5/6] Update pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go Co-authored-by: Nelo-T. Wallus <10514301+ntnn@users.noreply.github.com> --- .../tenancy/logicalcluster/logicalcluster_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go index 0ca3f4adb30..61acb6893ee 100644 --- a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go +++ b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go @@ -80,7 +80,7 @@ func NewController( _, _ = logicalClusterInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: func(obj any) { c.enqueue(obj) - c.handleMetrics(obj) + c.handleMetricsOnAdd(obj) }, UpdateFunc: func(oldObj, newObj any) { c.enqueue(newObj) From 57a23b97afebf3e2d181bd307b5db55b006c508e Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Thu, 28 Aug 2025 13:22:53 +0200 Subject: [PATCH 6/6] Update pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go Co-authored-by: Nelo-T. Wallus <10514301+ntnn@users.noreply.github.com> --- .../tenancy/logicalcluster/logicalcluster_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go index 61acb6893ee..1f5c280da26 100644 --- a/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go +++ b/pkg/reconciler/tenancy/logicalcluster/logicalcluster_controller.go @@ -269,7 +269,7 @@ func (c *Controller) process(ctx context.Context, key string) error { return err } -func (c *Controller) handleMetrics(obj any) { +func (c *Controller) handleMetricsOnAdd(obj any) { logicalCluster, ok := obj.(*corev1alpha1.LogicalCluster) if !ok { return