From 60a7ddfebe4de55f4b718903f578166bd7b10712 Mon Sep 17 00:00:00 2001 From: Mark Dordoy Date: Tue, 11 Jun 2024 09:52:34 +0100 Subject: [PATCH 1/2] Remove 404 retry, add custom ctx with timeout --- msgraph/application_templates.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/msgraph/application_templates.go b/msgraph/application_templates.go index 1aeac9db..934559c7 100644 --- a/msgraph/application_templates.go +++ b/msgraph/application_templates.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "net/http" + "time" "github.com/hashicorp/go-azure-sdk/sdk/odata" ) @@ -94,10 +95,14 @@ func (c *ApplicationTemplatesClient) Instantiate(ctx context.Context, applicatio return nil, status, fmt.Errorf("json.Marshal(): %v", err) } + // This post call can often timeout and return a 404, particularly against US Gov cloud. The aim here is to give it longer to complete on azure's backend + // before timeout occurs + ctx, cancel := context.WithTimeout(ctx, 45*time.Second) + defer cancel() + resp, status, _, err := c.BaseClient.Post(ctx, PostHttpRequestInput{ - Body: body, - ConsistencyFailureFunc: RetryOn404ConsistencyFailureFunc, - ValidStatusCodes: []int{http.StatusCreated}, + Body: body, + ValidStatusCodes: []int{http.StatusCreated}, Uri: Uri{ Entity: fmt.Sprintf("/applicationTemplates/%s/instantiate", *applicationTemplate.ID), }, From 899c6ce169f651b7c3bffae4cb8bca013974e151 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Tue, 11 Jun 2024 16:11:14 +0100 Subject: [PATCH 2/2] Remove custom timeout --- msgraph/application_templates.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/msgraph/application_templates.go b/msgraph/application_templates.go index 934559c7..ca24bf8c 100644 --- a/msgraph/application_templates.go +++ b/msgraph/application_templates.go @@ -7,7 +7,6 @@ import ( "fmt" "io" "net/http" - "time" "github.com/hashicorp/go-azure-sdk/sdk/odata" ) @@ -95,11 +94,6 @@ func (c *ApplicationTemplatesClient) Instantiate(ctx context.Context, applicatio return nil, status, fmt.Errorf("json.Marshal(): %v", err) } - // This post call can often timeout and return a 404, particularly against US Gov cloud. The aim here is to give it longer to complete on azure's backend - // before timeout occurs - ctx, cancel := context.WithTimeout(ctx, 45*time.Second) - defer cancel() - resp, status, _, err := c.BaseClient.Post(ctx, PostHttpRequestInput{ Body: body, ValidStatusCodes: []int{http.StatusCreated},