This is an automated email from the ASF dual-hosted git repository.
jonathanhurley pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 58fdcab [AMBARI-24090] - Resuming a Paused Upgrade Attempts To Retry
Tasks Which Were Already Passed (#1526)
58fdcab is described below
commit 58fdcab8d348b7fa6ad7624bafc9da89429350ce
Author: Jonathan Hurley <[email protected]>
AuthorDate: Wed Jun 13 12:15:28 2018 -0400
[AMBARI-24090] - Resuming a Paused Upgrade Attempts To Retry Tasks Which
Were Already Passed (#1526)
---
.../internal/UpgradeResourceProvider.java | 6 ++-
.../internal/UpgradeResourceProviderTest.java | 55 +++++++++++++++++++---
2 files changed, 54 insertions(+), 7 deletions(-)
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index 6cf87d3..ea7d906 100644
---
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -1555,8 +1555,12 @@ public class UpgradeResourceProvider extends
AbstractControllerResourceProvider
} else if (status == HostRoleStatus.PENDING) {
List<Long> taskIds = new ArrayList<>();
+
+ // pull back only ABORTED tasks in order to set them to PENDING - other
+ // status (such as TIMEDOUT and FAILED) must remain since they are
+ // considered to have been completed
List<HostRoleCommandEntity> hrcEntities =
s_hostRoleCommandDAO.findByRequestIdAndStatuses(
- requestId, Sets.newHashSet(HostRoleStatus.ABORTED,
HostRoleStatus.TIMEDOUT));
+ requestId, Sets.newHashSet(HostRoleStatus.ABORTED));
for (HostRoleCommandEntity hrcEntity : hrcEntities) {
taskIds.add(hrcEntity.getTaskId());
diff --git
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
index f577264..6059a32 100644
---
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
+++
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
@@ -898,7 +898,7 @@ public class UpgradeResourceProviderTest extends
EasyMockSupport {
@Test
- public void testAbort() throws Exception {
+ public void testAbortUpgrade() throws Exception {
RequestStatus status = testCreateResources();
Set<Resource> createdResources = status.getAssociatedResources();
@@ -954,7 +954,7 @@ public class UpgradeResourceProviderTest extends
EasyMockSupport {
@Test
- public void testRetry() throws Exception {
+ public void testResumeUpgrade() throws Exception {
RequestStatus status = testCreateResources();
Set<Resource> createdResources = status.getAssociatedResources();
@@ -988,15 +988,46 @@ public class UpgradeResourceProviderTest extends
EasyMockSupport {
foundOne = true;
}
}
+
assertTrue("Expected at least one server-side action", foundOne);
- HostRoleCommand cmd = commands.get(commands.size()-1);
+ // make sure we have enough commands to properly test this
+ assertTrue(commands.size() > 5);
+ // now, set some status of the commands to reflect an actual aborted
upgrade
+ // (some completed, some faiures, some timeouts)
HostRoleCommandDAO dao = injector.getInstance(HostRoleCommandDAO.class);
- HostRoleCommandEntity entity = dao.findByPK(cmd.getTaskId());
- entity.setStatus(HostRoleStatus.ABORTED);
- dao.merge(entity);
+ for (int i = 0; i < commands.size(); i++) {
+ HostRoleCommand command = commands.get(i);
+ HostRoleCommandEntity entity = dao.findByPK(command.getTaskId());
+
+ // make sure to interweave failures/timeouts with completed
+ final HostRoleStatus newStatus;
+ switch (i) {
+ case 0:
+ case 1:
+ newStatus = HostRoleStatus.COMPLETED;
+ break;
+ case 2:
+ newStatus = HostRoleStatus.TIMEDOUT;
+ break;
+ case 3:
+ newStatus = HostRoleStatus.COMPLETED;
+ break;
+ case 4:
+ newStatus = HostRoleStatus.FAILED;
+ break;
+ default:
+ newStatus = HostRoleStatus.ABORTED;
+ break;
+ }
+
+ entity.setStatus(newStatus);
+ dao.merge(entity);
+ }
+
+ // resume the upgrade
requestProps = new HashMap<>();
requestProps.put(UpgradeResourceProvider.UPGRADE_REQUEST_ID,
id.toString());
requestProps.put(UpgradeResourceProvider.UPGRADE_REQUEST_STATUS,
"PENDING");
@@ -1006,6 +1037,18 @@ public class UpgradeResourceProviderTest extends
EasyMockSupport {
// !!! make sure we can. actual reset is tested elsewhere
req = PropertyHelper.getUpdateRequest(requestProps, null);
urp.updateResources(req, null);
+
+ // test that prior completions (both timedout and failure) did not go back
+ // to PENDING
+ commands = am.getRequestTasks(id);
+ for (int i = 0; i < commands.size(); i++) {
+ HostRoleCommand command = commands.get(i);
+ if (i < 5) {
+ assertTrue(command.getStatus() != HostRoleStatus.PENDING);
+ } else {
+ assertTrue(command.getStatus() == HostRoleStatus.PENDING);
+ }
+ }
}
@Test(expected = IllegalArgumentException.class)
--
To stop receiving notification emails like this one, please contact
[email protected].