X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f398e9d75d32fbfa6804041353997bf74195e489..6756ee790a6c685b96bc1ec80b67e7d6c94e9846:/lib/cloud/azure.go diff --git a/lib/cloud/azure.go b/lib/cloud/azure.go index d94285d6ad..a194b33180 100644 --- a/lib/cloud/azure.go +++ b/lib/cloud/azure.go @@ -166,15 +166,14 @@ func WrapAzureError(err error) error { if parseErr != nil { // Could not parse as a timestamp, must be number of seconds dur, parseErr := strconv.ParseInt(ra, 10, 64) - if parseErr != nil { + if parseErr == nil { earliestRetry = time.Now().Add(time.Duration(dur) * time.Second) + } else { + // Couldn't make sense of retry-after, + // so set retry to 20 seconds + earliestRetry = time.Now().Add(20 * time.Second) } } - if parseErr != nil { - // Couldn't make sense of retry-after, - // so set retry to 20 seconds - earliestRetry = time.Now().Add(20 * time.Second) - } return &AzureRateLimitError{*rq, earliestRetry} } if rq.ServiceError == nil { @@ -251,10 +250,14 @@ func (az *AzureInstanceSet) setup(azcfg AzureInstanceSetConfig, dispatcherID str az.ctx, az.stopFunc = context.WithCancel(context.Background()) go func() { + az.stopWg.Add(1) + defer az.stopWg.Done() + tk := time.NewTicker(5 * time.Minute) for { select { case <-az.ctx.Done(): + tk.Stop() return case <-tk.C: az.ManageBlobs() @@ -504,9 +507,6 @@ func (az *AzureInstanceSet) ManageNics() (map[string]network.Interface, error) { // leased to a VM) and haven't been modified for // DeleteDanglingResourcesAfter seconds. func (az *AzureInstanceSet) ManageBlobs() { - az.stopWg.Add(1) - defer az.stopWg.Done() - result, err := az.storageAcctClient.ListKeys(az.ctx, az.azconfig.ResourceGroup, az.azconfig.StorageAccount) if err != nil { az.logger.WithError(err).Warn("Couldn't get account keys")