From b86673058b44b4f638b66aab52016305dc078682 Mon Sep 17 00:00:00 2001 From: SadiJr Date: Thu, 17 Mar 2022 09:47:11 -0300 Subject: [PATCH 1/3] Fix exception, in VMWare 6.5, when trying to detach volume --- .../resource/VmwareStorageLayoutHelper.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java index 54b899b91235..e1886bce2c8f 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java @@ -247,11 +247,25 @@ public static void syncVolumeToRootFolder(DatacenterMO dcMo, DatastoreMO ds, Str s_logger.info("Fixup folder-synchronization. move " + fileDsFullPath + " -> " + targetPath); ds.moveDatastoreFile(fileDsFullPath, dcMo.getMor(), ds.getMor(), targetPath, dcMo.getMor(), true); - if (folderName != null) { - String[] files = ds.listDirContent(folderName); - if (files == null || files.length == 0) { - ds.deleteFolder(folderName, dcMo.getMor()); + try { + if (folderName != null) { + String[] files = ds.listDirContent(folderName); + if (files == null || files.length == 0) { + ds.deleteFolder(folderName, dcMo.getMor()); + } } + } catch (Exception e) { + String firstLink = "https://communities.vmware.com/t5/VMware-vSphere-Discussions/VCSA-6-7-Datastore-browser-empty-error-500/td-p/2300628"; + String secondLink = "https://communities.vmware.com/t5/vCenter-Server-Discussions/Cannot-Open-VM-folder-in-url-in-vCenter-appliance-6-7/m-p/1871308"; + String thirdLink = "https://www.mail-archive.com/users@cloudstack.apache.org/msg31406.html"; + String jiraIssue = "https://issues.apache.org/jira/browse/CLOUDSTACK-8600"; + String prLink = "https://github.com/apache/cloudstack/pull/545"; + String message = String.format("Failed to list folder content of VM [name: %s] due to: [%s]. For more information about this error, please check this links [%s, %s, %s]. " + + "To know why ACS tries to check folder content, please check these links [%s, %s]. This error apparently only occurs with datastores that use the NFS protocol and " + + "in specific versions of VMWare. Users using VMFS or VMWare versions greater than 6.7 have not reported this error. If the operation performed is a volume detach, " + + "it was successful. If you want to know why this error occurs in VMWare, please contact VMWare's technical support.", + vmName, e.getMessage(), firstLink, secondLink, thirdLink, jiraIssue, prLink); + s_logger.warn(message, e); } } From 9e0c781b85d697ccedc8900dfda1bc598276363a Mon Sep 17 00:00:00 2001 From: SadiJr Date: Fri, 22 Apr 2022 10:51:09 -0300 Subject: [PATCH 2/3] Address reviews --- .../storage/resource/VmwareStorageLayoutHelper.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java index e1886bce2c8f..21453cb439ab 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java @@ -255,16 +255,12 @@ public static void syncVolumeToRootFolder(DatacenterMO dcMo, DatastoreMO ds, Str } } } catch (Exception e) { - String firstLink = "https://communities.vmware.com/t5/VMware-vSphere-Discussions/VCSA-6-7-Datastore-browser-empty-error-500/td-p/2300628"; - String secondLink = "https://communities.vmware.com/t5/vCenter-Server-Discussions/Cannot-Open-VM-folder-in-url-in-vCenter-appliance-6-7/m-p/1871308"; - String thirdLink = "https://www.mail-archive.com/users@cloudstack.apache.org/msg31406.html"; - String jiraIssue = "https://issues.apache.org/jira/browse/CLOUDSTACK-8600"; - String prLink = "https://github.com/apache/cloudstack/pull/545"; - String message = String.format("Failed to list folder content of VM [name: %s] due to: [%s]. For more information about this error, please check this links [%s, %s, %s]. " - + "To know why ACS tries to check folder content, please check these links [%s, %s]. This error apparently only occurs with datastores that use the NFS protocol and " + String link = "https://github.com/apache/cloudstack/pull/6283"; + String message = String.format("Failed to list folder content of VM [name: %s] due to: [%s]. For more information about this error, or " + + "to know why ACS tries to check folder content, please check this link [%s]. This error apparently only occurs with datastores that use the NFS protocol and " + "in specific versions of VMWare. Users using VMFS or VMWare versions greater than 6.7 have not reported this error. If the operation performed is a volume detach, " + "it was successful. If you want to know why this error occurs in VMWare, please contact VMWare's technical support.", - vmName, e.getMessage(), firstLink, secondLink, thirdLink, jiraIssue, prLink); + vmName, e.getMessage(), link); s_logger.warn(message, e); } } From 5225ecd35c4182bb3d1172397f476da907028b16 Mon Sep 17 00:00:00 2001 From: SadiJr Date: Tue, 26 Apr 2022 13:10:41 -0300 Subject: [PATCH 3/3] Address reviews --- .../resource/VmwareStorageLayoutHelper.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java index 21453cb439ab..1cb57c37813d 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/storage/resource/VmwareStorageLayoutHelper.java @@ -255,13 +255,19 @@ public static void syncVolumeToRootFolder(DatacenterMO dcMo, DatastoreMO ds, Str } } } catch (Exception e) { - String link = "https://github.com/apache/cloudstack/pull/6283"; - String message = String.format("Failed to list folder content of VM [name: %s] due to: [%s]. For more information about this error, or " - + "to know why ACS tries to check folder content, please check this link [%s]. This error apparently only occurs with datastores that use the NFS protocol and " - + "in specific versions of VMWare. Users using VMFS or VMWare versions greater than 6.7 have not reported this error. If the operation performed is a volume detach, " - + "it was successful. If you want to know why this error occurs in VMWare, please contact VMWare's technical support.", - vmName, e.getMessage(), link); - s_logger.warn(message, e); + if (e.getMessage().toLowerCase().startsWith("server returned http response code: 500 for url: ") && + e.getMessage().contains(vmName)) { + String link = "https://github.com/apache/cloudstack/pull/6283"; + String message = String.format("Failed to list folder content of VM [name: %s] due to: [%s]. For more information about this error, or " + + "to know why ACS tries to check folder content, please check this link [%s]. This error apparently only occurs with datastores that use the NFS protocol and " + + "in specific versions of VMWare. Users using VMFS or VMWare versions greater than 6.7 have not reported this error. If the operation performed is a volume detach, " + + "it was successful. If you want to know why this error occurs in VMWare, please contact VMWare's technical support.", + vmName, e.getMessage(), link); + s_logger.warn(message, e); + } else { + s_logger.error(String.format("Failed to sync volume [%s] of VM [%s] due to: [%s].", vmdkName, vmName, e.getMessage()), e); + throw e; + } } }