Skip to content

Commit 16bc6eb

Browse files
Merge pull request openshift#7515 from cjschaef/ibmcloud_destroy_disk_failure
OCPBUGS-20085: IBMCloud: Handle disk delete errors
2 parents 9376c2f + 13f2f9e commit 16bc6eb

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

pkg/destroy/ibmcloud/disk.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ibmcloud
22

33
import (
4+
"fmt"
45
"net/http"
56
"strings"
67

@@ -58,14 +59,16 @@ func (o *ClusterUninstaller) deleteDisk(item cloudResource) error {
5859
options := o.vpcSvc.NewDeleteVolumeOptions(item.id)
5960
details, err := o.vpcSvc.DeleteVolumeWithContext(ctx, options)
6061

61-
if err != nil && details.StatusCode != http.StatusNotFound {
62-
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)
63-
}
62+
if err != nil {
63+
if details == nil || details.StatusCode != http.StatusNotFound {
64+
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)
65+
}
6466

65-
if err != nil && details.StatusCode == http.StatusNotFound {
66-
// The resource is gone
67-
o.deletePendingItems(item.typeName, []cloudResource{item})
68-
o.Logger.Infof("Deleted disk %s", item.id)
67+
if details.StatusCode == http.StatusNotFound {
68+
// The resource is gone
69+
o.deletePendingItems(item.typeName, []cloudResource{item})
70+
o.Logger.Infof("Deleted disk %s", item.id)
71+
}
6972
}
7073

7174
return nil
@@ -81,9 +84,11 @@ func (o *ClusterUninstaller) waitForDiskDeletion(item cloudResource) error {
8184
volumeOptions := o.vpcSvc.NewGetVolumeOptions(item.id)
8285
_, response, err := o.vpcSvc.GetVolumeWithContext(ctx, volumeOptions)
8386
// Keep retry, until GetVolume returns volume not found
84-
if err != nil && response.StatusCode == http.StatusNotFound {
85-
skip = true
86-
return nil, skip
87+
if err != nil {
88+
if response != nil && response.StatusCode == http.StatusNotFound {
89+
skip = true
90+
return nil, skip
91+
}
8792
}
8893
return err, false // continue retry as we are not seeing error which means volume is available
8994
})

0 commit comments

Comments
 (0)