You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@git.apache.org on 2017/05/16 06:40:24 UTC

[GitHub] rhtyd commented on a change in pull request #2092: CLOUDSTACK-8599: [VMware] Successful migration was reported as failure when vCenter session timed out

rhtyd commented on a change in pull request #2092: CLOUDSTACK-8599: [VMware] Successful migration was reported as failure when vCenter session timed out
URL: https://github.com/apache/cloudstack/pull/2092#discussion_r116664875
 
 

 ##########
 File path: vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
 ##########
 @@ -353,10 +356,36 @@ public boolean waitForTask(ManagedObjectReference task) throws InvalidPropertyFa
             if (result[1] instanceof LocalizedMethodFault) {
                 throw new RuntimeException(((LocalizedMethodFault) result[1]).getLocalizedMessage());
             }
-        } catch(WebServiceException we) {
-            s_logger.debug("Cancelling vCenter task because task failed with " + we.getLocalizedMessage());
+        } catch (WebServiceException we) {
+            s_logger.warn("Session to vCenter failed with: " + we.getLocalizedMessage());
+
+            TaskInfo taskInfo = (TaskInfo)getDynamicProperty(task, "info");
+            if (!taskInfo.isCancelable()) {
+                s_logger.warn("vCenter task: " + taskInfo.getName() + "(" + taskInfo.getKey() + ")" + " will continue to run on vCenter because the task cannot be cancelled");
+                throw new RuntimeException(we.getLocalizedMessage());
+            }
+
+            s_logger.debug("Cancelling vCenter task: " + taskInfo.getName() + "(" + taskInfo.getKey() + ")");
             getService().cancelTask(task);
-            throw new RuntimeException("vCenter task failed due to " + we.getLocalizedMessage());
+
+            // Since task cancellation is asynchronous, wait for the task to be cancelled
+            Object[] result = waitForValues(task, new String[] {"info.state", "info.error"}, new String[] {"state"},
 
 Review comment:
   Should there be a check for length of `result` to avoid array-bound exceptions when accessing `result[0]`, `result[1]` etc.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services