cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From likit...@apache.org
Subject git commit: updated refs/heads/master to a957d52
Date Tue, 14 Jan 2014 04:17:34 GMT
Updated Branches:
  refs/heads/master af657b3d7 -> a957d52a3


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


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

Branch: refs/heads/master
Commit: a957d52a3c74c37d7dbe77b42a3c4ed74c81fa7f
Parents: af657b3
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Mon Jan 13 10:14:54 2014 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Tue Jan 14 09:38:50 2014 +0530

----------------------------------------------------------------------
 .../vmware/resource/VmwareContextFactory.java    |  2 +-
 .../vmware/resource/VmwareResource.java          | 12 +++++++++---
 .../VmwareSecondaryStorageResourceHandler.java   | 19 ++++++++++++-------
 .../hypervisor/vmware/util/VmwareContext.java    | 15 +++++++++------
 4 files changed, 31 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a957d52a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
index cdd0c29..11163e9 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
@@ -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);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a957d52a/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 4aa6f27..8b25276 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
@@ -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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a957d52a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
index c91d7b6..7e08aec 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
@@ -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) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a957d52a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
index 4c3ff55..eaa205e 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
@@ -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
{


Mime
View raw message