Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cli/azd/pkg/azapi/stack_deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ func (d *StackDeployments) GetSubscriptionDeployment(

err = retry.Do(
ctx,
retry.WithMaxDuration(10*time.Minute, retry.NewConstant(5*time.Second)),
retry.WithMaxDuration(
10*time.Minute,
retry.WithCappedDuration(10*time.Second, retry.NewExponential(1*time.Second)),
),
func(ctx context.Context) error {
response, err := client.GetAtSubscription(ctx, deploymentName, nil)
if err != nil {
Expand Down Expand Up @@ -201,7 +204,10 @@ func (d *StackDeployments) GetResourceGroupDeployment(

err = retry.Do(
ctx,
retry.WithMaxDuration(10*time.Minute, retry.NewConstant(5*time.Second)),
retry.WithMaxDuration(
10*time.Minute,
retry.WithCappedDuration(10*time.Second, retry.NewExponential(1*time.Second)),
),
func(ctx context.Context) error {
response, err := client.GetAtResourceGroup(ctx, resourceGroupName, deploymentName, nil)
if err != nil {
Expand Down
16 changes: 13 additions & 3 deletions cli/azd/pkg/azsdk/funcapp_host_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,13 @@ func (c *FuncAppHostClient) waitForDeployment(ctx context.Context, location stri
}

if deploymentNotFoundAttempts <= 3 && response.StatusCode == http.StatusNotFound {
response.Body.Close()
deploymentNotFoundAttempts++
time.Sleep(pollDelay)
select {
case <-ctx.Done():
return PublishResponse{}, ctx.Err()
case <-time.After(pollDelay):
}
continue
}

Expand All @@ -149,19 +154,24 @@ func (c *FuncAppHostClient) waitForDeployment(ctx context.Context, location stri
// This 404 is due to the deployment worker being "recycled".
// This shortcoming would be fixed by work item https://msazure.visualstudio.com/Antares/_workitems/edit/24715654.
if response.StatusCode == http.StatusNotFound && lastResponse != nil {
response.Body.Close()
return *lastResponse, nil
}

if response.StatusCode != http.StatusAccepted && response.StatusCode != http.StatusOK {
return PublishResponse{}, runtime.NewResponseError(response)
err := runtime.NewResponseError(response)
response.Body.Close()
return PublishResponse{}, err
}

// Server always returns status code of OK-200 whether the deployment is in-progress or complete.
// Thus, we always read the response body to determine the actual status.
resp := PublishResponse{}
if err := runtime.UnmarshalAsJSON(response, &resp); err != nil {
response.Body.Close()
return PublishResponse{}, err
}
response.Body.Close()

switch resp.Status {
case PublishStatusCancelled:
Expand All @@ -181,7 +191,7 @@ func (c *FuncAppHostClient) waitForDeployment(ctx context.Context, location stri

delay := pollDelay
if retryAfter := httputil.RetryAfter(response); retryAfter > 0 {
delay = pollDelay
delay = retryAfter
}

select {
Expand Down
6 changes: 5 additions & 1 deletion cli/azd/pkg/project/service_target_staticwebapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@ func (at *staticWebAppTarget) verifyDeployment(ctx context.Context, targetResour
return fmt.Errorf("failed verifying static web app deployment. Still in %s state", envProps.Status)
}

time.Sleep(5 * time.Second)
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(5 * time.Second):
}
}

return nil
Expand Down
Loading