Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions internal/controller/managedmetric_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"net/url"
"strings"
"time"

apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/metric_controller_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment here is a bit misleading since the whole IP address is now expected. Can you remove the comment please?

},
{
name: "WithPath",
host: "https://kubernetes.default.svc:6443/api",
expectedName: "kubernetes",
expectedName: "kubernetes.default.svc",
},
}

Expand Down