From 139e7c0eb8d87ee9313709b1aeeb305c03d2ed13 Mon Sep 17 00:00:00 2001 From: Vladimir Vuksan Date: Fri, 7 Jul 2023 14:52:21 -0400 Subject: [PATCH 1/3] Linking of an inspection service with Fastly service may take more than 90 seconds. Extending timeouts --- api.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api.go b/api.go index e99efe2..0a5cdf2 100644 --- a/api.go +++ b/api.go @@ -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)) @@ -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 { @@ -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 } From 9fdd57b9220145c16d603c56ced5d755274e7228 Mon Sep 17 00:00:00 2001 From: Vladimir Vuksan Date: Fri, 7 Jul 2023 14:57:38 -0400 Subject: [PATCH 2/3] Change error message --- api.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api.go b/api.go index 0a5cdf2..24414d0 100644 --- a/api.go +++ b/api.go @@ -2967,9 +2967,7 @@ 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 + return errors.New("timed out associating fastly service with inspection service. retry later.") } // DetachEdgeDeploymentService removes all backends from the Edge Deployment connected to the Fastly service From 6ab83d0222339c96136b58dc99e9e9efdd3420c7 Mon Sep 17 00:00:00 2001 From: Vladimir Vuksan Date: Fri, 7 Jul 2023 15:19:35 -0400 Subject: [PATCH 3/3] Fix build errors --- api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.go b/api.go index 24414d0..3e737d6 100644 --- a/api.go +++ b/api.go @@ -2967,7 +2967,7 @@ func (sc *Client) CreateOrUpdateEdgeDeploymentService(corpName, siteName, fastly } // If we got here linking of Fastly Service with Inspection Service has timed out - return errors.New("timed out associating fastly service with inspection service. retry later.") + return errors.New("timed out associating fastly service with inspection service retry later") } // DetachEdgeDeploymentService removes all backends from the Edge Deployment connected to the Fastly service