From ac0ded27e0f9f719193225b2dd975f50c8c9019d Mon Sep 17 00:00:00 2001 From: Patrik Cyvoct Date: Thu, 19 Mar 2020 15:21:06 +0100 Subject: [PATCH 1/2] feat(baremetal): add RetryInterval variable Signed-off-by: Patrik Cyvoct --- api/baremetal/v1alpha1/server_utils.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/api/baremetal/v1alpha1/server_utils.go b/api/baremetal/v1alpha1/server_utils.go index 48604ae10..f02b03bb0 100644 --- a/api/baremetal/v1alpha1/server_utils.go +++ b/api/baremetal/v1alpha1/server_utils.go @@ -8,6 +8,16 @@ import ( "github.com/scaleway/scaleway-sdk-go/scw" ) +var ( + // RetryInterval is needed when running recorded tests (e.g. on scaleway-cli) + // it allows to execute the WaitFor funcs immediately + RetryInterval = defaultRetryInterval +) + +const ( + defaultRetryInterval = time.Second * 15 +) + // WaitForServerRequest is used by WaitForServer method. type WaitForServerRequest struct { ServerID string @@ -40,7 +50,7 @@ func (s *API) WaitForServer(req *WaitForServerRequest) (*Server, error) { return res, isTerminal, err }, Timeout: req.Timeout, - IntervalStrategy: async.LinearIntervalStrategy(5 * time.Second), + IntervalStrategy: async.LinearIntervalStrategy(RetryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server failed") @@ -84,7 +94,7 @@ func (s *API) WaitForServerInstall(req *WaitForServerInstallRequest) (*Server, e return res, isTerminal, err }, Timeout: req.Timeout, - IntervalStrategy: async.LinearIntervalStrategy(15 * time.Second), + IntervalStrategy: async.LinearIntervalStrategy(RetryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server installation failed") From 7e68dfb057610dfde76c8aa65adbf28308f09baa Mon Sep 17 00:00:00 2001 From: Patrik Date: Thu, 19 Mar 2020 15:35:07 +0100 Subject: [PATCH 2/2] Update api/baremetal/v1alpha1/server_utils.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Rémy Léone --- api/baremetal/v1alpha1/server_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/baremetal/v1alpha1/server_utils.go b/api/baremetal/v1alpha1/server_utils.go index f02b03bb0..51151fc7f 100644 --- a/api/baremetal/v1alpha1/server_utils.go +++ b/api/baremetal/v1alpha1/server_utils.go @@ -15,7 +15,7 @@ var ( ) const ( - defaultRetryInterval = time.Second * 15 + defaultRetryInterval = 15 * time.Second ) // WaitForServerRequest is used by WaitForServer method.