Skip to content

Commit c0637fa

Browse files
authored
fix(k8s): add default timeout to WaitForCluster (#323)
Signed-off-by: Patrik Cyvoct <[email protected]>
1 parent 9e8b65b commit c0637fa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

api/k8s/v1beta4/k8s_helpers.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,24 @@ import (
88
"github.com./scaleway/scaleway-sdk-go/scw"
99
)
1010

11+
const (
12+
waitForClusterDefaultTimeout = time.Minute * 15
13+
)
14+
1115
// WaitForClusterRequest is used by WaitForCluster method.
1216
type WaitForClusterRequest struct {
1317
ClusterID string
1418
Region scw.Region
1519
Status ClusterStatus
16-
Timeout time.Duration
20+
Timeout *time.Duration
1721
}
1822

1923
// WaitForCluster waits for the cluster to be in a "terminal state" before returning.
2024
func (s *API) WaitForCluster(req *WaitForClusterRequest) (*Cluster, error) {
25+
timeout := waitForClusterDefaultTimeout
26+
if req.Timeout != nil {
27+
timeout = *req.Timeout
28+
}
2129
terminalStatus := map[ClusterStatus]struct{}{
2230
ClusterStatusReady: {},
2331
ClusterStatusError: {},
@@ -39,7 +47,7 @@ func (s *API) WaitForCluster(req *WaitForClusterRequest) (*Cluster, error) {
3947
_, isTerminal := terminalStatus[cluster.Status]
4048
return cluster, isTerminal, nil
4149
},
42-
Timeout: req.Timeout,
50+
Timeout: timeout,
4351
IntervalStrategy: async.LinearIntervalStrategy(5 * time.Second),
4452
})
4553
if err != nil {

0 commit comments

Comments
 (0)