You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/06/01 12:52:20 UTC

[GitHub] [cloudstack] GutoVeronezi commented on a change in pull request #5053: xenserver: attempt eject and destroying patch VBD separately

GutoVeronezi commented on a change in pull request #5053:
URL: https://github.com/apache/cloudstack/pull/5053#discussion_r643073441



##########
File path: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
##########
@@ -1522,12 +1522,16 @@ public void destroyPatchVbd(final Connection conn, final Set<VM> vms) throws Xml
                             vbd.insert(conn, patchVDI);
                             vbd.eject(conn);
                         }
+                    } catch (Exception e) {
+                        s_logger.debug("Cannot eject CD-ROM device for VM " + vmName + " due to " + e.toString(), e);
+                    }
+                    try {
                         vbd.destroy(conn);
-                        break;
+                    } catch (Exception e) {
+                        s_logger.debug("Cannot destroy CD-ROM device for VM " + vmName + " due to " + e.toString(), e);

Review comment:
       Same here.

##########
File path: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
##########
@@ -1522,12 +1522,16 @@ public void destroyPatchVbd(final Connection conn, final Set<VM> vms) throws Xml
                             vbd.insert(conn, patchVDI);
                             vbd.eject(conn);
                         }
+                    } catch (Exception e) {
+                        s_logger.debug("Cannot eject CD-ROM device for VM " + vmName + " due to " + e.toString(), e);

Review comment:
       Should an exception be logged in `debug`?

##########
File path: plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
##########
@@ -1507,13 +1507,13 @@ public void destroyPatchVbd(final Connection conn, final Set<VM> vms) throws Xml
         final VDI patchVDI = findPatchIsoVDI(conn, sr);
         for (final VM vm : vms) {
             final String vmName = vm.getNameLabel(conn);
-            try {
-                if (!vmName.startsWith("r-") && !vmName.startsWith("s-") && !vmName.startsWith("v-")) {
-                    return;
-                }
-                final Set<VBD> vbds = vm.getVBDs(conn);
-                for (final VBD vbd : vbds) {
-                    if (Types.VbdType.CD.equals(vbd.getType(conn))) {
+            if (!vmName.startsWith("r-") && !vmName.startsWith("s-") && !vmName.startsWith("v-")) {

Review comment:
       To simplify the validation, we could use `StringUtils.startsWithAny`, from `commons.lang3`:
   
   ```java
   if (!StringUtils.startsWithAny(vmName, "r-", "s-", v-")) {
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org