ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject ambari git commit: AMBARI-21967. Exception was thrown while starting Patch Rolling/Express Upgrade when upgrade failure tolerance option is selected (ncole)
Date Fri, 15 Sep 2017 15:06:40 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 2de51400d -> fed32b85a


AMBARI-21967. Exception was thrown while starting Patch Rolling/Express Upgrade when upgrade
failure tolerance option is selected (ncole)


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

Branch: refs/heads/trunk
Commit: fed32b85a6c1f8fc28036f02df39fe8fa6a3bfb5
Parents: 2de5140
Author: Nate Cole <ncole@hortonworks.com>
Authored: Fri Sep 15 10:00:53 2017 -0400
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Fri Sep 15 11:05:21 2017 -0400

----------------------------------------------------------------------
 .../ambari/server/state/UpgradeHelper.java      | 25 ++++++++---
 .../ambari/server/topology/TopologyManager.java |  1 -
 .../ambari/server/state/UpgradeHelperTest.java  | 44 ++++++++++++++++++++
 3 files changed, 64 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fed32b85/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
index 464cb41..087adc2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
@@ -563,15 +563,29 @@ public class UpgradeHelper {
     LinkedHashSet<StageWrapper> priority = new LinkedHashSet<>();
     LinkedHashSet<StageWrapper> others = new LinkedHashSet<>();
 
+    Set<String> extraKeys = new HashSet<>();
+    LinkedHashSet<StageWrapper> extras = new LinkedHashSet<>();
+
     for (List<StageWrapper> holderItems : new List[] { oldHolder.items, newHolder.items
}) {
       for (StageWrapper stageWrapper : holderItems) {
-        ServiceCheckStageWrapper wrapper = (ServiceCheckStageWrapper) stageWrapper;
-
-        if (wrapper.priority) {
-          priority.add(stageWrapper);
+        if (stageWrapper instanceof ServiceCheckStageWrapper) {
+          ServiceCheckStageWrapper wrapper = (ServiceCheckStageWrapper) stageWrapper;
+          if (wrapper.priority) {
+            priority.add(stageWrapper);
+          } else {
+            others.add(stageWrapper);
+          }
         } else {
-          others.add(stageWrapper);
+          // !!! It's a good chance that back-to-back service check groups are adding the
+          // same non-service-check wrappers.
+          // this should be "equal enough" to prevent them from duplicating on merge
+          String key = stageWrapper.toString();
+          if (!extraKeys.contains(key)) {
+            extras.add(stageWrapper);
+            extraKeys.add(key);
+          }
         }
+
       }
     }
 
@@ -580,6 +594,7 @@ public class UpgradeHelper {
 
     oldHolder.items = Lists.newLinkedList(priority);
     oldHolder.items.addAll(others);
+    oldHolder.items.addAll(extras);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/fed32b85/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index ce99e05..3af62e8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -79,7 +79,6 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.eventbus.Subscribe;
 import com.google.inject.Inject;
-import com.google.inject.Injector;
 import com.google.inject.Singleton;
 import com.google.inject.persist.Transactional;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/fed32b85/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
index 677b607..8b8e7e1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
@@ -2536,6 +2536,50 @@ public class UpgradeHelperTest extends EasyMockSupport {
   }
 
   @Test
+  public void testSequentialServiceChecksWithServiceCheckFailure() throws Exception {
+    Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1");
+    assertTrue(upgrades.containsKey("upgrade_test_checks"));
+    UpgradePack upgrade = upgrades.get("upgrade_test_checks");
+    assertNotNull(upgrade);
+
+    // !!! fake skippable so we don't affect other tests
+    for (Grouping g : upgrade.getAllGroups()) {
+      if (g.name.equals("SERVICE_CHECK_1") || g.name.equals("SERVICE_CHECK_2")) {
+        g.skippable = true;
+      }
+    }
+
+    Cluster cluster = makeCluster();
+    cluster.deleteService("HDFS");
+    cluster.deleteService("YARN");
+
+    UpgradeContext context = getMockUpgradeContext(cluster, Direction.UPGRADE, UpgradeType.ROLLING,
repositoryVersion2110,
+        RepositoryType.STANDARD, cluster.getServices().keySet(), m_masterHostResolver, false);
+    expect(context.isServiceCheckFailureAutoSkipped()).andReturn(Boolean.TRUE).atLeastOnce();
+
+    replay(context);
+
+    List<UpgradeGroupHolder> groups = m_upgradeHelper.createSequence(upgrade, context);
+    assertEquals(5, groups.size());
+
+    UpgradeGroupHolder serviceCheckGroup = groups.get(2);
+    assertEquals(ServiceCheckGrouping.class, serviceCheckGroup.groupClass);
+    assertEquals(4, serviceCheckGroup.items.size());
+
+    StageWrapper wrapper = serviceCheckGroup.items.get(0);
+    assertEquals(ServiceCheckGrouping.ServiceCheckStageWrapper.class, wrapper.getClass());
+    assertTrue(wrapper.getText().contains("ZooKeeper"));
+
+    wrapper = serviceCheckGroup.items.get(serviceCheckGroup.items.size()-1);
+    assertTrue(wrapper.getText().equals("Verifying Skipped Failures"));
+
+    // Do stacks cleanup
+    stackManagerMock.invalidateCurrentPaths();
+    ambariMetaInfo.init();
+  }
+
+
+  @Test
   public void testPrematureServiceChecks() throws Exception {
     Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1");
     assertTrue(upgrades.containsKey("upgrade_test_checks"));


Mime
View raw message