You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2015/11/18 20:49:04 UTC

ambari git commit: AMBARI-13930: Express Upgrade: Failure at Save Cluster State because cluster_version=OUT_OF_SYNC (jluniya)

Repository: ambari
Updated Branches:
  refs/heads/trunk a63b73f2d -> 851b662b7


AMBARI-13930: Express Upgrade: Failure at Save Cluster State because cluster_version=OUT_OF_SYNC (jluniya)


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

Branch: refs/heads/trunk
Commit: 851b662b748aac2e46e3a8f5dc1af15e0de716bf
Parents: a63b73f
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Wed Nov 18 11:48:50 2015 -0800
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Wed Nov 18 11:48:50 2015 -0800

----------------------------------------------------------------------
 .../org/apache/ambari/server/api/handlers/CreateHandler.java | 4 ++--
 .../org/apache/ambari/server/state/cluster/ClusterImpl.java  | 8 ++++++++
 .../org/apache/ambari/server/state/cluster/ClusterTest.java  | 8 ++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/851b662b/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java
index 9690bcd..706d2be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java
@@ -54,7 +54,7 @@ public class CreateHandler extends BaseManagementHandler {
       result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.NOT_FOUND, e.getMessage()));
     } catch (SystemException e) {
       if (LOG.isErrorEnabled()) {
-        LOG.error("Caught a system exception while attempting to create a resource: {}", e.getMessage());
+        LOG.error("Caught a system exception while attempting to create a resource: {}", e.getMessage(), e);
       }
       result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.SERVER_ERROR, e.getMessage()));
     } catch (ResourceAlreadyExistsException e) {
@@ -63,7 +63,7 @@ public class CreateHandler extends BaseManagementHandler {
       result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e.getMessage()));
     } catch (RuntimeException e) {
       if (LOG.isErrorEnabled()) {
-        LOG.error("Caught a runtime exception while attempting to create a resource", e);
+        LOG.error("Caught a runtime exception while attempting to create a resource: {}", e.getMessage(), e);
       }
       //result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.SERVER_ERROR, e.getMessage()));
       throw e;

http://git-wip-us.apache.org/repos/asf/ambari/blob/851b662b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 8e31f3c..2f4dae0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -1221,6 +1221,7 @@ public class ClusterImpl implements Cluster {
    * UPGRADE_FAILED: at least one host in UPGRADE_FAILED
    * UPGRADED: all hosts are UPGRADED
    * UPGRADING: at least one host is UPGRADING, and the rest in UPGRADING|INSTALLED
+   * UPGRADING: at least one host is UPGRADED, and the rest in UPGRADING|INSTALLED
    * INSTALLED: all hosts in INSTALLED
    * INSTALL_FAILED: at least one host in INSTALL_FAILED
    * INSTALLING: all hosts in INSTALLING. Notice that if one host is CURRENT and another is INSTALLING, then the
@@ -1251,6 +1252,13 @@ public class ClusterImpl implements Cluster {
     if (stateToHosts.containsKey(RepositoryVersionState.UPGRADING) && !stateToHosts.get(RepositoryVersionState.UPGRADING).isEmpty()) {
       return RepositoryVersionState.UPGRADING;
     }
+    if (stateToHosts.containsKey(RepositoryVersionState.UPGRADED)
+        && !stateToHosts.get(RepositoryVersionState.UPGRADED).isEmpty()
+        && stateToHosts.get(RepositoryVersionState.UPGRADED).size() != totalHosts) {
+      // It is possible that a host has transitioned to UPGRADED state even before any other host has transitioned to UPGRADING state.
+      // Example: Host with single component ZOOKEEPER Server on it which is the first component to be upgraded.
+      return RepositoryVersionState.UPGRADING;
+    }
     if (stateToHosts.containsKey(RepositoryVersionState.INSTALLED) && stateToHosts.get(RepositoryVersionState.INSTALLED).size() == totalHosts) {
       return RepositoryVersionState.INSTALLED;
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/851b662b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
index 28ba0e7..b2e2d68 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
@@ -1673,6 +1673,14 @@ public class ClusterTest {
     checkStackVersionState(stackId, stackVersion,
         RepositoryVersionState.UPGRADING);
 
+    hv1.setState(RepositoryVersionState.UPGRADED);
+    hostVersionDAO.merge(hv1);
+    c1.recalculateClusterVersionState(repositoryVersionEntity);
+    checkStackVersionState(stackId, stackVersion,
+        RepositoryVersionState.UPGRADING);
+    // reset host1 state
+    hv1.setState(RepositoryVersionState.UPGRADING);
+
     hv2.setState(RepositoryVersionState.UPGRADING);
     hostVersionDAO.merge(hv2);
     c1.recalculateClusterVersionState(repositoryVersionEntity);