Skip to content

Commit 2d127a2

Browse files
jremy42Codelax
andauthored
fix(mongodb): switch to GetSnapshot (scaleway#2263)
Co-authored-by: Jules Castéran <[email protected]>
1 parent f21f9b3 commit 2d127a2

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

api/mongodb/v1alpha1/mongodb_utils.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,16 @@ func (s *API) WaitForSnapshot(req *WaitForSnapshotRequest, opts ...scw.RequestOp
9090

9191
snapshot, err := async.WaitSync(&async.WaitSyncConfig{
9292
Get: func() (interface{}, bool, error) {
93-
opts = append(opts, scw.WithAllPages())
94-
listSnapshotResponse, err := s.ListSnapshots(&ListSnapshotsRequest{
93+
getSnapshotResponse, err := s.GetSnapshot(&GetSnapshotRequest{
9594
Region: req.Region,
96-
InstanceID: &req.InstanceID,
95+
SnapshotID: req.SnapshotID,
9796
}, opts...)
9897
if err != nil {
9998
return nil, false, err
10099
}
101100

102-
for _, snapshot := range listSnapshotResponse.Snapshots {
103-
if snapshot.ID == req.SnapshotID {
104-
_, isTerminal := terminalStatus[snapshot.Status]
105-
return snapshot, isTerminal, nil
106-
}
107-
}
108-
return nil, false, nil
101+
_, isTerminal := terminalStatus[getSnapshotResponse.Status]
102+
return getSnapshotResponse, isTerminal, nil
109103
},
110104
Timeout: timeout,
111105
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),

0 commit comments

Comments
 (0)