Skip to content

Commit

Permalink
fix(k8s): add default timeout to WaitForCluster
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Cyvoct <pcyvoct@scaleway.com>
  • Loading branch information
Sh4d1 committed Feb 18, 2020
1 parent 086aa05 commit f86b6c6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/k8s/v1beta4/k8s_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ import (
"github.com/scaleway/scaleway-sdk-go/scw"
)

const (
waitForClusterDefaultTimeout = time.Minute * 15
)

// WaitForClusterRequest is used by WaitForCluster method.
type WaitForClusterRequest struct {
ClusterID string
Region scw.Region
Status ClusterStatus
Timeout time.Duration
Timeout *time.Duration
}

// WaitForCluster waits for the cluster to be in a "terminal state" before returning.
func (s *API) WaitForCluster(req *WaitForClusterRequest) (*Cluster, error) {
timeout := waitForClusterDefaultTimeout
if req.Timeout != nil {
timeout = *req.Timeout
}
terminalStatus := map[ClusterStatus]struct{}{
ClusterStatusReady: {},
ClusterStatusError: {},
Expand All @@ -39,7 +47,7 @@ func (s *API) WaitForCluster(req *WaitForClusterRequest) (*Cluster, error) {
_, isTerminal := terminalStatus[cluster.Status]
return cluster, isTerminal, nil
},
Timeout: req.Timeout,
Timeout: timeout,
IntervalStrategy: async.LinearIntervalStrategy(5 * time.Second),
})
if err != nil {
Expand Down

0 comments on commit f86b6c6

Please sign in to comment.