Repository: cloudstack
Updated Branches:
  refs/heads/master 2bf72a781 -> f1e3e83bb


BUG-ID: CLOUDSTACK-7652. [VMware] 'SOAPFaultException: The object has already 
been deleted or has not been completely created' exceptions.
If CCP thread local context which is used to handle connections to a vCenter is 
being re-used, validate that the context corresponds to the right vCenter API 
session.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6b069703
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6b069703
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6b069703

Branch: refs/heads/master
Commit: 6b069703666c33636a545e7093eccf04efff88e7
Parents: 2bf72a7
Author: Likitha Shetty <likitha.she...@citrix.com>
Authored: Tue Sep 23 13:32:06 2014 +0530
Committer: Likitha Shetty <likitha.she...@citrix.com>
Committed: Tue Sep 30 15:20:14 2014 +0530

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6b069703/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 489cf43..226a884 100755
--- 
a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ 
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -239,6 +239,7 @@ import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
 import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
 import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostResourceSummary;
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+import com.cloud.hypervisor.vmware.util.VmwareContextPool;
 import com.cloud.hypervisor.vmware.util.VmwareHelper;
 import com.cloud.network.Networks;
 import com.cloud.network.Networks.BroadcastDomainType;
@@ -4794,14 +4795,21 @@ public class VmwareResource implements 
StoragePoolResource, ServerResource, Vmwa
         VmwareContext context = null;
         if(s_serviceContext.get() != null) {
             context = s_serviceContext.get();
-            if (context.validate()) {
-                if (s_logger.isTraceEnabled()) {
-                    s_logger.trace("ThreadLocal context is still valid, just 
reuse");
+            String poolKey = VmwareContextPool.composePoolKey(_vCenterAddress, 
_username);
+            // Before re-using the thread local context, ensure it corresponds 
to the right vCenter API session and that it is valid to make calls.
+            if(context.getPoolKey().equals(poolKey)) {
+                if (context.validate()) {
+                    if (s_logger.isTraceEnabled()) {
+                        s_logger.trace("ThreadLocal context is still valid, 
just reuse");
+                    }
+                    return context;
+                } else {
+                    s_logger.info("Validation of the context failed, dispose 
and use a new one");
+                    invalidateServiceContext(context);
                 }
-                return context;
             } else {
-                s_logger.info("Validation of the context failed, dispose and 
use a new one");
-                invalidateServiceContext(context);
+                // Exisitng ThreadLocal context corresponds to a different 
vCenter API session. Why has it not been recycled?
+                s_logger.warn("ThreadLocal VMware context: " + poolKey + " 
doesn't correspond to the right vCenter. Expected VMware context: " + 
context.getPoolKey());
             }
         }
         try {

Reply via email to