Skip to content

Commit aefd897

Browse files
authored
fix(k8s): WaitForClusterPool actually waits for pools (#2010)
1 parent 94068cc commit aefd897

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

api/k8s/v1/k8s_helpers.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,18 @@ func (s *API) WaitForClusterPool(req *WaitForClusterRequest, opts ...scw.Request
181181
retryInterval = *req.RetryInterval
182182
}
183183

184-
terminalStatus := map[ClusterStatus]struct{}{
184+
terminalClusterStatus := map[ClusterStatus]struct{}{
185185
ClusterStatusPoolRequired: {},
186186
ClusterStatusReady: {},
187187
}
188188

189+
terminalPoolStatus := map[PoolStatus]struct{}{
190+
PoolStatusReady: {},
191+
PoolStatusWarning: {},
192+
}
193+
194+
optsWithAllPages := append(opts, scw.WithAllPages())
195+
189196
cluster, err := async.WaitSync(&async.WaitSyncConfig{
190197
Get: func() (interface{}, bool, error) {
191198
cluster, err := s.GetCluster(&GetClusterRequest{
@@ -196,8 +203,27 @@ func (s *API) WaitForClusterPool(req *WaitForClusterRequest, opts ...scw.Request
196203
return nil, false, err
197204
}
198205

199-
_, isTerminal := terminalStatus[cluster.Status]
200-
return cluster, isTerminal, nil
206+
_, isTerminal := terminalClusterStatus[cluster.Status]
207+
if !isTerminal {
208+
return cluster, false, nil
209+
}
210+
211+
pools, err := s.ListPools(&ListPoolsRequest{
212+
Region: req.Region,
213+
ClusterID: req.ClusterID,
214+
}, optsWithAllPages...)
215+
if err != nil {
216+
return nil, false, err
217+
}
218+
219+
for _, pool := range pools.Pools {
220+
_, isTerminal = terminalPoolStatus[pool.Status]
221+
if !isTerminal {
222+
return cluster, false, nil
223+
}
224+
}
225+
226+
return cluster, true, nil
201227
},
202228
Timeout: timeout,
203229
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),

0 commit comments

Comments
 (0)