Skip to content

Commit

Permalink
Merge pull request #3631 from DataDog/azure-spread-over-time
Browse files Browse the repository at this point in the history
Azure: keep refreshes spread over time
  • Loading branch information
k8s-ci-robot authored Oct 19, 2020
2 parents d46df66 + ec2e477 commit d054bb2
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions cluster-autoscaler/cloudprovider/azure/azure_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,18 +562,13 @@ func (scaleSet *ScaleSet) Nodes() ([]cloudprovider.Instance, error) {
}

klog.V(4).Infof("Nodes: starts to get VMSS VMs")

lastRefresh := time.Now()
if scaleSet.lastInstanceRefresh.IsZero() && scaleSet.instancesRefreshJitter > 0 {
// new VMSS: spread future refreshs
splay := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(scaleSet.instancesRefreshJitter + 1)
lastRefresh = time.Now().Add(-time.Second * time.Duration(splay))
}
splay := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(scaleSet.instancesRefreshJitter + 1)
lastRefresh := time.Now().Add(-time.Second * time.Duration(splay))

vms, rerr := scaleSet.GetScaleSetVms()
if rerr != nil {
if isAzureRequestsThrottled(rerr) {
// Log a warning and update the instance refresh time so that it would retry after next scaleSet.instanceRefreshPeriod.
// Log a warning and update the instance refresh time so that it would retry after cache expiration
klog.Warningf("GetScaleSetVms() is throttled with message %v, would return the cached instances", rerr)
scaleSet.lastInstanceRefresh = lastRefresh
return scaleSet.instanceCache, nil
Expand Down

0 comments on commit d054bb2

Please sign in to comment.