From b5d8407ca85aebc6b8643975f660a6398221514d Mon Sep 17 00:00:00 2001 From: Daniel-Redeploy <84455776+Daniel-Redeploy@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:58:54 +0100 Subject: [PATCH 1/2] dont normalize vmss --- .../cloudprovider/clusterapi/clusterapi_utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils.go b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils.go index 58ae58915192..68c2be164436 100644 --- a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils.go +++ b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils.go @@ -201,6 +201,9 @@ func machineSetHasMachineDeploymentOwnerRef(machineSet *unstructured.Unstructure // normalizedProviderString splits s on '/' returning everything after // the last '/'. func normalizedProviderString(s string) normalizedProviderID { + if strings.HasPrefix(s, "azure://") && strings.Contains(s, "virtualMachineScaleSets") { + return normalizedProviderID(s) + } split := strings.Split(s, "/") return normalizedProviderID(split[len(split)-1]) } From ef76ba70817940a103c9972e0bb5d9705c48dd30 Mon Sep 17 00:00:00 2001 From: Daniel-Redeploy <84455776+Daniel-Redeploy@users.noreply.github.com> Date: Tue, 2 Jan 2024 08:19:46 +0100 Subject: [PATCH 2/2] add tests --- .../cloudprovider/clusterapi/clusterapi_utils_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils_test.go b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils_test.go index c6bafd50a969..f56c767de209 100644 --- a/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils_test.go +++ b/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_utils_test.go @@ -422,6 +422,14 @@ func TestUtilNormalizedProviderID(t *testing.T) { description: "id with / characters", providerID: "aws:////i-12345678", expectedID: "i-12345678", + }, { + description: "azure standard vm", + providerID: "azure:///subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachines/control-plane-1cbe5-d4dx7", + expectedID: "control-plane-1cbe5-d4dx7", + }, { + description: "azure vmss", + providerID: "azure:///subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/vmssName/virtualMachines/0", + expectedID: "azure:///subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroupName/providers/Microsoft.Compute/virtualMachineScaleSets/vmssName/virtualMachines/0", }} { t.Run(tc.description, func(t *testing.T) { actualID := normalizedProviderString(tc.providerID)