Skip to content

Commit 693e7e3

Browse files
committed
azure: Fix disk deletion loop during cluster teardown
Signed-off-by: Ciprian Hacman <ciprian@hakman.dev>
1 parent 5ed100f commit 693e7e3

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

pkg/resources/azure/azure.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package azure
1919
import (
2020
"context"
2121
"fmt"
22+
"strings"
2223

2324
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
2425
authz "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v3"
@@ -80,11 +81,14 @@ func (g *resourceGetter) listResourcesAzure() (map[string]*resources.Resource, e
8081
}
8182

8283
// Convert a slice of resources to a map of resources keyed by type and ID.
84+
// Normalize IDs to lowercase since Azure resource IDs are case-insensitive
85+
// but different Azure APIs may return different casing for the same resource.
8386
resources := make(map[string]*resources.Resource)
8487
for _, r := range rs {
8588
if r.Done {
8689
continue
8790
}
91+
r.ID = strings.ToLower(r.ID)
8892
resources[toKey(r.Type, r.ID)] = r
8993
}
9094
return resources, nil
@@ -780,5 +784,5 @@ func (g *resourceGetter) isOwnedByCluster(tags map[string]*string) bool {
780784
}
781785

782786
func toKey(rtype, id string) string {
783-
return rtype + ":" + id
787+
return rtype + ":" + strings.ToLower(id)
784788
}

upup/pkg/fi/cloudup/azure/disk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (c *disksClientImpl) CreateOrUpdate(ctx context.Context, resourceGroupName,
5151

5252
func (c *disksClientImpl) List(ctx context.Context, resourceGroupName string) ([]*compute.Disk, error) {
5353
var l []*compute.Disk
54-
pager := c.c.NewListPager(nil)
54+
pager := c.c.NewListByResourceGroupPager(resourceGroupName, nil)
5555
for pager.More() {
5656
resp, err := pager.NextPage(ctx)
5757
if err != nil {

0 commit comments

Comments
 (0)