From 6130b8cf5476b42411b1f870988d8742b7778432 Mon Sep 17 00:00:00 2001 From: qini Date: Thu, 25 Jun 2020 08:57:18 +0800 Subject: [PATCH] Disable increaseSize when the node group is under initialilzation. --- cluster-autoscaler/cloudprovider/azure/azure_agent_pool.go | 5 +++++ cluster-autoscaler/cloudprovider/azure/azure_scale_set.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/cluster-autoscaler/cloudprovider/azure/azure_agent_pool.go b/cluster-autoscaler/cloudprovider/azure/azure_agent_pool.go index 642248ae261a..cb55f9cba62a 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 { @@ -214,6 +215,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 8d1c4939092e..0a0fdc648428 100644 --- a/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go +++ b/cluster-autoscaler/cloudprovider/azure/azure_scale_set.go @@ -297,6 +297,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()) }