Skip to content

Commit

Permalink
add context timeouts for the sync part of long running operations
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanad committed Jul 9, 2020
1 parent fd1a370 commit 7a8613a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cluster-autoscaler/cloudprovider/azure/azure_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
var (
defaultVmssSizeRefreshPeriod = 15 * time.Second
vmssInstancesRefreshPeriod = 5 * time.Minute
vmssContextTimeout = 3 * time.Minute
vmssSizeMutex sync.Mutex
)

Expand Down Expand Up @@ -174,7 +175,7 @@ func (scaleSet *ScaleSet) getVMSSInfo() (compute.VirtualMachineScaleSet, *retry.
}

func (scaleSet *ScaleSet) getAllVMSSInfo() ([]compute.VirtualMachineScaleSet, *retry.Error) {
ctx, cancel := getContextWithTimeout(3 * time.Minute)
ctx, cancel := getContextWithTimeout(vmssContextTimeout)
defer cancel()

resourceGroup := scaleSet.manager.config.ResourceGroup
Expand Down Expand Up @@ -276,7 +277,7 @@ func (scaleSet *ScaleSet) SetScaleSetSize(size int64) error {
Sku: vmssInfo.Sku,
Location: vmssInfo.Location,
}
ctx, cancel := getContextWithCancel()
ctx, cancel := getContextWithTimeout(vmssContextTimeout)
defer cancel()
klog.V(3).Infof("Waiting for virtualMachineScaleSetsClient.CreateOrUpdateAsync(%s)", scaleSet.Name)
future, rerr := scaleSet.manager.azClient.virtualMachineScaleSetsClient.CreateOrUpdateAsync(ctx, scaleSet.manager.config.ResourceGroup, scaleSet.Name, op)
Expand Down Expand Up @@ -327,7 +328,7 @@ func (scaleSet *ScaleSet) IncreaseSize(delta int) error {
// GetScaleSetVms returns list of nodes for the given scale set.
func (scaleSet *ScaleSet) GetScaleSetVms() ([]compute.VirtualMachineScaleSetVM, *retry.Error) {
klog.V(4).Infof("GetScaleSetVms: starts")
ctx, cancel := getContextWithTimeout(3 * time.Minute)
ctx, cancel := getContextWithTimeout(vmssContextTimeout)
defer cancel()

resourceGroup := scaleSet.manager.config.ResourceGroup
Expand Down Expand Up @@ -426,7 +427,7 @@ func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef) error {
InstanceIds: &instanceIDs,
}

ctx, cancel := getContextWithCancel()
ctx, cancel := getContextWithTimeout(vmssContextTimeout)
defer cancel()
resourceGroup := scaleSet.manager.config.ResourceGroup

Expand Down

0 comments on commit 7a8613a

Please sign in to comment.