You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ha...@apache.org on 2017/09/08 12:31:59 UTC
[1/2] ambari git commit: AMBARI-21911 "Retry" upgrade doesn't work if
a server action times out (dgrinenko)
Repository: ambari
Updated Branches:
refs/heads/branch-2.6 f8d30d85f -> d4791c384
refs/heads/trunk 2ab8b39c1 -> 2170ce032
AMBARI-21911 "Retry" upgrade doesn't work if a server action times out (dgrinenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2170ce03
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2170ce03
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2170ce03
Branch: refs/heads/trunk
Commit: 2170ce0321b8ea2c772c5dcdce38c4d94bea8175
Parents: 2ab8b39
Author: Dmytro Grinenko <ha...@apache.org>
Authored: Fri Sep 8 15:29:45 2017 +0300
Committer: Dmytro Grinenko <ha...@apache.org>
Committed: Fri Sep 8 15:29:45 2017 +0300
----------------------------------------------------------------------
.../actionmanager/ActionDBAccessorImpl.java | 11 ++++
.../actionmanager/TestActionDBAccessorImpl.java | 63 +++++++++++++-------
2 files changed, 54 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2170ce03/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 f0e2ce7..063ea1c 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
@@ -538,6 +538,12 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
reportedTaskStatus = HostRoleStatus.SKIPPED_FAILED;
}
}
+
+ // if TIMEOUT and marked for holding then set status = HOLDING_TIMEOUT
+ if (reportedTaskStatus == HostRoleStatus.TIMEDOUT && commandEntity.isRetryAllowed()){
+ reportedTaskStatus = HostRoleStatus.HOLDING_TIMEDOUT;
+ }
+
if (!existingTaskStatus.isCompletedState()) {
commandEntity.setStatus(reportedTaskStatus);
}
@@ -601,6 +607,11 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
}
}
+ // if TIMEOUT and marked for holding then set status = HOLDING_TIMEOUT
+ if (status == HostRoleStatus.TIMEDOUT && command.isRetryAllowed()){
+ status = HostRoleStatus.HOLDING_TIMEDOUT;
+ }
+
command.setStatus(status);
command.setStdOut(report.getStdOut().getBytes());
command.setStdError(report.getStdErr().getBytes());
http://git-wip-us.apache.org/repos/asf/ambari/blob/2170ce03/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
index c449aae..94799cc 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
@@ -132,7 +132,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testActionResponse() throws AmbariException {
String hostname = "host1";
- populateActionDB(db, hostname, requestId, stageId);
+ populateActionDB(db, hostname, requestId, stageId, false);
Stage stage = db.getAllStages(requestId).get(0);
Assert.assertEquals(stageId, stage.getStageId());
stage.setHostRoleStatus(hostname, "HBASE_MASTER", HostRoleStatus.QUEUED);
@@ -160,7 +160,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testCancelCommandReport() throws AmbariException {
String hostname = "host1";
- populateActionDB(db, hostname, requestId, stageId);
+ populateActionDB(db, hostname, requestId, stageId, false);
Stage stage = db.getAllStages(requestId).get(0);
Assert.assertEquals(stageId, stage.getStageId());
stage.setHostRoleStatus(hostname, "HBASE_MASTER", HostRoleStatus.ABORTED);
@@ -191,8 +191,8 @@ public class TestActionDBAccessorImpl {
@Test
public void testGetStagesInProgress() throws AmbariException {
List<Stage> stages = new ArrayList<>();
- stages.add(createStubStage(hostName, requestId, stageId));
- stages.add(createStubStage(hostName, requestId, stageId + 1));
+ stages.add(createStubStage(hostName, requestId, stageId, false));
+ stages.add(createStubStage(hostName, requestId, stageId + 1, false));
Request request = new Request(stages, "", clusters);
db.persistActions(request);
assertEquals(2, stages.size());
@@ -200,8 +200,8 @@ public class TestActionDBAccessorImpl {
@Test
public void testGetStagesInProgressWithFailures() throws AmbariException {
- populateActionDB(db, hostName, requestId, stageId);
- populateActionDB(db, hostName, requestId + 1, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
+ populateActionDB(db, hostName, requestId + 1, stageId, false);
List<Stage> stages = db.getFirstStageInProgressPerRequest();
assertEquals(2, stages.size());
@@ -289,7 +289,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testPersistActions() throws AmbariException {
- populateActionDB(db, hostName, requestId, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
for (Stage stage : db.getAllStages(requestId)) {
log.info("taskId={}" + stage.getExecutionCommands(hostName).get(0).
getExecutionCommand().getTaskId());
@@ -302,7 +302,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testHostRoleScheduled() throws InterruptedException, AmbariException {
- populateActionDB(db, hostName, requestId, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
Stage stage = db.getStage(StageUtils.getActionId(requestId, stageId));
assertEquals(HostRoleStatus.PENDING, stage.getHostRoleStatus(hostName, Role.HBASE_MASTER.toString()));
List<HostRoleCommandEntity> entities=
@@ -421,7 +421,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testUpdateHostRole() throws Exception {
- populateActionDB(db, hostName, requestId, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 50000; i++) {
sb.append("1234567890");
@@ -452,13 +452,36 @@ public class TestActionDBAccessorImpl {
}
@Test
+ public void testUpdateHostRoleTimeoutRetry() throws Exception {
+ populateActionDB(db, hostName, requestId, stageId, true);
+
+ CommandReport commandReport = new CommandReport();
+ commandReport.setStatus(HostRoleStatus.TIMEDOUT.toString());
+ commandReport.setStdOut("");
+ commandReport.setStdErr("");
+ commandReport.setStructuredOut("");
+ commandReport.setExitCode(123);
+ db.updateHostRoleState(hostName, requestId, stageId, Role.HBASE_MASTER.toString(), commandReport);
+
+ List<HostRoleCommandEntity> commandEntities =
+ hostRoleCommandDAO.findByHostRole(hostName, requestId, stageId, Role.HBASE_MASTER.toString());
+
+ HostRoleCommandEntity commandEntity = commandEntities.get(0);
+ HostRoleCommand command = db.getTask(commandEntity.getTaskId());
+ assertNotNull(command);
+ assertEquals(HostRoleStatus.HOLDING_TIMEDOUT, command.getStatus());
+
+ }
+
+
+ @Test
public void testGetRequestsByStatus() throws AmbariException {
List<Long> requestIds = new ArrayList<>();
requestIds.add(requestId + 1);
requestIds.add(requestId);
- populateActionDB(db, hostName, requestId, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
clusters.addHost("host2");
- populateActionDB(db, hostName, requestId + 1, stageId);
+ populateActionDB(db, hostName, requestId + 1, stageId, false);
List<Long> requestIdsResult =
db.getRequestsByStatus(null, BaseRequest.DEFAULT_PAGE_SIZE, false);
@@ -508,7 +531,7 @@ public class TestActionDBAccessorImpl {
}
for (Long id : ids) {
- populateActionDB(db, hostName, id, stageId);
+ populateActionDB(db, hostName, id, stageId, false);
}
List<Long> expected = null;
@@ -617,7 +640,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testEntitiesCreatedWithIDs() throws Exception {
List<Stage> stages = new ArrayList<>();
- Stage stage = createStubStage(hostName, requestId, stageId);
+ Stage stage = createStubStage(hostName, requestId, stageId, false);
stages.add(stage);
@@ -707,8 +730,8 @@ public class TestActionDBAccessorImpl {
}
private void populateActionDB(ActionDBAccessor db, String hostname,
- long requestId, long stageId) throws AmbariException {
- Stage s = createStubStage(hostname, requestId, stageId);
+ long requestId, long stageId, boolean retryAllowed) throws AmbariException {
+ Stage s = createStubStage(hostname, requestId, stageId, retryAllowed);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "", clusters);
@@ -721,7 +744,7 @@ public class TestActionDBAccessorImpl {
List<Stage> stages = new ArrayList<>();
for (int i = 0; i < numberOfStages; i++) {
- Stage stage = createStubStage(hostname, requestId, stageId + i);
+ Stage stage = createStubStage(hostname, requestId, stageId + i, false);
stages.add(stage);
}
@@ -732,7 +755,7 @@ public class TestActionDBAccessorImpl {
private void populateActionDBWithCompletedRequest(ActionDBAccessor db, String hostname,
long requestId, long stageId) throws AmbariException {
- Stage s = createStubStage(hostname, requestId, stageId);
+ Stage s = createStubStage(hostname, requestId, stageId, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "", clusters);
@@ -745,7 +768,7 @@ public class TestActionDBAccessorImpl {
private void populateActionDBWithPartiallyCompletedRequest(ActionDBAccessor db, String hostname,
long requestId, long stageId) throws AmbariException {
- Stage s = createStubStage(hostname, requestId, stageId);
+ Stage s = createStubStage(hostname, requestId, stageId, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
@@ -756,14 +779,14 @@ public class TestActionDBAccessorImpl {
db.persistActions(request);
}
- private Stage createStubStage(String hostname, long requestId, long stageId) {
+ private Stage createStubStage(String hostname, long requestId, long stageId, boolean retryAllowed) {
Stage s = stageFactory.createNew(requestId, "/a/b", "cluster1", 1L, "action db accessor test",
"commandParamsStage", "hostParamsStage");
s.setStageId(stageId);
s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
- hostname, System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ hostname, System.currentTimeMillis()), "cluster1", "HBASE", retryAllowed, false);
s.addHostRoleExecutionCommand(
hostname,
Role.HBASE_REGIONSERVER,
[2/2] ambari git commit: AMBARI-21911 "Retry" upgrade doesn't work if
a server action times out (dgrinenko)
Posted by ha...@apache.org.
AMBARI-21911 "Retry" upgrade doesn't work if a server action times out (dgrinenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d4791c38
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d4791c38
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d4791c38
Branch: refs/heads/branch-2.6
Commit: d4791c3848d8bbec9d0cabfabf8a1b5c5475cc8e
Parents: f8d30d8
Author: Dmytro Grinenko <ha...@apache.org>
Authored: Fri Sep 8 15:30:55 2017 +0300
Committer: Dmytro Grinenko <ha...@apache.org>
Committed: Fri Sep 8 15:30:55 2017 +0300
----------------------------------------------------------------------
.../actionmanager/ActionDBAccessorImpl.java | 10 ++++
.../actionmanager/TestActionDBAccessorImpl.java | 63 +++++++++++++-------
2 files changed, 53 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/d4791c38/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 84f2475..b378232 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
@@ -531,6 +531,11 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
}
}
+ // if TIMEOUT and marked for holding then set status = HOLDING_TIMEOUT
+ if (status == HostRoleStatus.TIMEDOUT && commandEntity.isRetryAllowed()){
+ status = HostRoleStatus.HOLDING_TIMEDOUT;
+ }
+
commandEntity.setStatus(status);
statusChanged = true;
break;
@@ -598,6 +603,11 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
}
}
+ // if TIMEOUT and marked for holding then set status = HOLDING_TIMEOUT
+ if (status == HostRoleStatus.TIMEDOUT && command.isRetryAllowed()){
+ status = HostRoleStatus.HOLDING_TIMEDOUT;
+ }
+
command.setStatus(status);
command.setStdOut(report.getStdOut().getBytes());
command.setStdError(report.getStdErr().getBytes());
http://git-wip-us.apache.org/repos/asf/ambari/blob/d4791c38/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
index 391a0e6..03db515 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
@@ -138,7 +138,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testActionResponse() throws AmbariException {
String hostname = "host1";
- populateActionDB(db, hostname, requestId, stageId);
+ populateActionDB(db, hostname, requestId, stageId, false);
Stage stage = db.getAllStages(requestId).get(0);
Assert.assertEquals(stageId, stage.getStageId());
stage.setHostRoleStatus(hostname, "HBASE_MASTER", HostRoleStatus.QUEUED);
@@ -166,7 +166,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testCancelCommandReport() throws AmbariException {
String hostname = "host1";
- populateActionDB(db, hostname, requestId, stageId);
+ populateActionDB(db, hostname, requestId, stageId, false);
Stage stage = db.getAllStages(requestId).get(0);
Assert.assertEquals(stageId, stage.getStageId());
stage.setHostRoleStatus(hostname, "HBASE_MASTER", HostRoleStatus.ABORTED);
@@ -197,8 +197,8 @@ public class TestActionDBAccessorImpl {
@Test
public void testGetStagesInProgress() throws AmbariException {
List<Stage> stages = new ArrayList<>();
- stages.add(createStubStage(hostName, requestId, stageId));
- stages.add(createStubStage(hostName, requestId, stageId + 1));
+ stages.add(createStubStage(hostName, requestId, stageId, false));
+ stages.add(createStubStage(hostName, requestId, stageId + 1, false));
Request request = new Request(stages, "", clusters);
db.persistActions(request);
assertEquals(2, stages.size());
@@ -206,8 +206,8 @@ public class TestActionDBAccessorImpl {
@Test
public void testGetStagesInProgressWithFailures() throws AmbariException {
- populateActionDB(db, hostName, requestId, stageId);
- populateActionDB(db, hostName, requestId + 1, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
+ populateActionDB(db, hostName, requestId + 1, stageId, false);
List<Stage> stages = db.getFirstStageInProgressPerRequest();
assertEquals(2, stages.size());
@@ -295,7 +295,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testPersistActions() throws AmbariException {
- populateActionDB(db, hostName, requestId, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
for (Stage stage : db.getAllStages(requestId)) {
log.info("taskId={}" + stage.getExecutionCommands(hostName).get(0).
getExecutionCommand().getTaskId());
@@ -308,7 +308,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testHostRoleScheduled() throws InterruptedException, AmbariException {
- populateActionDB(db, hostName, requestId, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
Stage stage = db.getStage(StageUtils.getActionId(requestId, stageId));
assertEquals(HostRoleStatus.PENDING, stage.getHostRoleStatus(hostName, Role.HBASE_MASTER.toString()));
List<HostRoleCommandEntity> entities=
@@ -427,7 +427,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testUpdateHostRole() throws Exception {
- populateActionDB(db, hostName, requestId, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 50000; i++) {
sb.append("1234567890");
@@ -458,13 +458,36 @@ public class TestActionDBAccessorImpl {
}
@Test
+ public void testUpdateHostRoleTimeoutRetry() throws Exception {
+ populateActionDB(db, hostName, requestId, stageId, true);
+
+ CommandReport commandReport = new CommandReport();
+ commandReport.setStatus(HostRoleStatus.TIMEDOUT.toString());
+ commandReport.setStdOut("");
+ commandReport.setStdErr("");
+ commandReport.setStructuredOut("");
+ commandReport.setExitCode(123);
+ db.updateHostRoleState(hostName, requestId, stageId, Role.HBASE_MASTER.toString(), commandReport);
+
+ List<HostRoleCommandEntity> commandEntities =
+ hostRoleCommandDAO.findByHostRole(hostName, requestId, stageId, Role.HBASE_MASTER.toString());
+
+ HostRoleCommandEntity commandEntity = commandEntities.get(0);
+ HostRoleCommand command = db.getTask(commandEntity.getTaskId());
+ assertNotNull(command);
+ assertEquals(HostRoleStatus.HOLDING_TIMEDOUT, command.getStatus());
+
+ }
+
+
+ @Test
public void testGetRequestsByStatus() throws AmbariException {
List<Long> requestIds = new ArrayList<>();
requestIds.add(requestId + 1);
requestIds.add(requestId);
- populateActionDB(db, hostName, requestId, stageId);
+ populateActionDB(db, hostName, requestId, stageId, false);
clusters.addHost("host2");
- populateActionDB(db, hostName, requestId + 1, stageId);
+ populateActionDB(db, hostName, requestId + 1, stageId, false);
List<Long> requestIdsResult =
db.getRequestsByStatus(null, BaseRequest.DEFAULT_PAGE_SIZE, false);
@@ -514,7 +537,7 @@ public class TestActionDBAccessorImpl {
}
for (Long id : ids) {
- populateActionDB(db, hostName, id, stageId);
+ populateActionDB(db, hostName, id, stageId, false);
}
List<Long> expected = null;
@@ -629,7 +652,7 @@ public class TestActionDBAccessorImpl {
@Test
public void testEntitiesCreatedWithIDs() throws Exception {
List<Stage> stages = new ArrayList<>();
- Stage stage = createStubStage(hostName, requestId, stageId);
+ Stage stage = createStubStage(hostName, requestId, stageId, false);
stages.add(stage);
@@ -719,8 +742,8 @@ public class TestActionDBAccessorImpl {
}
private void populateActionDB(ActionDBAccessor db, String hostname,
- long requestId, long stageId) throws AmbariException {
- Stage s = createStubStage(hostname, requestId, stageId);
+ long requestId, long stageId, boolean retryAllowed) throws AmbariException {
+ Stage s = createStubStage(hostname, requestId, stageId, retryAllowed);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "", clusters);
@@ -733,7 +756,7 @@ public class TestActionDBAccessorImpl {
List<Stage> stages = new ArrayList<>();
for (int i = 0; i < numberOfStages; i++) {
- Stage stage = createStubStage(hostname, requestId, stageId + i);
+ Stage stage = createStubStage(hostname, requestId, stageId + i, false);
stages.add(stage);
}
@@ -744,7 +767,7 @@ public class TestActionDBAccessorImpl {
private void populateActionDBWithCompletedRequest(ActionDBAccessor db, String hostname,
long requestId, long stageId) throws AmbariException {
- Stage s = createStubStage(hostname, requestId, stageId);
+ Stage s = createStubStage(hostname, requestId, stageId, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
Request request = new Request(stages, "", clusters);
@@ -757,7 +780,7 @@ public class TestActionDBAccessorImpl {
private void populateActionDBWithPartiallyCompletedRequest(ActionDBAccessor db, String hostname,
long requestId, long stageId) throws AmbariException {
- Stage s = createStubStage(hostname, requestId, stageId);
+ Stage s = createStubStage(hostname, requestId, stageId, false);
List<Stage> stages = new ArrayList<>();
stages.add(s);
@@ -768,14 +791,14 @@ public class TestActionDBAccessorImpl {
db.persistActions(request);
}
- private Stage createStubStage(String hostname, long requestId, long stageId) {
+ private Stage createStubStage(String hostname, long requestId, long stageId, boolean retryAllowed) {
Stage s = stageFactory.createNew(requestId, "/a/b", "cluster1", 1L, "action db accessor test",
"commandParamsStage", "hostParamsStage");
s.setStageId(stageId);
s.addHostRoleExecutionCommand(hostname, Role.HBASE_MASTER,
RoleCommand.START,
new ServiceComponentHostStartEvent(Role.HBASE_MASTER.toString(),
- hostname, System.currentTimeMillis()), "cluster1", "HBASE", false, false);
+ hostname, System.currentTimeMillis()), "cluster1", "HBASE", retryAllowed, false);
s.addHostRoleExecutionCommand(
hostname,
Role.HBASE_REGIONSERVER,