Skip to content

Commit

Permalink
Ignore block storage detach error when already detached (#393)
Browse files Browse the repository at this point in the history
Fixes a bug when block storage volume is manually detached.
  • Loading branch information
kobajagi authored Dec 12, 2024
1 parent f384cfc commit fd3d75e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

BUG FIXES:

- Ignore block storage detach error when already detached #393

## 0.62.3

BUG FIXES:
Expand Down
9 changes: 6 additions & 3 deletions pkg/resources/instance/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,14 @@ func rUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag
bid,
)
if err != nil {
if !errors.Is(err, v3.ErrNotFound) {
return diag.Errorf("failed to detach block storage: %s", err)
// Ideally we would have a custom error defined in OpenAPI spec & egoscale.
// For now we just check the error text.
if strings.HasSuffix(err.Error(), "Volume not attached") {
tflog.Info(ctx, "volume not attached")
continue
}

continue
return diag.Errorf("failed to detach block storage: %s", err)
}

_, err = clientV3.Wait(ctx, op, v3.OperationStateSuccess)
Expand Down

0 comments on commit fd3d75e

Please sign in to comment.