Skip to content

Commit

Permalink
Merge pull request #3038 from feiskyer/vmss-1.18
Browse files Browse the repository at this point in the history
CA 1.18: Remove checking for VMSS provisioningState before scaling
  • Loading branch information
k8s-ci-robot authored Apr 11, 2020
2 parents 0c67f65 + faebb31 commit fa1f10b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
9 changes: 0 additions & 9 deletions cluster-autoscaler/cloudprovider/azure/azure_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
)

var (
Expand Down Expand Up @@ -268,17 +267,9 @@ func (scaleSet *ScaleSet) SetScaleSetSize(size int64) error {
return rerr.Error()
}

// Abort scaling to avoid concurrent VMSS scaling if the VMSS is still under updating.
// Note that the VMSS provisioning state would be updated per scaleSet.sizeRefreshPeriod.
if vmssInfo.VirtualMachineScaleSetProperties != nil && strings.EqualFold(to.String(vmssInfo.VirtualMachineScaleSetProperties.ProvisioningState), string(compute.ProvisioningStateUpdating)) {
klog.Errorf("VMSS %q is still under updating, waiting for it finishes before scaling", scaleSet.Name)
return fmt.Errorf("VMSS %q is still under updating", scaleSet.Name)
}

// Update the new capacity to cache.
vmssSizeMutex.Lock()
vmssInfo.Sku.Capacity = &size
vmssInfo.VirtualMachineScaleSetProperties.ProvisioningState = to.StringPtr(string(compute.ProvisioningStateUpdating))
vmssSizeMutex.Unlock()

// Compose a new VMSS for updating.
Expand Down
23 changes: 1 addition & 22 deletions cluster-autoscaler/cloudprovider/azure/azure_scale_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"net/http"
"testing"
"time"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
"github.com/Azure/go-autorest/autorest"
Expand Down Expand Up @@ -126,30 +125,10 @@ func TestIncreaseSizeOnVMSSUpdating(t *testing.T) {
provider, err := BuildAzureCloudProvider(manager, nil)
assert.NoError(t, err)

// Scaling should fail because VMSS is still under updating.
// Scaling should continue even VMSS is under updating.
scaleSet, ok := provider.NodeGroups()[0].(*ScaleSet)
assert.True(t, ok)
err = scaleSet.IncreaseSize(1)
assert.Equal(t, fmt.Errorf("VMSS %q is still under updating", scaleSet.Name), err)

// Scaling should succeed after VMSS ProvisioningState changed to succeeded.
scaleSetClient.FakeStore = map[string]map[string]compute.VirtualMachineScaleSet{
"test": {
vmssName: {
Name: &vmssName,
Sku: &compute.Sku{
Capacity: &vmssCapacity,
},
VirtualMachineScaleSetProperties: &compute.VirtualMachineScaleSetProperties{
ProvisioningState: to.StringPtr(string(compute.ProvisioningStateSucceeded)),
},
},
},
}
scaleSetStatusCache.mutex.Lock()
scaleSetStatusCache.lastRefresh = time.Now().Add(-1 * scaleSet.sizeRefreshPeriod)
scaleSetStatusCache.mutex.Unlock()
err = scaleSet.IncreaseSize(1)
assert.NoError(t, err)
}

Expand Down

0 comments on commit fa1f10b

Please sign in to comment.