Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/services/block/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func ResourceBlockVolumeDelete(ctx context.Context, d *schema.ResourceData, m in
return diag.FromErr(err)
}

_, err = waitForBlockVolume(ctx, api, zone, id, d.Timeout(schema.TimeoutDelete))
_, err = waitForBlockVolumeToBeAvailable(ctx, api, zone, id, d.Timeout(schema.TimeoutDelete))
if err != nil {
if httperrors.Is404(err) {
d.SetId("")
Expand Down
19 changes: 19 additions & 0 deletions internal/services/block/waiters.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ func waitForBlockVolume(ctx context.Context, blockAPI *block.API, zone scw.Zone,
return volume, err
}

func waitForBlockVolumeToBeAvailable(ctx context.Context, blockAPI *block.API, zone scw.Zone, id string, timeout time.Duration) (*block.Volume, error) {
retryInterval := defaultBlockRetryInterval
if transport.DefaultWaitRetryInterval != nil {
retryInterval = *transport.DefaultWaitRetryInterval
}

terminalStatus := block.VolumeStatusAvailable
volume, err := blockAPI.WaitForVolumeAndReferences(&block.WaitForVolumeAndReferencesRequest{
Zone: zone,
VolumeID: id,
RetryInterval: &retryInterval,
Timeout: scw.TimeDurationPtr(timeout),

VolumeTerminalStatus: &terminalStatus,
}, scw.WithContext(ctx))

return volume, err
}

func waitForBlockSnapshot(ctx context.Context, blockAPI *block.API, zone scw.Zone, id string, timeout time.Duration) (*block.Snapshot, error) {
retryInterval := defaultBlockRetryInterval
if transport.DefaultWaitRetryInterval != nil {
Expand Down
Loading