use contexts with timeouts in scale set GET calls
This commit is contained in:
parent
ca6bbc96a2
commit
3891852eec
|
|
@ -174,7 +174,7 @@ func (scaleSet *ScaleSet) getVMSSInfo() (compute.VirtualMachineScaleSet, *retry.
|
|||
}
|
||||
|
||||
func (scaleSet *ScaleSet) getAllVMSSInfo() ([]compute.VirtualMachineScaleSet, *retry.Error) {
|
||||
ctx, cancel := getContextWithCancel()
|
||||
ctx, cancel := getContextWithTimeout(3 * time.Minute)
|
||||
defer cancel()
|
||||
|
||||
resourceGroup := scaleSet.manager.config.ResourceGroup
|
||||
|
|
@ -339,7 +339,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 := getContextWithCancel()
|
||||
ctx, cancel := getContextWithTimeout(3 * time.Minute)
|
||||
defer cancel()
|
||||
|
||||
resourceGroup := scaleSet.manager.config.ResourceGroup
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import (
|
|||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-12-01/compute"
|
||||
azStorage "github.com/Azure/azure-sdk-for-go/storage"
|
||||
|
|
@ -597,6 +598,10 @@ func getContextWithCancel() (context.Context, context.CancelFunc) {
|
|||
return context.WithCancel(context.Background())
|
||||
}
|
||||
|
||||
func getContextWithTimeout(timeout time.Duration) (context.Context, context.CancelFunc) {
|
||||
return context.WithTimeout(context.Background(), timeout)
|
||||
}
|
||||
|
||||
// checkExistsFromError inspects an error and returns a true if err is nil,
|
||||
// false if error is an autorest.Error with StatusCode=404 and will return the
|
||||
// error back if error is another status code or another type of error.
|
||||
|
|
|
|||
Loading…
Reference in New Issue