Skip to content

Commit

Permalink
need to wait for volume to detach to not spam deletion failures
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyDumaine committed Feb 26, 2024
1 parent e637b9a commit db7f34a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cloud/services/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import (
"github.com/linode/cluster-api-provider-linode/util"
)

const defaultEtcdSizeGB = 10
const (
defaultEtcdSizeGB = 10
defaultVolumeDetachTimeoutSeconds = 10
)

// CreateEtcdVolume creates an etcd Volume for a given linode instance ID
func CreateEtcdVolume(ctx context.Context,
Expand Down Expand Up @@ -58,6 +61,21 @@ func DeleteEtcdVolume(ctx context.Context,
return err
}
}

// need to wait for volume to actually detach before we can proceed with
// deleting it
if _, err := machineScope.LinodeClient.WaitForVolumeLinodeID(
ctx,
volumeID,
nil,
defaultVolumeDetachTimeoutSeconds,
); err != nil {
logger.Error(err, "Timed out waiting for volume to detach")

return err
}

// now that the volume is detached it can be properly deleted
if err := machineScope.LinodeClient.DeleteVolume(ctx, volumeID); err != nil {
if util.IgnoreLinodeAPIError(err, http.StatusNotFound) != nil {
logger.Error(err, "Failed to delete volume")
Expand Down

0 comments on commit db7f34a

Please sign in to comment.