Skip to content

Commit

Permalink
Linking of an inspection service with Fastly service may take more th…
Browse files Browse the repository at this point in the history
…an 90 seconds. Extending timeouts
  • Loading branch information
vvuksan committed Jul 7, 2023
1 parent e93edec commit 13b8ee7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2926,7 +2926,10 @@ func (sc *Client) CreateOrUpdateEdgeDeploymentService(corpName, siteName, fastly
return err
}

var sleepTime = 15 * time.Second
// Call to link inspection service with the Fastly service will fail if inspection service is not available. Set sleeptime to
// 20 seconds for the first sleep before retrying the first time
var sleepTime = 20 * time.Second

for i := 0; i < 6; i++ {
resp, err := sc.doRequestDetailed("PUT", fmt.Sprintf("/v0/corps/%s/sites/%s/edgeDeployment/%s", corpName, siteName, fastlySID), string(b))

Expand All @@ -2948,6 +2951,8 @@ func (sc *Client) CreateOrUpdateEdgeDeploymentService(corpName, siteName, fastly
// Only sleep if Retry-After response header is available
if resp.Header.Get("Retry-After") != "" {
time.Sleep(sleepTime)
// Add 5 seconds to sleeptime for every consecutive retry e.g. wait 20, 25, 30, 35, 40, 45 seconds
sleepTime += 5 * time.Second
} else {
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand All @@ -2961,6 +2966,9 @@ func (sc *Client) CreateOrUpdateEdgeDeploymentService(corpName, siteName, fastly
}
}

// If we got here linking of Fastly Service with Inspection Service has timed out
err = errors.New("timed out associating fastly service with inspection service")

return err
}

Expand Down

0 comments on commit 13b8ee7

Please sign in to comment.