ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [1/2] ambari git commit: AMBARI-14074. RU: Perform Upgrade action becomes enabled before packages are even installed (dlysnichenko)
Date Thu, 26 Nov 2015 08:38:18 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 312cd5c80 -> 3d57232de
  refs/heads/trunk 3c1944c18 -> c51227fd0


AMBARI-14074. RU: Perform Upgrade action becomes enabled before packages are even installed
(dlysnichenko)


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

Branch: refs/heads/branch-2.1
Commit: 3d57232de2822a6e40ba3e084c488099c5da1253
Parents: 312cd5c
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Thu Nov 26 10:37:09 2015 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Thu Nov 26 10:37:09 2015 +0200

----------------------------------------------------------------------
 .../server/state/cluster/ClusterImpl.java       | 15 +++++++++---
 .../server/state/cluster/ClusterTest.java       | 25 ++++++++++++++++++--
 2 files changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3d57232d/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 f828a15..11c1f1b 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
@@ -1262,13 +1262,22 @@ public class ClusterImpl implements Cluster {
     if (stateToHosts.containsKey(RepositoryVersionState.INSTALLED) && stateToHosts.get(RepositoryVersionState.INSTALLED).size()
== totalHosts) {
       return RepositoryVersionState.INSTALLED;
     }
-    if (stateToHosts.containsKey(RepositoryVersionState.INSTALL_FAILED) && !stateToHosts.get(RepositoryVersionState.INSTALL_FAILED).isEmpty())
{
-      return RepositoryVersionState.INSTALL_FAILED;
+    if (stateToHosts.containsKey(RepositoryVersionState.INSTALL_FAILED) &&
+      !stateToHosts.get(RepositoryVersionState.INSTALL_FAILED).isEmpty()) {
+      // Installation failed on some host(s). But
+      // cluster version state should transition to Install Failed only after
+      // all hosts have finished installation. Otherwise, UI will misbehave
+      // (hide progress dialog before installation is finished)
+      if (! stateToHosts.containsKey(RepositoryVersionState.INSTALLING) ||
+        stateToHosts.get(RepositoryVersionState.INSTALLING).isEmpty()) {
+        return RepositoryVersionState.INSTALL_FAILED;
+      }
     }
 
     final int totalINSTALLING = stateToHosts.containsKey(RepositoryVersionState.INSTALLING)
? stateToHosts.get(RepositoryVersionState.INSTALLING).size() : 0;
     final int totalINSTALLED = stateToHosts.containsKey(RepositoryVersionState.INSTALLED)
? stateToHosts.get(RepositoryVersionState.INSTALLED).size() : 0;
-    if (totalINSTALLING + totalINSTALLED == totalHosts) {
+    final int totalINSTALL_FAILED = stateToHosts.containsKey(RepositoryVersionState.INSTALL_FAILED)
? stateToHosts.get(RepositoryVersionState.INSTALL_FAILED).size() : 0;
+    if (totalINSTALLING + totalINSTALLED + totalINSTALL_FAILED== totalHosts) {
       return RepositoryVersionState.INSTALLING;
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3d57232d/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 b2e2d68..3998f1c 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
@@ -1642,14 +1642,35 @@ public class ClusterTest {
     c1.transitionClusterVersion(stackId, stackVersion,
         RepositoryVersionState.INSTALLING);
 
+    // Installation on one host fails (other is continuing)
+    hv1.setState(RepositoryVersionState.INSTALL_FAILED);
+    hostVersionDAO.merge(hv1);
+    // Check that cluster version is still in a non-final state
+    c1.recalculateClusterVersionState(repositoryVersionEntity);
+    checkStackVersionState(stackId, stackVersion,
+      RepositoryVersionState.INSTALLING);
+
     h2.setState(HostState.HEALTHY);
     hv2.setState(RepositoryVersionState.INSTALLED);
     hostVersionDAO.merge(hv2);
+    // Now both cluster versions are in a final state, so
+    // cluster version state changes to final state
     c1.recalculateClusterVersionState(repositoryVersionEntity);
     checkStackVersionState(stackId, stackVersion,
-        RepositoryVersionState.INSTALLING);
+        RepositoryVersionState.INSTALL_FAILED);
+
+    // Retry by going back to INSTALLING
+    c1.transitionClusterVersion(stackId, stackVersion,
+      RepositoryVersionState.INSTALLING);
+
+    h2.setState(HostState.HEALTHY);
+    hv2.setState(RepositoryVersionState.INSTALLED);
+    hostVersionDAO.merge(hv2);
+    c1.recalculateClusterVersionState(repositoryVersionEntity);
+    checkStackVersionState(stackId, stackVersion,
+      RepositoryVersionState.INSTALLING);
 
-    // Make one host fail
+    // Make the last host fail
     hv1.setState(RepositoryVersionState.INSTALL_FAILED);
     hostVersionDAO.merge(hv1);
     c1.recalculateClusterVersionState(repositoryVersionEntity);


Mime
View raw message