Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4206D200CFE for ; Fri, 8 Sep 2017 14:32:02 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4089E1609C5; Fri, 8 Sep 2017 12:32:02 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C9CA21609BF for ; Fri, 8 Sep 2017 14:32:00 +0200 (CEST) Received: (qmail 31224 invoked by uid 500); 8 Sep 2017 12:31:59 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 31209 invoked by uid 99); 8 Sep 2017 12:31:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Sep 2017 12:31:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B64C2F5533; Fri, 8 Sep 2017 12:31:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hapylestat@apache.org To: commits@ambari.apache.org Date: Fri, 08 Sep 2017 12:31:59 -0000 Message-Id: <8e8c0105c6e04e5ba4a8122b475a9254@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] ambari git commit: AMBARI-21911 "Retry" upgrade doesn't work if a server action times out (dgrinenko) archived-at: Fri, 08 Sep 2017 12:32:02 -0000 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 Authored: Fri Sep 8 15:29:45 2017 +0300 Committer: Dmytro Grinenko 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 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 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 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 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 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 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 expected = null; @@ -617,7 +640,7 @@ public class TestActionDBAccessorImpl { @Test public void testEntitiesCreatedWithIDs() throws Exception { List 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 stages = new ArrayList<>(); stages.add(s); Request request = new Request(stages, "", clusters); @@ -721,7 +744,7 @@ public class TestActionDBAccessorImpl { List 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 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 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,