From f3888883bbc55e49c80e0b2ab2e6c181bfd2c3b0 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Wed, 21 Aug 2019 12:59:19 +0000 Subject: [PATCH] fix: azure disk name matching issue --- .../providers/azure/azure_controller_common.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/cloudprovider/providers/azure/azure_controller_common.go b/pkg/cloudprovider/providers/azure/azure_controller_common.go index 2e957ea54f15..fc092e2351ae 100644 --- a/pkg/cloudprovider/providers/azure/azure_controller_common.go +++ b/pkg/cloudprovider/providers/azure/azure_controller_common.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "path" + "strings" "time" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute" @@ -205,9 +206,9 @@ func (c *controllerCommon) GetDiskLun(diskName, diskURI string, nodeName types.N } for _, disk := range disks { - if disk.Lun != nil && (disk.Name != nil && diskName != "" && *disk.Name == diskName) || - (disk.Vhd != nil && disk.Vhd.URI != nil && diskURI != "" && *disk.Vhd.URI == diskURI) || - (disk.ManagedDisk != nil && *disk.ManagedDisk.ID == diskURI) { + if disk.Lun != nil && (disk.Name != nil && diskName != "" && strings.EqualFold(*disk.Name, diskName)) || + (disk.Vhd != nil && disk.Vhd.URI != nil && diskURI != "" && strings.EqualFold(*disk.Vhd.URI, diskURI)) || + (disk.ManagedDisk != nil && strings.EqualFold(*disk.ManagedDisk.ID, diskURI)) { // found the disk klog.V(2).Infof("azureDisk - find disk: lun %d name %q uri %q", *disk.Lun, diskName, diskURI) return *disk.Lun, nil @@ -259,7 +260,7 @@ func (c *controllerCommon) DisksAreAttached(diskNames []string, nodeName types.N for _, disk := range disks { for _, diskName := range diskNames { - if disk.Name != nil && diskName != "" && *disk.Name == diskName { + if disk.Name != nil && diskName != "" && strings.EqualFold(*disk.Name, diskName) { attached[diskName] = true } }