Skip to content

Commit 6b06970

Browse files
author
Likitha Shetty
committed
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.
1 parent 2bf72a7 commit 6b06970

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
240240
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostResourceSummary;
241241
import com.cloud.hypervisor.vmware.util.VmwareContext;
242+
import com.cloud.hypervisor.vmware.util.VmwareContextPool;
242243
import com.cloud.hypervisor.vmware.util.VmwareHelper;
243244
import com.cloud.network.Networks;
244245
import com.cloud.network.Networks.BroadcastDomainType;
@@ -4794,14 +4795,21 @@ public VmwareContext getServiceContext(Command cmd) {
47944795
VmwareContext context = null;
47954796
if(s_serviceContext.get() != null) {
47964797
context = s_serviceContext.get();
4797-
if (context.validate()) {
4798-
if (s_logger.isTraceEnabled()) {
4799-
s_logger.trace("ThreadLocal context is still valid, just reuse");
4798+
String poolKey = VmwareContextPool.composePoolKey(_vCenterAddress, _username);
4799+
// Before re-using the thread local context, ensure it corresponds to the right vCenter API session and that it is valid to make calls.
4800+
if(context.getPoolKey().equals(poolKey)) {
4801+
if (context.validate()) {
4802+
if (s_logger.isTraceEnabled()) {
4803+
s_logger.trace("ThreadLocal context is still valid, just reuse");
4804+
}
4805+
return context;
4806+
} else {
4807+
s_logger.info("Validation of the context failed, dispose and use a new one");
4808+
invalidateServiceContext(context);
48004809
}
4801-
return context;
48024810
} else {
4803-
s_logger.info("Validation of the context failed, dispose and use a new one");
4804-
invalidateServiceContext(context);
4811+
// Exisitng ThreadLocal context corresponds to a different vCenter API session. Why has it not been recycled?
4812+
s_logger.warn("ThreadLocal VMware context: " + poolKey + " doesn't correspond to the right vCenter. Expected VMware context: " + context.getPoolKey());
48054813
}
48064814
}
48074815
try {

0 commit comments

Comments
 (0)