This is an automated email from the ASF dual-hosted git repository.
sateesh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new c5692ce CLOUDSTACK-8599 [VMware] Successful migration was reported as
failure when vCenter session timed out
c5692ce is described below
commit c5692cea4ed9b44276f5feb6163ac583b91ef341
Author: Suresh Kumar Anaparti <[email protected]>
AuthorDate: Wed May 10 08:21:07 2017 +0530
CLOUDSTACK-8599 [VMware] Successful migration was reported as failure when
vCenter session timed out
---
.../cloud/hypervisor/vmware/util/VmwareClient.java | 47 ++++++++++++++++++----
1 file changed, 40 insertions(+), 7 deletions(-)
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
index 96558ea..3050f0a 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
@@ -37,6 +37,7 @@ import com.vmware.vim25.InvalidCollectorVersionFaultMsg;
import com.vmware.vim25.InvalidPropertyFaultMsg;
import com.vmware.vim25.LocalizedMethodFault;
import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.MethodFault;
import com.vmware.vim25.ObjectContent;
import com.vmware.vim25.ObjectSpec;
import com.vmware.vim25.ObjectUpdate;
@@ -46,9 +47,11 @@ import com.vmware.vim25.PropertyChangeOp;
import com.vmware.vim25.PropertyFilterSpec;
import com.vmware.vim25.PropertyFilterUpdate;
import com.vmware.vim25.PropertySpec;
+import com.vmware.vim25.RequestCanceled;
import com.vmware.vim25.RuntimeFaultFaultMsg;
import com.vmware.vim25.SelectionSpec;
import com.vmware.vim25.ServiceContent;
+import com.vmware.vim25.TaskInfo;
import com.vmware.vim25.TaskInfoState;
import com.vmware.vim25.TraversalSpec;
import com.vmware.vim25.UpdateSet;
@@ -347,16 +350,46 @@ public class VmwareClient {
Object[] result = waitForValues(task, new String[] { "info.state",
"info.error" }, new String[] { "state" }, new Object[][] { new Object[] {
TaskInfoState.SUCCESS, TaskInfoState.ERROR } });
- if (result[0].equals(TaskInfoState.SUCCESS)) {
- retVal = true;
+ if (result != null && result.length == 2) { //result for 2
properties: info.state, info.error
+ if (result[0].equals(TaskInfoState.SUCCESS)) {
+ retVal = true;
+ }
+ if (result[1] instanceof LocalizedMethodFault) {
+ throw new
RuntimeException(((LocalizedMethodFault)result[1]).getLocalizedMessage());
+ }
}
- if (result[1] instanceof LocalizedMethodFault) {
- throw new RuntimeException(((LocalizedMethodFault)
result[1]).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());
}
- } catch(WebServiceException we) {
- s_logger.debug("Cancelling vCenter task because task failed with "
+ 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"},
+ new Object[][] {new Object[] {TaskInfoState.SUCCESS,
TaskInfoState.ERROR}});
+
+ if (result != null && result.length == 2) { //result for 2
properties: info.state, info.error
+ if (result[0].equals(TaskInfoState.SUCCESS)) {
+ s_logger.warn("Failed to cancel vCenter task: " +
taskInfo.getName() + "(" + taskInfo.getKey() + ")" + " and the task
successfully completed");
+ retVal = true;
+ }
+
+ if (result[1] instanceof LocalizedMethodFault) {
+ MethodFault fault =
((LocalizedMethodFault)result[1]).getFault();
+ if (fault instanceof RequestCanceled) {
+ s_logger.debug("vCenter task " + taskInfo.getName() +
"(" + taskInfo.getKey() + ")" + " was successfully cancelled");
+ throw new RuntimeException(we.getLocalizedMessage());
+ }
+ } else {
+ throw new
RuntimeException(((LocalizedMethodFault)result[1]).getLocalizedMessage());
+ }
+ }
}
return retVal;
}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].