diff --git a/cluster-autoscaler/cloudprovider/azure/azure_agent_pool.go b/cluster-autoscaler/cloudprovider/azure/azure_agent_pool.go index 4b059e78a126..d5d0cdc9c810 100644 --- a/cluster-autoscaler/cloudprovider/azure/azure_agent_pool.go +++ b/cluster-autoscaler/cloudprovider/azure/azure_agent_pool.go @@ -71,6 +71,7 @@ func NewAgentPool(spec *dynamic.NodeGroupSpec, az *AzureManager) (*AgentPool, er minSize: spec.MinSize, maxSize: spec.MaxSize, manager: az, + curSize: -1, } if err := as.initialize(); err != nil { @@ -228,6 +229,10 @@ func (as *AgentPool) IncreaseSize(delta int) error { as.mutex.Lock() defer as.mutex.Unlock() + if as.curSize == -1 { + return fmt.Errorf("the availability set %s is under initialization, skipping IncreaseSize", as.Name) + } + if delta <= 0 { return fmt.Errorf("size increase must be positive") } diff --git a/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go b/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go index 007aeab34d35..f12ba1fda11f 100644 --- a/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go +++ b/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go @@ -314,6 +314,10 @@ func (scaleSet *ScaleSet) IncreaseSize(delta int) error { return err } + if size == -1 { + return fmt.Errorf("the scale set %s is under initialization, skipping IncreaseSize", scaleSet.Name) + } + if int(size)+delta > scaleSet.MaxSize() { return fmt.Errorf("size increase too large - desired:%d max:%d", int(size)+delta, scaleSet.MaxSize()) }