Skip to content

Commit 7ef23be

Browse files
authored
Merge pull request #8623 from andyzhangx/reduce-get-disk-call
fix: reduce get disk calls in disk attach/detach on VMSS
2 parents dc3df06 + 4057519 commit 7ef23be

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/provider/azure_controller_vmss.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (ss *ScaleSet) AttachDisk(ctx context.Context, nodeName types.NodeName, dis
110110
result, rerr := ss.ComputeClientFactory.GetVirtualMachineScaleSetVMClient().Update(ctx, nodeResourceGroup, vm.VMSSName, vm.InstanceID, *newVM)
111111
if rerr != nil {
112112
klog.Errorf("azureDisk - attach disk list(%+v) on rg(%s) vm(%s) failed, err: %v", diskMap, nodeResourceGroup, nodeName, rerr)
113-
if exists, err := errutils.CheckResourceExistsFromAzcoreError(rerr); exists && err == nil {
113+
if exists, err := errutils.CheckResourceExistsFromAzcoreError(rerr); !exists && !strings.Contains(rerr.Error(), consts.ParentResourceNotFoundMessageCode) && err == nil {
114114
klog.Errorf("azureDisk - begin to filterNonExistingDisks(%v) on rg(%s) vm(%s)", diskMap, nodeResourceGroup, nodeName)
115115
disks := FilterNonExistingDisks(ctx, ss.ComputeClientFactory, newVM.Properties.StorageProfile.DataDisks)
116116
newVM.Properties.StorageProfile.DataDisks = disks
@@ -223,7 +223,7 @@ func (ss *ScaleSet) DetachDisk(ctx context.Context, nodeName types.NodeName, dis
223223
result, rerr = ss.ComputeClientFactory.GetVirtualMachineScaleSetVMClient().Update(ctx, nodeResourceGroup, vm.VMSSName, vm.InstanceID, *newVM)
224224
if rerr != nil {
225225
klog.Errorf("azureDisk - detach disk list(%s) on rg(%s) vm(%s) failed, err: %v", diskMap, nodeResourceGroup, nodeName, rerr)
226-
if exists, err := errutils.CheckResourceExistsFromAzcoreError(rerr); exists && err == nil {
226+
if exists, err := errutils.CheckResourceExistsFromAzcoreError(rerr); !exists && !strings.Contains(rerr.Error(), consts.ParentResourceNotFoundMessageCode) && err == nil {
227227
klog.Errorf("azureDisk - begin to filterNonExistingDisks(%v) on rg(%s) vm(%s)", diskMap, nodeResourceGroup, nodeName)
228228
disks := FilterNonExistingDisks(ctx, ss.ComputeClientFactory, newVM.Properties.StorageProfile.DataDisks)
229229
newVM.Properties.StorageProfile.DataDisks = disks

0 commit comments

Comments
 (0)