Skip to content

Commit

Permalink
OCPBUGS-20085: IBMCloud: Handle disk delete errors
Browse files Browse the repository at this point in the history
Handle cases when IBM Cloud disk deletion returns an error,
without any response data.

Related: https://issues.redhat.com//browse/OCPBUGS-20085
  • Loading branch information
cjschaef committed Feb 6, 2024
1 parent 9376c2f commit 3d1103b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions pkg/destroy/ibmcloud/disk.go
Expand Up @@ -58,14 +58,16 @@ func (o *ClusterUninstaller) deleteDisk(item cloudResource) error {
options := o.vpcSvc.NewDeleteVolumeOptions(item.id)
details, err := o.vpcSvc.DeleteVolumeWithContext(ctx, options)

if err != nil && details.StatusCode != http.StatusNotFound {
return errors.Wrapf(err, "Failed to delete disk name=%s, id=%s.If this error continues to persist for more than 20 minutes then please try to manually cleanup the volume using - ibmcloud is vold %s", item.name, item.id, item.id)
}
if err != nil {
if details == nil || details.StatusCode != http.StatusNotFound {
return fmt.Errorf("Failed to delete disk name=%s, id=%s.If this error continues to persist for more than 20 minutes then please try to manually cleanup the volume using - ibmcloud is vold %s: %w", item.name, item.id, item.id, err)
}

if err != nil && details.StatusCode == http.StatusNotFound {
// The resource is gone
o.deletePendingItems(item.typeName, []cloudResource{item})
o.Logger.Infof("Deleted disk %s", item.id)
if details.StatusCode == http.StatusNotFound {
// The resource is gone
o.deletePendingItems(item.typeName, []cloudResource{item})
o.Logger.Infof("Deleted disk %s", item.id)
}
}

return nil
Expand All @@ -81,9 +83,11 @@ func (o *ClusterUninstaller) waitForDiskDeletion(item cloudResource) error {
volumeOptions := o.vpcSvc.NewGetVolumeOptions(item.id)
_, response, err := o.vpcSvc.GetVolumeWithContext(ctx, volumeOptions)
// Keep retry, until GetVolume returns volume not found
if err != nil && response.StatusCode == http.StatusNotFound {
skip = true
return nil, skip
if err != nil {
if response != nil && response.StatusCode == http.StatusNotFound {
skip = true
return nil, skip
}
}
return err, false // continue retry as we are not seeing error which means volume is available
})
Expand Down

0 comments on commit 3d1103b

Please sign in to comment.