mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-5707. Hitting multiple 'User unauthenticated' exceptions when vCenter is upgraded to 5.5 from 5.1.
We hit these excptions whenever a management server held session that was with the old 5.1 vCenter server is used to make resource calls to the new 5.5 vCenter. Validate a vCenter session context before it is being used to make a resource call. And if the context is invalid then discard the context and retrieve a new one. During the invalidation of an old context handle the context disconnect better by catching the appropriate exception and returning a newly created context. Conflicts: plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
This commit is contained in:
parent
af657b3d71
commit
a957d52a3c
@ -89,7 +89,7 @@ public class VmwareContextFactory {
|
||||
} else {
|
||||
// Validate current context and verify if vCenter session timeout value of the context matches the timeout value set by Admin
|
||||
if (!context.validate() || (context.getVimClient().getVcenterSessionTimeout() != s_vmwareMgr.getVcenterSessionTimeout())) {
|
||||
s_logger.info("Validation of the context faild. dispose and create a new one");
|
||||
s_logger.info("Validation of the context failed, dispose and create a new one");
|
||||
context.close();
|
||||
context = create(vCenterAddress, vCenterUserName, vCenterPassword);
|
||||
}
|
||||
|
||||
@ -6896,10 +6896,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
|
||||
@Override
|
||||
public VmwareContext getServiceContext(Command cmd) {
|
||||
if (s_serviceContext.get() != null)
|
||||
return s_serviceContext.get();
|
||||
|
||||
VmwareContext context = null;
|
||||
if(s_serviceContext.get() != null) {
|
||||
context = s_serviceContext.get();
|
||||
if (context.validate()) {
|
||||
return context;
|
||||
} else {
|
||||
s_logger.info("Validation of the context failed, dispose and use a new one");
|
||||
invalidateServiceContext(context);
|
||||
}
|
||||
}
|
||||
try {
|
||||
context = VmwareContextFactory.getContext(_vCenterAddress, _username, _password);
|
||||
s_serviceContext.set(context);
|
||||
|
||||
@ -214,18 +214,23 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
||||
_resource.ensureOutgoingRuleForAddress(vCenterAddress);
|
||||
|
||||
VmwareContext context = currentContext.get();
|
||||
if (context == null) {
|
||||
if (context != null) {
|
||||
if(!context.validate()) {
|
||||
invalidateServiceContext(context);
|
||||
context = null;
|
||||
} else {
|
||||
context.registerStockObject("serviceconsole", cmd.getContextParam("serviceconsole"));
|
||||
context.registerStockObject("manageportgroup", cmd.getContextParam("manageportgroup"));
|
||||
context.registerStockObject("noderuninfo", cmd.getContextParam("noderuninfo"));
|
||||
}
|
||||
}
|
||||
if(context == null) {
|
||||
s_logger.info("Open new VmwareContext. vCenter: " + vCenterAddress + ", user: " + username + ", password: " +
|
||||
StringUtils.getMaskedPasswordForDisplay(password));
|
||||
StringUtils.getMaskedPasswordForDisplay(password));
|
||||
VmwareSecondaryStorageContextFactory.setVcenterSessionTimeout(vCenterSessionTimeout);
|
||||
context = VmwareSecondaryStorageContextFactory.getContext(vCenterAddress, username, password);
|
||||
}
|
||||
|
||||
if (context != null) {
|
||||
context.registerStockObject("serviceconsole", cmd.getContextParam("serviceconsole"));
|
||||
context.registerStockObject("manageportgroup", cmd.getContextParam("manageportgroup"));
|
||||
context.registerStockObject("noderuninfo", cmd.getContextParam("noderuninfo"));
|
||||
}
|
||||
currentContext.set(context);
|
||||
return context;
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -37,6 +37,7 @@ import java.util.Map;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.xml.ws.soap.SOAPFaultException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -638,16 +639,18 @@ public class VmwareContext {
|
||||
public void close() {
|
||||
clearStockObjects();
|
||||
try {
|
||||
s_logger.info("Disconnecting VMware session");
|
||||
_vimClient.disconnect();
|
||||
} catch(SOAPFaultException sfe) {
|
||||
s_logger.debug("Tried to disconnect a session that is no longer valid");
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unexpected exception: ", e);
|
||||
} finally {
|
||||
if (_pool != null) {
|
||||
_pool.unregisterOutstandingContext(this);
|
||||
}
|
||||
unregisterOutstandingContext();
|
||||
}
|
||||
|
||||
if (_pool != null) {
|
||||
_pool.unregisterOutstandingContext(this);
|
||||
}
|
||||
|
||||
unregisterOutstandingContext();
|
||||
}
|
||||
|
||||
public static class TrustAllManager implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user