Skip to content

Commit 752c4f4

Browse files
authored
feat: retry fetching instance connections on 404 (#2294)
1 parent 6a06083 commit 752c4f4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

internal/resources/cloud/resource_cloud_stack.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,18 @@ func readStack(ctx context.Context, d *schema.ResourceData, client *gcom.APIClie
405405
return common.WarnMissing("stack", d)
406406
}
407407

408-
connectionsReq := client.InstancesAPI.GetConnections(ctx, id.(string))
409-
connections, _, err := connectionsReq.Execute()
408+
var connections *gcom.FormattedApiInstanceConnections
409+
err = retry.RetryContext(ctx, 2*time.Minute, func() *retry.RetryError {
410+
resp, httpResp, err := client.InstancesAPI.GetConnections(ctx, id.(string)).Execute()
411+
if err != nil {
412+
if httpResp != nil && httpResp.StatusCode == http.StatusNotFound {
413+
return retry.RetryableError(err)
414+
}
415+
return retry.NonRetryableError(err)
416+
}
417+
connections = resp
418+
return nil
419+
})
410420
if err != nil {
411421
return apiError(err)
412422
}

0 commit comments

Comments
 (0)