Forráskód Böngészése

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

Nate Cole 9 éve
szülő
commit
15c992c5be

+ 4 - 3
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

+ 1 - 1
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)

+ 0 - 1
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>
   

+ 41 - 10
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 =
@@ -1716,6 +1716,37 @@ public class ClusterTest {
         RepositoryVersionState.CURRENT);
   }
 
+  @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();

+ 2 - 2
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