From 42acba9690393bbbcc3f76dddd38953b4dbf8786 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Mon, 28 Aug 2023 15:18:38 -0600 Subject: [PATCH] PowerFlex: Handle missing volumes gracefully during delete volume --- .../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 61e190d5239c..fa4283139432 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 boolean deleteVolume(final String volumeId) { 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; }