sureshanaparti 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_r116710430
 
 

 ##########
 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:
   @rhtyd ok. will check and update. Thanks for the review.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to