Skip to content

Commit

Permalink
Finally mitigate race
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLangworthy committed Nov 7, 2019
1 parent ba4c935 commit cd457ff
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cluster-autoscaler/cloudprovider/azure/azure_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,19 @@ func (scaleSet *ScaleSet) getCurSize() (int64, error) {
}
return -1, err
}
klog.V(5).Infof("Getting scale set (%q) capacity: %d\n", scaleSet.Name, *set.Sku.Capacity)

if scaleSet.curSize != *set.Sku.Capacity {
vmssSizeMutex.Lock()
curSize := *set.Sku.Capacity
vmssSizeMutex.Unlock()

klog.V(5).Infof("Getting scale set (%q) capacity: %d\n", scaleSet.Name, curSize)

if scaleSet.curSize != curSize {
// Invalidate the instance cache if the capacity has changed.
scaleSet.invalidateInstanceCache()
}

vmssSizeMutex.Lock()
scaleSet.curSize = *set.Sku.Capacity
vmssSizeMutex.Unlock()
scaleSet.curSize = curSize
scaleSet.lastSizeRefresh = time.Now()
return scaleSet.curSize, nil
}
Expand Down

0 comments on commit cd457ff

Please sign in to comment.