@@ -530,19 +530,22 @@ func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef, hasUnregistered
530
530
return rerr .Error ()
531
531
}
532
532
533
- // Proactively decrement scale set size so that we don't
534
- // go below minimum node count if cache data is stale
535
- // only do it for non-unregistered nodes
536
- if ! hasUnregisteredNodes {
537
- scaleSet .sizeMutex .Lock ()
538
- scaleSet .curSize -= int64 (len (instanceIDs ))
539
- scaleSet .lastSizeRefresh = time .Now ()
540
- scaleSet .sizeMutex .Unlock ()
541
- }
533
+ if ! scaleSet .manager .config .StrictCacheUpdates {
534
+ // Proactively decrement scale set size so that we don't
535
+ // go below minimum node count if cache data is stale
536
+ // only do it for non-unregistered nodes
537
+
538
+ if ! hasUnregisteredNodes {
539
+ scaleSet .sizeMutex .Lock ()
540
+ scaleSet .curSize -= int64 (len (instanceIDs ))
541
+ scaleSet .lastSizeRefresh = time .Now ()
542
+ scaleSet .sizeMutex .Unlock ()
543
+ }
542
544
543
- // Proactively set the status of the instances to be deleted in cache
544
- for _ , instance := range instancesToDelete {
545
- scaleSet .setInstanceStatusByProviderID (instance .Name , cloudprovider.InstanceStatus {State : cloudprovider .InstanceDeleting })
545
+ // Proactively set the status of the instances to be deleted in cache
546
+ for _ , instance := range instancesToDelete {
547
+ scaleSet .setInstanceStatusByProviderID (instance .Name , cloudprovider.InstanceStatus {State : cloudprovider .InstanceDeleting })
548
+ }
546
549
}
547
550
548
551
go scaleSet .waitForDeleteInstances (future , requiredIds )
@@ -558,11 +561,18 @@ func (scaleSet *ScaleSet) waitForDeleteInstances(future *azure.Future, requiredI
558
561
isSuccess , err := isSuccessHTTPResponse (httpResponse , err )
559
562
if isSuccess {
560
563
klog .V (3 ).Infof (".WaitForDeleteInstancesResult(%v) for %s success" , requiredIds .InstanceIds , scaleSet .Name )
561
- // No need to invalidateInstanceCache because instanceStates were proactively set to "deleting"
564
+ if scaleSet .manager .config .StrictCacheUpdates {
565
+ if err := scaleSet .manager .forceRefresh (); err != nil {
566
+ klog .Errorf ("forceRefresh failed with error: %v" , err )
567
+ }
568
+ scaleSet .invalidateInstanceCache ()
569
+ }
562
570
return
563
571
}
564
- // On failure, invalidate the instanceCache - cannot have instances in deletingState
565
- scaleSet .invalidateInstanceCache ()
572
+ if ! scaleSet .manager .config .StrictCacheUpdates {
573
+ // On failure, invalidate the instanceCache - cannot have instances in deletingState
574
+ scaleSet .invalidateInstanceCache ()
575
+ }
566
576
klog .Errorf ("WaitForDeleteInstancesResult(%v) for %s failed with error: %v" , requiredIds .InstanceIds , scaleSet .Name , err )
567
577
}
568
578
0 commit comments