Skip to content

Commit

Permalink
Mitigate race
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLangworthy committed Nov 6, 2019
1 parent f0e4e5e commit 7a99522
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cluster-autoscaler/cloudprovider/azure/azure_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,14 @@ func (scaleSet *ScaleSet) updateVMSSCapacity(size int64) {
var isSuccess bool
var err error

scaleSet.sizeMutex.Lock()
defer scaleSet.sizeMutex.Unlock()

defer func() {
if err != nil {
klog.Errorf("Failed to update the capacity for vmss %s with error %v, invalidate the cache so as to get the real size from API", scaleSet.Name, err)
// Invalidate the VMSS size cache in order to fetch the size from the API.
scaleSet.sizeMutex.Lock()
defer scaleSet.sizeMutex.Unlock()

scaleSet.lastSizeRefresh = time.Now().Add(-1 * vmssSizeRefreshPeriod)
}
}()
Expand Down

0 comments on commit 7a99522

Please sign in to comment.