From 89e0a4ca25c108f9c0a166a741c15180bed10712 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Thu, 31 Aug 2023 13:43:45 -0600 Subject: [PATCH] PowerFlex: Handle missing volumes gracefully during delete volume (#7924) --- .../client/ScaleIOGatewayClientImpl.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/client/ScaleIOGatewayClientImpl.java b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/client/ScaleIOGatewayClientImpl.java index 61e190d5239..fa428313943 100644 --- a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/client/ScaleIOGatewayClientImpl.java +++ b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/client/ScaleIOGatewayClientImpl.java @@ -738,11 +738,20 @@ public class ScaleIOGatewayClientImpl implements ScaleIOGatewayClient { try { unmapVolumeFromAllSdcs(volumeId); } catch (Exception ignored) {} - Boolean removeVolumeStatus = post( - "/instances/Volume::" + volumeId + "/action/removeVolume", - "{\"removeMode\":\"ONLY_ME\"}", Boolean.class); - if (removeVolumeStatus != null) { - return removeVolumeStatus; + + try { + Boolean removeVolumeStatus = post( + "/instances/Volume::" + volumeId + "/action/removeVolume", + "{\"removeMode\":\"ONLY_ME\"}", Boolean.class); + if (removeVolumeStatus != null) { + return removeVolumeStatus; + } + } catch (Exception ex) { + if (ex instanceof ServerApiException && ex.getMessage().contains("Could not find the volume")) { + LOG.warn(String.format("API says deleting volume %s does not exist, handling gracefully", volumeId)); + return true; + } + throw ex; } return false; }