From 6da62d0b7b18815b54a10b71457843b723dcc740 Mon Sep 17 00:00:00 2001 From: Marwan Ahmed Date: Sun, 13 Sep 2020 22:21:28 -0700 Subject: [PATCH] dont update capacity if VMSS provisioning state is updating --- cluster-autoscaler/cloudprovider/azure/azure_scale_set.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go b/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go index 95166c1c6518..9c7835e513ff 100644 --- a/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go +++ b/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go @@ -40,6 +40,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" ) var ( @@ -218,6 +219,12 @@ func (scaleSet *ScaleSet) getCurSize() (int64, error) { return -1, rerr.Error() } + // If VMSS state is updating, return the currentSize which would've been proactively incremented or decremented by CA + if set.VirtualMachineScaleSetProperties != nil && strings.EqualFold(to.String(set.VirtualMachineScaleSetProperties.ProvisioningState), string(compute.ProvisioningStateUpdating)) { + klog.V(5).Infof("VMSS %q is in updating state, returning cached size: %d", scaleSet.Name, scaleSet.curSize) + return scaleSet.curSize, nil + } + vmssSizeMutex.Lock() curSize := *set.Sku.Capacity vmssSizeMutex.Unlock()