You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/02/29 21:26:29 UTC

ambari git commit: AMBARI-15231. Cluster Stack Version returning wrong state (ncole)

Repository: ambari
Updated Branches:
  refs/heads/trunk 365c74b53 -> 15c992c5b


AMBARI-15231. Cluster Stack Version returning wrong state (ncole)


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

Branch: refs/heads/trunk
Commit: 15c992c5beb3210c5be23eda73869bab85b50fcb
Parents: 365c74b
Author: Nate Cole <nc...@hortonworks.com>
Authored: Mon Feb 29 14:13:17 2016 -0500
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Mon Feb 29 15:25:23 2016 -0500

----------------------------------------------------------------------
 .../server/state/cluster/ClusterImpl.java       |  7 +--
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  2 +-
 .../src/main/resources/version_definition.xsd   |  1 -
 .../server/state/cluster/ClusterTest.java       | 51 ++++++++++++++++----
 contrib/version-builder/example.sh              |  4 +-
 5 files changed, 48 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/15c992c5/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 9560a65..0592c05 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
@@ -1379,13 +1379,14 @@ public class ClusterImpl implements Cluster {
     }
 
     if (totalNotRequired > 0) {
+      if (totalInstalled + totalNotRequired == totalHosts) {
+        return RepositoryVersionState.INSTALLED;
+      }
+
       if (totalInstalling + totalInstalled + totalNotRequired == totalHosts) {
         return RepositoryVersionState.INSTALLING;
       }
 
-      if (totalInstalled + totalNotRequired == totalHosts) {
-        return RepositoryVersionState.INSTALLED;
-      }
     }
 
     // Also returns when have a mix of CURRENT and INSTALLING|INSTALLED

http://git-wip-us.apache.org/repos/asf/ambari/blob/15c992c5/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index bb47a8a..5d8899e 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -559,7 +559,7 @@ CREATE TABLE repo_version (
   repositories TEXT NOT NULL,
   repo_type VARCHAR(255) DEFAULT 'STANDARD' NOT NULL,
   version_url VARCHAR(1024),
-  version_xml VARCHAR TEXT,
+  version_xml TEXT,
   version_xsd VARCHAR(512),
   parent_id BIGINT,
   PRIMARY KEY(repo_version_id)

http://git-wip-us.apache.org/repos/asf/ambari/blob/15c992c5/ambari-server/src/main/resources/version_definition.xsd
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/version_definition.xsd b/ambari-server/src/main/resources/version_definition.xsd
index de0efd8..3c0399f 100644
--- a/ambari-server/src/main/resources/version_definition.xsd
+++ b/ambari-server/src/main/resources/version_definition.xsd
@@ -54,7 +54,6 @@
       <xs:enumeration value="ubuntu12" />
       <xs:enumeration value="ubuntu14" />
       <xs:enumeration value="suse11" />
-      <xs:enumeration value="amazon2015" />
     </xs:restriction>
   </xs:simpleType>
   

http://git-wip-us.apache.org/repos/asf/ambari/blob/15c992c5/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 a89eb1b..57e21d2 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
@@ -18,6 +18,16 @@
 
 package org.apache.ambari.server.state.cluster;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -119,16 +129,6 @@ import com.google.inject.util.Modules;
 
 import junit.framework.Assert;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
 public class ClusterTest {
 
   private static final EnumSet<RepositoryVersionState> TERMINAL_VERSION_STATES =
@@ -1717,6 +1717,37 @@ public class ClusterTest {
   }
 
   @Test
+  public void testRecalculateClusterVersionStateWithNotRequired() throws Exception {
+    createDefaultCluster();
+
+    Host h1 = clusters.getHost("h1");
+    h1.setState(HostState.HEALTHY);
+
+    Host h2 = clusters.getHost("h2");
+    h2.setState(HostState.HEALTHY);
+
+    // Phase 1: Install bits during distribution
+    StackId stackId = new StackId("HDP-0.1");
+    final String stackVersion = "0.1-1000";
+    RepositoryVersionEntity repositoryVersionEntity = helper.getOrCreateRepositoryVersion(
+        stackId,
+        stackVersion);
+    // Because the cluster already has a Cluster Version, an additional stack must init with INSTALLING
+    c1.createClusterVersion(stackId, stackVersion, "admin",
+        RepositoryVersionState.INSTALLING);
+    c1.setCurrentStackVersion(stackId);
+
+    HostVersionEntity hv1 = helper.createHostVersion("h1", repositoryVersionEntity, RepositoryVersionState.INSTALLED);
+    HostVersionEntity hv2 = helper.createHostVersion("h2", repositoryVersionEntity, RepositoryVersionState.NOT_REQUIRED);
+
+    c1.recalculateClusterVersionState(repositoryVersionEntity);
+    //Should remain in its current state
+    checkStackVersionState(stackId, stackVersion,
+        RepositoryVersionState.INSTALLED);
+  }
+
+
+  @Test
   public void testRecalculateAllClusterVersionStates() throws Exception {
     createDefaultCluster();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/15c992c5/contrib/version-builder/example.sh
----------------------------------------------------------------------
diff --git a/contrib/version-builder/example.sh b/contrib/version-builder/example.sh
index a93ddb6..7016997 100755
--- a/contrib/version-builder/example.sh
+++ b/contrib/version-builder/example.sh
@@ -20,7 +20,7 @@
 filename="version_241-12345.xml"
 
 python version_builder.py --file $filename --release-type PATCH
-python version_builder.py --file $filename --release-stack HDP-2.3
+python version_builder.py --file $filename --release-stack HDP-2.4
 python version_builder.py --file $filename --release-version 2.4.1.1
 python version_builder.py --file $filename --release-build 12345
 python version_builder.py --file $filename --release-notes http://example.com
@@ -35,7 +35,7 @@ python version_builder.py --file $filename --manifest --manifest-id HBASE-132 --
 python version_builder.py --file $filename --available --manifest-id HDFS-271
 
 #call any number of times for repo per os
-python version_builder.py --file $filename --repo --repo-os redhat6 --repo-id HDP-2.3 --repo-name HDP --repo-url http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.3.4.0
+python version_builder.py --file $filename --repo --repo-os redhat6 --repo-id HDP-2.4 --repo-name HDP --repo-url http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.4.1.1
 python version_builder.py --file $filename --repo --repo-os redhat6 --repo-id HDP-UTILS-1.1.0.20 --repo-name HDP-UTILS --repo-url http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos6
 
 python version_builder.py --file $filename --finalize --xsd ../../ambari-server/src/main/resources/version_definition.xsd