From d54c4c8a7f7189ec9ac2ff4912c2b330f51acc40 Mon Sep 17 00:00:00 2001 From: Jordan Raychev Date: Mon, 27 Oct 2025 10:56:14 +0200 Subject: [PATCH 1/2] Fix cluster name parsing logic --- internal/controller/managedmetric_controller.go | 7 +------ internal/controller/metric_controller_helpers_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/internal/controller/managedmetric_controller.go b/internal/controller/managedmetric_controller.go index c1b4aed..1762017 100644 --- a/internal/controller/managedmetric_controller.go +++ b/internal/controller/managedmetric_controller.go @@ -20,7 +20,6 @@ import ( "context" "fmt" "net/url" - "strings" "time" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -309,11 +308,7 @@ func getClusterInfo(config *rest.Config) (string, error) { return "localhost", nil } - // Remove any prefix (like "kubernetes" or "kubernetes.default.svc") - parts := strings.Split(hostname, ".") - clusterName := parts[0] - - return clusterName, nil + return hostname, nil } // OrchestratorFactory is a function type for creating orchestrators diff --git a/internal/controller/metric_controller_helpers_test.go b/internal/controller/metric_controller_helpers_test.go index 6a776fa..a583749 100644 --- a/internal/controller/metric_controller_helpers_test.go +++ b/internal/controller/metric_controller_helpers_test.go @@ -45,22 +45,22 @@ func TestGetClusterInfo(t *testing.T) { { name: "KubernetesService", host: "https://kubernetes.default.svc:6443", - expectedName: "kubernetes", + expectedName: "kubernetes.default.svc", }, { name: "CustomClusterName", host: "https://my-cluster-api.example.com:6443", - expectedName: "my-cluster-api", + expectedName: "my-cluster-api.example.com", }, { name: "IPAddress", host: "https://192.168.1.1:6443", - expectedName: "192", // The function only extracts the first part of the IP address + expectedName: "192.168.1.1", // The function only extracts the first part of the IP address }, { name: "WithPath", host: "https://kubernetes.default.svc:6443/api", - expectedName: "kubernetes", + expectedName: "kubernetes.default.svc", }, } From 859b310c7cee3e73da32191b1a787de8c5f52156 Mon Sep 17 00:00:00 2001 From: Jordan Raychev Date: Wed, 19 Nov 2025 09:03:12 +0200 Subject: [PATCH 2/2] Fix cluster name (#5) * fix cluster name logic * remove comment --- internal/controller/metric_controller_helpers_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/controller/metric_controller_helpers_test.go b/internal/controller/metric_controller_helpers_test.go index a583749..d41b22d 100644 --- a/internal/controller/metric_controller_helpers_test.go +++ b/internal/controller/metric_controller_helpers_test.go @@ -55,7 +55,7 @@ func TestGetClusterInfo(t *testing.T) { { name: "IPAddress", host: "https://192.168.1.1:6443", - expectedName: "192.168.1.1", // The function only extracts the first part of the IP address + expectedName: "192.168.1.1", }, { name: "WithPath",