You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mp...@apache.org on 2016/06/23 15:03:54 UTC
[1/2] ambari git commit: AMBARI-17377. Rolling Upgrade process is
blocked after ambari-server/ambari-agent restart. (mpapirkovskyy)
Repository: ambari
Updated Branches:
refs/heads/branch-2.4 4b0e3b655 -> 1e0813ac1
refs/heads/trunk 5e11d0366 -> 7d317cc29
AMBARI-17377. Rolling Upgrade process is blocked after ambari-server/ambari-agent restart. (mpapirkovskyy)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7d317cc2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7d317cc2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7d317cc2
Branch: refs/heads/trunk
Commit: 7d317cc29dd4189dd19fdba3cbf44b70232d538e
Parents: 5e11d03
Author: Myroslav Papirkovskyi <mp...@hortonworks.com>
Authored: Wed Jun 22 19:47:30 2016 +0300
Committer: Myroslav Papirkovskyi <mp...@hortonworks.com>
Committed: Thu Jun 23 17:59:47 2016 +0300
----------------------------------------------------------------------
.../actionmanager/ActionDBAccessorImpl.java | 2 +-
.../server/actionmanager/ActionScheduler.java | 4 +-
.../server/actionmanager/HostRoleStatus.java | 15 +++
.../stacks/HDP/2.2/upgrades/upgrade-2.2.xml | 1 +
.../stacks/HDP/2.2/upgrades/upgrade-2.3.xml | 1 +
.../stacks/HDP/2.2/upgrades/upgrade-2.4.xml | 1 +
.../stacks/HDP/2.3/upgrades/upgrade-2.3.xml | 1 +
.../stacks/HDP/2.3/upgrades/upgrade-2.4.xml | 1 +
.../stacks/HDP/2.3/upgrades/upgrade-2.5.xml | 1 +
.../stacks/HDP/2.4/upgrades/upgrade-2.4.xml | 1 +
.../stacks/HDP/2.4/upgrades/upgrade-2.5.xml | 1 +
.../stacks/HDP/2.5/upgrades/upgrade-2.5.xml | 1 +
.../actionmanager/TestActionScheduler.java | 100 +++++++++++++++++++
13 files changed, 127 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
index 0fa5aa9..b44dc78 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
@@ -168,7 +168,7 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
@Override
public Stage getStage(String actionId) {
StageEntity stageEntity = stageDAO.findByActionId(actionId);
- return stageFactory.createExisting(stageEntity);
+ return stageEntity == null ? null : stageFactory.createExisting(stageEntity);
}
/* (non-Javadoc)
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
index 622ee88..bb83dfb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
@@ -542,7 +542,7 @@ class ActionScheduler implements Runnable {
long prevStageId = stage.getStageId() - 1;
- if (prevStageId > 0) {
+ if (prevStageId >= 0) {
// Find previous stage instance
String actionId = StageUtils.getActionId(stage.getRequestId(), prevStageId);
Stage prevStage = db.getStage(actionId);
@@ -565,7 +565,7 @@ class ActionScheduler implements Runnable {
}
int hostCount = hostCountsForRoles.get(c.getRole());
hostCountsForRoles.put(c.getRole(), hostCount + 1);
- if (c.getStatus().isFailedState()) {
+ if (c.getStatus().isFailedAndNotSkippableState()) {
int failedHostCount = failedHostCountsForRoles.get(c.getRole());
failedHostCountsForRoles.put(c.getRole(), failedHostCount + 1);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java
index f5ba1c6..3656bfe 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java
@@ -94,6 +94,12 @@ public enum HostRoleStatus {
SKIPPED_FAILED);
/**
+ * The {@link HostRoleStatus}s that represent any commands which are
+ * considered to be "Failed" and next commands can not be executed.
+ */
+ public static EnumSet<HostRoleStatus> NOT_SKIPPABLE_FAILED_STATUSES = EnumSet.of(FAILED, TIMEDOUT, ABORTED);
+
+ /**
* The {@link HostRoleStatus}s that represent the current commands that failed during stack upgrade.
* This is not used to indicate commands that failed and then skipped.
*/
@@ -124,6 +130,15 @@ public enum HostRoleStatus {
}
/**
+ * Indicates whether or not it is a valid failure state without ability to be skipped.
+ *
+ * @return true if this is a valid failure state.
+ */
+ public boolean isFailedAndNotSkippableState() {
+ return NOT_SKIPPABLE_FAILED_STATUSES.contains(this);
+ }
+
+ /**
* Indicates whether or not this is a completed state.
* Completed means that the associated task has stopped
* running because it has finished successfully or has
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
index 0f1082f..9f0f421 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
@@ -95,6 +95,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml
index ea9a274..2315fc1 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml
@@ -126,6 +126,7 @@
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml
index 03b1e05..2f10ddc 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml
@@ -131,6 +131,7 @@
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
index 44ceee3..4f5778b 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
@@ -113,6 +113,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
index 54aec3f..ea365e1 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
@@ -110,6 +110,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
index 48eebd3..4c7591d 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
@@ -117,6 +117,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
index 821a5b4..78d22ab 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
@@ -111,6 +111,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
index dc81564..383dd9c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
@@ -112,6 +112,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
index 699982c..1faf6f9 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
@@ -111,6 +111,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/7d317cc2/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
index 5bb9669..df3cc8d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
@@ -17,6 +17,10 @@
*/
package org.apache.ambari.server.actionmanager;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -30,6 +34,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
@@ -2604,6 +2609,101 @@ public class TestActionScheduler {
}
+ @Test
+ public void testSkippableCommandFailureDoesNotAbortNextStage() throws Exception {
+ Stage previousStage = createMock(Stage.class);
+ Stage nextStage = createMock(Stage.class);
+ ActionDBAccessor actionDBAccessor = createMock(ActionDBAccessor.class);
+
+ expect(previousStage.isSkippable()).andReturn(false);
+
+ expect(nextStage.getStageId()).andReturn(5L);
+ expect(nextStage.getRequestId()).andReturn(1L);
+ expect(actionDBAccessor.getStage("1-4")).andReturn(previousStage);
+
+ Map<String, HostRoleCommand> roleCommandMap = new HashMap<>();
+ HostRoleCommand hostRoleCommand = createMock(HostRoleCommand.class);
+ expect(hostRoleCommand.getRole()).andReturn(Role.DATANODE).anyTimes();
+ expect(hostRoleCommand.getStatus()).andReturn(HostRoleStatus.SKIPPED_FAILED);
+
+ roleCommandMap.put(Role.DATANODE.toString(), hostRoleCommand);
+
+ Map<String, Map<String, HostRoleCommand>> hostRoleCommands = new HashMap<>();
+ hostRoleCommands.put("host", roleCommandMap);
+
+ expect(previousStage.getHostRoleCommands()).andReturn(hostRoleCommands).anyTimes();
+ expect(previousStage.getSuccessFactor(Role.DATANODE)).andReturn(0.5F);
+
+ ActionScheduler scheduler = new ActionScheduler(100, 50, actionDBAccessor, null, null, 3,
+ new HostsMap((String) null), null, null, null);
+
+ replay(previousStage, nextStage, actionDBAccessor, hostRoleCommand);
+
+ Method method = scheduler.getClass().getDeclaredMethod("hasPreviousStageFailed", Stage.class);
+ method.setAccessible(true);
+ Object result = method.invoke(scheduler, nextStage);
+
+ assertFalse((Boolean) result);
+ EasyMock.verify(previousStage, nextStage, actionDBAccessor, hostRoleCommand);
+ }
+
+ @Test
+ public void testPreviousStageToFailForFirstStage() throws Exception {
+ Stage nextStage = createNiceMock(Stage.class);
+
+ expect(nextStage.getStageId()).andReturn(0L);
+
+ ActionScheduler scheduler = new ActionScheduler(100, 50, null, null, null, 3,
+ new HostsMap((String) null), null, null, null);
+
+ replay(nextStage);
+
+ Method method = scheduler.getClass().getDeclaredMethod("hasPreviousStageFailed", Stage.class);
+ method.setAccessible(true);
+ Object result = method.invoke(scheduler, nextStage);
+
+ assertFalse((Boolean) result);
+ EasyMock.verify(nextStage);
+ }
+
+ @Test
+ public void testPreviousStageToFailForSecondStage() throws Exception {
+ Stage previousStage = createMock(Stage.class);
+ Stage nextStage = createMock(Stage.class);
+ ActionDBAccessor actionDBAccessor = createMock(ActionDBAccessor.class);
+
+ expect(previousStage.isSkippable()).andReturn(false);
+
+ expect(nextStage.getStageId()).andReturn(1L);
+ expect(nextStage.getRequestId()).andReturn(1L);
+ expect(actionDBAccessor.getStage("1-0")).andReturn(previousStage);
+
+ Map<String, HostRoleCommand> roleCommandMap = new HashMap<>();
+ HostRoleCommand hostRoleCommand = createMock(HostRoleCommand.class);
+ expect(hostRoleCommand.getRole()).andReturn(Role.DATANODE).anyTimes();
+ expect(hostRoleCommand.getStatus()).andReturn(HostRoleStatus.FAILED);
+
+ roleCommandMap.put(Role.DATANODE.toString(), hostRoleCommand);
+
+ Map<String, Map<String, HostRoleCommand>> hostRoleCommands = new HashMap<>();
+ hostRoleCommands.put("host", roleCommandMap);
+
+ expect(previousStage.getHostRoleCommands()).andReturn(hostRoleCommands).anyTimes();
+ expect(previousStage.getSuccessFactor(Role.DATANODE)).andReturn(0.5F);
+
+ ActionScheduler scheduler = new ActionScheduler(100, 50, actionDBAccessor, null, null, 3,
+ new HostsMap((String) null), null, null, null);
+
+ replay(previousStage, nextStage, actionDBAccessor, hostRoleCommand);
+
+ Method method = scheduler.getClass().getDeclaredMethod("hasPreviousStageFailed", Stage.class);
+ method.setAccessible(true);
+ Object result = method.invoke(scheduler, nextStage);
+
+ assertTrue((Boolean) result);
+ EasyMock.verify(previousStage, nextStage, actionDBAccessor, hostRoleCommand);
+ }
+
public static class MockModule extends AbstractModule {
@Override
protected void configure() {
[2/2] ambari git commit: AMBARI-17377. Rolling Upgrade process is
blocked after ambari-server/ambari-agent restart. (mpapirkovskyy)
Posted by mp...@apache.org.
AMBARI-17377. Rolling Upgrade process is blocked after ambari-server/ambari-agent restart. (mpapirkovskyy)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1e0813ac
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1e0813ac
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1e0813ac
Branch: refs/heads/branch-2.4
Commit: 1e0813ac1f09c5650a4b0cf6e4d5f28edb19aedf
Parents: 4b0e3b6
Author: Myroslav Papirkovskyi <mp...@hortonworks.com>
Authored: Wed Jun 22 19:47:30 2016 +0300
Committer: Myroslav Papirkovskyi <mp...@hortonworks.com>
Committed: Thu Jun 23 18:00:52 2016 +0300
----------------------------------------------------------------------
.../actionmanager/ActionDBAccessorImpl.java | 2 +-
.../server/actionmanager/ActionScheduler.java | 4 +-
.../server/actionmanager/HostRoleStatus.java | 15 +++
.../stacks/HDP/2.2/upgrades/upgrade-2.2.xml | 1 +
.../stacks/HDP/2.2/upgrades/upgrade-2.3.xml | 1 +
.../stacks/HDP/2.2/upgrades/upgrade-2.4.xml | 1 +
.../stacks/HDP/2.3/upgrades/upgrade-2.3.xml | 1 +
.../stacks/HDP/2.3/upgrades/upgrade-2.4.xml | 1 +
.../stacks/HDP/2.3/upgrades/upgrade-2.5.xml | 1 +
.../stacks/HDP/2.4/upgrades/upgrade-2.4.xml | 1 +
.../stacks/HDP/2.4/upgrades/upgrade-2.5.xml | 1 +
.../stacks/HDP/2.5/upgrades/upgrade-2.5.xml | 1 +
.../actionmanager/TestActionScheduler.java | 100 +++++++++++++++++++
13 files changed, 127 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
index 0fa5aa9..b44dc78 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
@@ -168,7 +168,7 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
@Override
public Stage getStage(String actionId) {
StageEntity stageEntity = stageDAO.findByActionId(actionId);
- return stageFactory.createExisting(stageEntity);
+ return stageEntity == null ? null : stageFactory.createExisting(stageEntity);
}
/* (non-Javadoc)
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
index 622ee88..bb83dfb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
@@ -542,7 +542,7 @@ class ActionScheduler implements Runnable {
long prevStageId = stage.getStageId() - 1;
- if (prevStageId > 0) {
+ if (prevStageId >= 0) {
// Find previous stage instance
String actionId = StageUtils.getActionId(stage.getRequestId(), prevStageId);
Stage prevStage = db.getStage(actionId);
@@ -565,7 +565,7 @@ class ActionScheduler implements Runnable {
}
int hostCount = hostCountsForRoles.get(c.getRole());
hostCountsForRoles.put(c.getRole(), hostCount + 1);
- if (c.getStatus().isFailedState()) {
+ if (c.getStatus().isFailedAndNotSkippableState()) {
int failedHostCount = failedHostCountsForRoles.get(c.getRole());
failedHostCountsForRoles.put(c.getRole(), failedHostCount + 1);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java
index f5ba1c6..3656bfe 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleStatus.java
@@ -94,6 +94,12 @@ public enum HostRoleStatus {
SKIPPED_FAILED);
/**
+ * The {@link HostRoleStatus}s that represent any commands which are
+ * considered to be "Failed" and next commands can not be executed.
+ */
+ public static EnumSet<HostRoleStatus> NOT_SKIPPABLE_FAILED_STATUSES = EnumSet.of(FAILED, TIMEDOUT, ABORTED);
+
+ /**
* The {@link HostRoleStatus}s that represent the current commands that failed during stack upgrade.
* This is not used to indicate commands that failed and then skipped.
*/
@@ -124,6 +130,15 @@ public enum HostRoleStatus {
}
/**
+ * Indicates whether or not it is a valid failure state without ability to be skipped.
+ *
+ * @return true if this is a valid failure state.
+ */
+ public boolean isFailedAndNotSkippableState() {
+ return NOT_SKIPPABLE_FAILED_STATUSES.contains(this);
+ }
+
+ /**
* Indicates whether or not this is a completed state.
* Completed means that the associated task has stopped
* running because it has finished successfully or has
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
index 0f1082f..9f0f421 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.2.xml
@@ -95,6 +95,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml
index ea9a274..2315fc1 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.3.xml
@@ -126,6 +126,7 @@
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml
index 03b1e05..2f10ddc 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/upgrade-2.4.xml
@@ -131,6 +131,7 @@
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
index 44ceee3..4f5778b 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.3.xml
@@ -113,6 +113,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
index 54aec3f..ea365e1 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
@@ -110,6 +110,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
index 48eebd3..4c7591d 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
@@ -117,6 +117,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
index 821a5b4..78d22ab 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.4.xml
@@ -111,6 +111,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
index dc81564..383dd9c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
@@ -112,6 +112,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
index 699982c..1faf6f9 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.5.xml
@@ -111,6 +111,7 @@
</group>
<group name="ZOOKEEPER" title="ZooKeeper">
+ <supports-auto-skip-failure>false</supports-auto-skip-failure>
<service name="ZOOKEEPER">
<component>ZOOKEEPER_SERVER</component>
</service>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1e0813ac/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
index 5bb9669..df3cc8d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
@@ -17,6 +17,10 @@
*/
package org.apache.ambari.server.actionmanager;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -30,6 +34,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
@@ -2604,6 +2609,101 @@ public class TestActionScheduler {
}
+ @Test
+ public void testSkippableCommandFailureDoesNotAbortNextStage() throws Exception {
+ Stage previousStage = createMock(Stage.class);
+ Stage nextStage = createMock(Stage.class);
+ ActionDBAccessor actionDBAccessor = createMock(ActionDBAccessor.class);
+
+ expect(previousStage.isSkippable()).andReturn(false);
+
+ expect(nextStage.getStageId()).andReturn(5L);
+ expect(nextStage.getRequestId()).andReturn(1L);
+ expect(actionDBAccessor.getStage("1-4")).andReturn(previousStage);
+
+ Map<String, HostRoleCommand> roleCommandMap = new HashMap<>();
+ HostRoleCommand hostRoleCommand = createMock(HostRoleCommand.class);
+ expect(hostRoleCommand.getRole()).andReturn(Role.DATANODE).anyTimes();
+ expect(hostRoleCommand.getStatus()).andReturn(HostRoleStatus.SKIPPED_FAILED);
+
+ roleCommandMap.put(Role.DATANODE.toString(), hostRoleCommand);
+
+ Map<String, Map<String, HostRoleCommand>> hostRoleCommands = new HashMap<>();
+ hostRoleCommands.put("host", roleCommandMap);
+
+ expect(previousStage.getHostRoleCommands()).andReturn(hostRoleCommands).anyTimes();
+ expect(previousStage.getSuccessFactor(Role.DATANODE)).andReturn(0.5F);
+
+ ActionScheduler scheduler = new ActionScheduler(100, 50, actionDBAccessor, null, null, 3,
+ new HostsMap((String) null), null, null, null);
+
+ replay(previousStage, nextStage, actionDBAccessor, hostRoleCommand);
+
+ Method method = scheduler.getClass().getDeclaredMethod("hasPreviousStageFailed", Stage.class);
+ method.setAccessible(true);
+ Object result = method.invoke(scheduler, nextStage);
+
+ assertFalse((Boolean) result);
+ EasyMock.verify(previousStage, nextStage, actionDBAccessor, hostRoleCommand);
+ }
+
+ @Test
+ public void testPreviousStageToFailForFirstStage() throws Exception {
+ Stage nextStage = createNiceMock(Stage.class);
+
+ expect(nextStage.getStageId()).andReturn(0L);
+
+ ActionScheduler scheduler = new ActionScheduler(100, 50, null, null, null, 3,
+ new HostsMap((String) null), null, null, null);
+
+ replay(nextStage);
+
+ Method method = scheduler.getClass().getDeclaredMethod("hasPreviousStageFailed", Stage.class);
+ method.setAccessible(true);
+ Object result = method.invoke(scheduler, nextStage);
+
+ assertFalse((Boolean) result);
+ EasyMock.verify(nextStage);
+ }
+
+ @Test
+ public void testPreviousStageToFailForSecondStage() throws Exception {
+ Stage previousStage = createMock(Stage.class);
+ Stage nextStage = createMock(Stage.class);
+ ActionDBAccessor actionDBAccessor = createMock(ActionDBAccessor.class);
+
+ expect(previousStage.isSkippable()).andReturn(false);
+
+ expect(nextStage.getStageId()).andReturn(1L);
+ expect(nextStage.getRequestId()).andReturn(1L);
+ expect(actionDBAccessor.getStage("1-0")).andReturn(previousStage);
+
+ Map<String, HostRoleCommand> roleCommandMap = new HashMap<>();
+ HostRoleCommand hostRoleCommand = createMock(HostRoleCommand.class);
+ expect(hostRoleCommand.getRole()).andReturn(Role.DATANODE).anyTimes();
+ expect(hostRoleCommand.getStatus()).andReturn(HostRoleStatus.FAILED);
+
+ roleCommandMap.put(Role.DATANODE.toString(), hostRoleCommand);
+
+ Map<String, Map<String, HostRoleCommand>> hostRoleCommands = new HashMap<>();
+ hostRoleCommands.put("host", roleCommandMap);
+
+ expect(previousStage.getHostRoleCommands()).andReturn(hostRoleCommands).anyTimes();
+ expect(previousStage.getSuccessFactor(Role.DATANODE)).andReturn(0.5F);
+
+ ActionScheduler scheduler = new ActionScheduler(100, 50, actionDBAccessor, null, null, 3,
+ new HostsMap((String) null), null, null, null);
+
+ replay(previousStage, nextStage, actionDBAccessor, hostRoleCommand);
+
+ Method method = scheduler.getClass().getDeclaredMethod("hasPreviousStageFailed", Stage.class);
+ method.setAccessible(true);
+ Object result = method.invoke(scheduler, nextStage);
+
+ assertTrue((Boolean) result);
+ EasyMock.verify(previousStage, nextStage, actionDBAccessor, hostRoleCommand);
+ }
+
public static class MockModule extends AbstractModule {
@Override
protected void configure() {