ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lpus...@apache.org
Subject [29/57] [abbrv] ambari git commit: AMBARI-21911 "Retry" upgrade doesn't work if a server action times out (dgrinenko)
Date Tue, 12 Sep 2017 10:04:46 GMT
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/feature-branch-AMBARI-21307
Commit: 2170ce0321b8ea2c772c5dcdce38c4d94bea8175
Parents: 2ab8b39
Author: Dmytro Grinenko <hapylestat@apache.org>
Authored: Fri Sep 8 15:29:45 2017 +0300
Committer: Dmytro Grinenko <hapylestat@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,


Mime
View raw message