ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlun...@apache.org
Subject ambari git commit: AMBARI-17718: KERBEROS_CLIENT version sometimes gets set for a host (jluniya)
Date Fri, 15 Jul 2016 17:58:20 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 5ab3cc02b -> e8bd12b19


AMBARI-17718: KERBEROS_CLIENT version sometimes gets set for a host (jluniya)


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

Branch: refs/heads/trunk
Commit: e8bd12b19c580db0873aba1c70f00a59cac1f1c7
Parents: 5ab3cc0
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Fri Jul 15 10:58:14 2016 -0700
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Fri Jul 15 10:58:14 2016 -0700

----------------------------------------------------------------------
 .../listeners/upgrade/StackVersionListener.java | 31 ++++++++++++--------
 .../upgrade/StackVersionListenerTest.java       | 20 +++++++++++++
 2 files changed, 39 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e8bd12b1/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
index d9599cc..87247eb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
@@ -111,18 +111,25 @@ public class StackVersionListener {
     // Update host component version value if needed
     try {
       ServiceComponent sc = cluster.getService(sch.getServiceName()).getServiceComponent(sch.getServiceComponentName());
-      if (UNKNOWN_VERSION.equals(sc.getDesiredVersion())) {
-        processUnknownDesiredVersion(cluster, sc, sch, newVersion);
-      } else if (StringUtils.isNotBlank(newVersion)) {
-        String previousVersion = sch.getVersion();
-        if (previousVersion == null || UNKNOWN_VERSION.equalsIgnoreCase(previousVersion))
{
-          // value may be "UNKNOWN" when upgrading from older Ambari versions
-          // or if host component reports it's version for the first time
-          sch.setUpgradeState(UpgradeState.NONE);
-          sch.setVersion(newVersion);
-          bootstrapVersion(cluster, sch);
-        } else if (!StringUtils.equals(previousVersion, newVersion)) { //
-          processComponentVersionChange(cluster, sc, sch, newVersion);
+      if(!sc.isVersionAdvertised() && StringUtils.isNotBlank(newVersion)
+          && !UNKNOWN_VERSION.equalsIgnoreCase(newVersion)) {
+        LOG.error("ServiceComponent {0} doesn't advertise version, " +
+                "however ServiceHostComponent {} on host {} advertised version as {}. Skipping
version update",
+            sc.getName(), sch.getServiceComponentName(), sch.getHostName(), newVersion);
+      } else {
+        if (UNKNOWN_VERSION.equals(sc.getDesiredVersion())) {
+          processUnknownDesiredVersion(cluster, sc, sch, newVersion);
+        } else if (StringUtils.isNotBlank(newVersion)) {
+          String previousVersion = sch.getVersion();
+          if (previousVersion == null || UNKNOWN_VERSION.equalsIgnoreCase(previousVersion))
{
+            // value may be "UNKNOWN" when upgrading from older Ambari versions
+            // or if host component reports it's version for the first time
+            sch.setUpgradeState(UpgradeState.NONE);
+            sch.setVersion(newVersion);
+            bootstrapVersion(cluster, sch);
+          } else if (!StringUtils.equals(previousVersion, newVersion)) { //
+            processComponentVersionChange(cluster, sc, sch, newVersion);
+          }
         }
       }
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e8bd12b1/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
index 6177e6b..d22622e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
@@ -78,6 +78,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   @Test
   public void testRecalculateHostVersionStateWhenVersionIsNullAndNewVersionIsNotBlank() throws
AmbariException {
     expect(sch.getVersion()).andReturn(null);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     sch.setVersion(INVALID_NEW_VERSION);
     expectLastCall().once();
     expect(sch.recalculateHostVersionState()).andReturn(null).once();
@@ -90,6 +91,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   @Test
   public void testRecalculateHostVersionStateWhenVersionIsUnknownAndNewVersionIsNotBlank()
throws AmbariException {
     expect(sch.getVersion()).andReturn(UNKNOWN_VERSION);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     sch.setVersion(INVALID_NEW_VERSION);
     expectLastCall().once();
     expect(sch.recalculateHostVersionState()).andReturn(null).once();
@@ -102,6 +104,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   @Test
   public void testRecalculateClusterVersionStateWhenVersionIsNullAndNewVersionIsValid() throws
AmbariException {
     expect(sch.getVersion()).andReturn(null);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     sch.setVersion(VALID_NEW_VERSION);
     expectLastCall().once();
     expect(sch.recalculateHostVersionState()).andReturn(DUMMY_REPOSITORY_VERSION_ENTITY).once();
@@ -116,6 +119,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   @Test
   public void testRecalculateClusterVersionStateWhenVersionIsUnknownAndNewVersionIsValid()
throws AmbariException {
     expect(sch.getVersion()).andReturn(UNKNOWN_VERSION);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     sch.setVersion(VALID_NEW_VERSION);
     expectLastCall().once();
     expect(sch.recalculateHostVersionState()).andReturn(DUMMY_REPOSITORY_VERSION_ENTITY).once();
@@ -130,6 +134,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   @Test
   public void testRecalculateHostVersionStateWhenComponentDesiredVersionIsUnknownAndNewVersionIsNotValid()
throws AmbariException {
     expect(serviceComponent.getDesiredVersion()).andReturn(UNKNOWN_VERSION);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     serviceComponent.setDesiredVersion(INVALID_NEW_VERSION);
     expectLastCall().once();
     sch.setUpgradeState(UpgradeState.NONE);
@@ -146,6 +151,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   @Test
   public void testRecalculateClusterVersionStateWhenComponentDesiredVersionIsUnknownAndNewVersionIsValid()
throws AmbariException {
     expect(serviceComponent.getDesiredVersion()).andReturn(UNKNOWN_VERSION);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     serviceComponent.setDesiredVersion(VALID_NEW_VERSION);
     expectLastCall().once();
     sch.setUpgradeState(UpgradeState.NONE);
@@ -162,6 +168,14 @@ public class StackVersionListenerTest extends EasyMockSupport {
   }
 
   @Test
+  public void testRecalculateClusterVersionStateWhenVersionNotAdvertised() throws AmbariException
{
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.FALSE);
+    replayAll();
+    sendEventAndVerify(VALID_NEW_VERSION);
+  }
+
+
+  @Test
   public void testNoActionTakenOnNullVersion() {
     expect(serviceComponent.isVersionAdvertised()).andReturn(true);
     resetAll();
@@ -174,6 +188,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   public void testSetUpgradeStateToCompleteWhenUpgradeIsInProgressAndNewVersionIsEqualToComponentDesiredVersion()
{
     expect(sch.getVersion()).andReturn(VALID_PREVIOUS_VERSION);
     expect(sch.getUpgradeState()).andReturn(UpgradeState.IN_PROGRESS);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     sch.setUpgradeState(UpgradeState.COMPLETE);
     expectLastCall().once();
 
@@ -187,6 +202,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   public void testSetUpgradeStateToVersionMismatchWhenUpgradeIsInProgressAndNewVersionIsNotEqualToComponentDesiredVersion()
{
     expect(sch.getVersion()).andReturn(VALID_PREVIOUS_VERSION);
     expect(sch.getUpgradeState()).andReturn(UpgradeState.IN_PROGRESS);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     sch.setUpgradeState(UpgradeState.VERSION_MISMATCH);
     expectLastCall().once();
 
@@ -202,6 +218,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
     expect(sch.getUpgradeState()).andReturn(UpgradeState.VERSION_MISMATCH);
     expect(cluster.getUpgradeEntity()).andReturn(DUMMY_UPGRADE_ENTITY);
     expect(serviceComponent.getDesiredVersion()).andStubReturn(VALID_NEW_VERSION);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     sch.setUpgradeState(UpgradeState.COMPLETE);
     expectLastCall().once();
 
@@ -215,6 +232,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
     expect(sch.getVersion()).andReturn(VALID_PREVIOUS_VERSION);
     expect(sch.getUpgradeState()).andReturn(UpgradeState.VERSION_MISMATCH);
     expect(serviceComponent.getDesiredVersion()).andStubReturn(VALID_NEW_VERSION);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     sch.setUpgradeState(UpgradeState.NONE);
     expectLastCall().once();
 
@@ -226,6 +244,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   @Test
   public void testSetUpgradeStateToVersionMismatchByDefaultWhenHostAndNewVersionsAreValid()
{
     expect(sch.getVersion()).andReturn(VALID_PREVIOUS_VERSION);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
     sch.setUpgradeState(UpgradeState.VERSION_MISMATCH);
     expectLastCall().once();
 
@@ -237,6 +256,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   @Test
   public void testSetRepositoryVersion() throws Exception {
     expect(sch.getVersion()).andReturn(UNKNOWN_VERSION);
+    expect(serviceComponent.isVersionAdvertised()).andReturn(Boolean.TRUE);
 
     RepositoryVersionDAO dao = createNiceMock(RepositoryVersionDAO.class);
     RepositoryVersionEntity entity = createNiceMock(RepositoryVersionEntity.class);


Mime
View raw message