Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 0119bc1

Browse files
committed
standardize ARM ops timeout to 2.5 hours (#3741)
1 parent ecc9b5b commit 0119bc1

File tree

9 files changed

+17
-12
lines changed

9 files changed

+17
-12
lines changed

cmd/deploy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func autofillApimodel(dc *deployCmd) error {
301301
dc.containerService.Properties.LinuxProfile.SSH.PublicKeys = []api.PublicKey{{KeyData: publicKey}}
302302
}
303303

304-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
304+
ctx, cancel := context.WithTimeout(context.Background(), armhelpers.DefaultARMOperationTimeout)
305305
defer cancel()
306306
_, err = dc.client.EnsureResourceGroup(ctx, dc.resourceGroup, dc.location, nil)
307307
if err != nil {
@@ -439,7 +439,7 @@ func (dc *deployCmd) run() error {
439439
}
440440

441441
deploymentSuffix := dc.random.Int31()
442-
cx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
442+
cx, cancel := context.WithTimeout(context.Background(), armhelpers.DefaultARMOperationTimeout)
443443
defer cancel()
444444

445445
if res, err := dc.client.DeployTemplate(

cmd/scale.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (sc *scaleCmd) load(cmd *cobra.Command) error {
130130
return errors.Wrap(err, "failed to get client")
131131
}
132132

133-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
133+
ctx, cancel := context.WithTimeout(context.Background(), armhelpers.DefaultARMOperationTimeout)
134134
defer cancel()
135135
_, err = sc.client.EnsureResourceGroup(ctx, sc.resourceGroupName, sc.location, nil)
136136
if err != nil {
@@ -208,7 +208,7 @@ func (sc *scaleCmd) run(cmd *cobra.Command, args []string) error {
208208
return errors.Wrap(err, "failed to load existing container service")
209209
}
210210

211-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
211+
ctx, cancel := context.WithTimeout(context.Background(), armhelpers.DefaultARMOperationTimeout)
212212
defer cancel()
213213
orchestratorInfo := sc.containerService.Properties.OrchestratorProfile
214214
var currentNodeCount, highestUsedIndex, index, winPoolIndex int

cmd/upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (uc *upgradeCmd) loadCluster(cmd *cobra.Command) error {
122122
return errors.Wrap(err, "Failed to get client")
123123
}
124124

125-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
125+
ctx, cancel := context.WithTimeout(context.Background(), armhelpers.DefaultARMOperationTimeout)
126126
defer cancel()
127127
_, err = uc.client.EnsureResourceGroup(ctx, uc.resourceGroupName, uc.location, nil)
128128
if err != nil {

pkg/acsengine/tenantid.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
// GetTenantID figures out the AAD tenant ID of the subscription by making an
1515
// unauthenticated request to the Get Subscription Details endpoint and parses
1616
// the value from WWW-Authenticate header.
17+
// TODO this should probably to to the armhelpers library
1718
func GetTenantID(resourceManagerEndpoint string, subscriptionID string) (string, error) {
1819
const hdrKey = "WWW-Authenticate"
1920
c := subscriptions.NewClientWithBaseURI(resourceManagerEndpoint)
@@ -23,7 +24,7 @@ func GetTenantID(resourceManagerEndpoint string, subscriptionID string) (string,
2324
// we expect this request to fail (err != nil), but we are only interested
2425
// in headers, so surface the error if the Response is not present (i.e.
2526
// network error etc)
26-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
27+
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*150)
2728
defer cancel()
2829
subs, err := c.Get(ctx, subscriptionID)
2930
if subs.Response.Response == nil {

pkg/armhelpers/azureclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ func getClient(env azure.Environment, subscriptionID, tenantID string, armSpt *a
327327

328328
// EnsureProvidersRegistered checks if the AzureClient is registered to required resource providers and, if not, register subscription to providers
329329
func (az *AzureClient) EnsureProvidersRegistered(subscriptionID string) error {
330-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
330+
ctx, cancel := context.WithTimeout(context.Background(), DefaultARMOperationTimeout)
331331
defer cancel()
332332
registeredProviders, err := az.providersClient.List(ctx, to.Int32Ptr(100), "")
333333
if err != nil {

pkg/armhelpers/const.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package armhelpers
2+
3+
import "time"
4+
5+
// DefaultARMOperationTimeout defines a default (permissive) ARM operation timeout
6+
const DefaultARMOperationTimeout = 150 * time.Minute

pkg/armhelpers/deploymentError.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"encoding/json"
77
"fmt"
88
"strings"
9-
"time"
109

1110
"github.com/Azure/acs-engine/pkg/api"
1211
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
@@ -59,7 +58,7 @@ func (e *DeploymentValidationError) Error() string {
5958

6059
// DeployTemplateSync deploys the template and returns ArmError
6160
func DeployTemplateSync(az ACSEngineClient, logger *logrus.Entry, resourceGroupName, deploymentName string, template map[string]interface{}, parameters map[string]interface{}) error {
62-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
61+
ctx, cancel := context.WithTimeout(context.Background(), DefaultARMOperationTimeout)
6362
defer cancel()
6463
deploymentExtended, err := az.DeployTemplate(ctx, resourceGroupName, deploymentName, template, parameters)
6564
if err == nil {

pkg/operations/deletevm.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package operations
33
import (
44
"context"
55
"fmt"
6-
"time"
76

87
"github.com/Azure/acs-engine/pkg/armhelpers"
98
"github.com/Azure/acs-engine/pkg/armhelpers/utils"
@@ -18,7 +17,7 @@ const (
1817

1918
// CleanDeleteVirtualMachine deletes a VM and any associated OS disk
2019
func CleanDeleteVirtualMachine(az armhelpers.ACSEngineClient, logger *log.Entry, subscriptionID, resourceGroup, name string) error {
21-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
20+
ctx, cancel := context.WithTimeout(context.Background(), armhelpers.DefaultARMOperationTimeout)
2221
defer cancel()
2322
logger.Infof("fetching VM: %s/%s", resourceGroup, name)
2423
vm, err := az.GetVirtualMachine(ctx, resourceGroup, name)

pkg/operations/kubernetesupgrade/upgradecluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (uc *UpgradeCluster) UpgradeCluster(subscriptionID uuid.UUID, kubeConfig, r
145145
func (uc *UpgradeCluster) getClusterNodeStatus(subscriptionID uuid.UUID, resourceGroup string) error {
146146
targetOrchestratorTypeVersion := fmt.Sprintf("%s:%s", uc.DataModel.Properties.OrchestratorProfile.OrchestratorType, uc.DataModel.Properties.OrchestratorProfile.OrchestratorVersion)
147147

148-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour)
148+
ctx, cancel := context.WithTimeout(context.Background(), armhelpers.DefaultARMOperationTimeout)
149149
defer cancel()
150150
for vmScaleSetPage, err := uc.Client.ListVirtualMachineScaleSets(ctx, resourceGroup); vmScaleSetPage.NotDone(); err = vmScaleSetPage.Next() {
151151
if err != nil {

0 commit comments

Comments
 (0)