Skip to content

Commit 09cd9c4

Browse files
authored
func: add mitigation for deployments that take awhile to "come alive" (#4449)
Add polling delay and retries for function app consumption deployments that take awhile to "come alive" Fixes #4439
1 parent 331c013 commit 09cd9c4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cli/azd/pkg/azsdk/funcapp_host_client.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,12 @@ func (c *FuncAppHostClient) Publish(
117117

118118
func (c *FuncAppHostClient) waitForDeployment(ctx context.Context, location string) (PublishResponse, error) {
119119
// This frequency is recommended by the service team.
120-
polLDelay := 1 * time.Second
120+
pollDelay := 1 * time.Second
121121
var lastResponse *PublishResponse
122122

123+
// mitigation for deployments that take awhile to "come alive"
124+
deploymentNotFoundAttempts := 0
125+
123126
for {
124127
req, err := runtime.NewRequest(ctx, http.MethodGet, location)
125128
if err != nil {
@@ -131,6 +134,12 @@ func (c *FuncAppHostClient) waitForDeployment(ctx context.Context, location stri
131134
return PublishResponse{}, err
132135
}
133136

137+
if deploymentNotFoundAttempts <= 3 && response.StatusCode == http.StatusNotFound {
138+
deploymentNotFoundAttempts++
139+
time.Sleep(pollDelay)
140+
continue
141+
}
142+
134143
// It's possible to observe a 404 response after the deployment is complete.
135144
// If a 404 is observed, we assume the deployment is complete and return the last response.
136145
//
@@ -167,9 +176,9 @@ func (c *FuncAppHostClient) waitForDeployment(ctx context.Context, location stri
167176
// Record the latest response
168177
lastResponse = &resp
169178

170-
delay := polLDelay
179+
delay := pollDelay
171180
if retryAfter := httputil.RetryAfter(response); retryAfter > 0 {
172-
delay = polLDelay
181+
delay = pollDelay
173182
}
174183

175184
select {

0 commit comments

Comments
 (0)