You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2016/04/04 21:18:32 UTC

ambari git commit: AMBARI-15673. Stack Upgrade should allow suspended=false when aborting an upgrade to initiate a downgrade (alejandro)

Repository: ambari
Updated Branches:
  refs/heads/trunk 43c67bc46 -> fa6550c4e


AMBARI-15673. Stack Upgrade should allow suspended=false when aborting an upgrade to initiate a downgrade (alejandro)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fa6550c4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fa6550c4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fa6550c4

Branch: refs/heads/trunk
Commit: fa6550c4ef38f9c15e7a341c02bdac046e0e28d4
Parents: 43c67bc
Author: Alejandro Fernandez <af...@hortonworks.com>
Authored: Mon Apr 4 12:00:33 2016 -0700
Committer: Alejandro Fernandez <af...@hortonworks.com>
Committed: Mon Apr 4 12:18:29 2016 -0700

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       | 22 +++++---------------
 1 file changed, 5 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fa6550c4/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
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 b3bf345..0384f6c 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
@@ -468,32 +468,20 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     if (null != requestStatus) {
       HostRoleStatus status = HostRoleStatus.valueOf(requestStatus);
 
-      // when aborting an upgrade, the suspend flag must be present to indicate
-      // if the upgrade is merely being suspended
+      // When aborting an upgrade, the suspend flag must be present to indicate
+      // if the upgrade is merely being paused (suspended=true) or aborted to initiate a downgrade (suspended=false).
       boolean suspended = false;
-      if( status == HostRoleStatus.ABORTED && !propertyMap.containsKey(UPGRADE_SUSPENDED)){
+      if (status == HostRoleStatus.ABORTED && !propertyMap.containsKey(UPGRADE_SUSPENDED)){
         throw new IllegalArgumentException(String.format(
             "When changing the state of an upgrade to %s, the %s property is required to be either true or false.",
             status, UPGRADE_SUSPENDED ));
-      } else {
+      } else if (status == HostRoleStatus.ABORTED) {
         suspended = Boolean.valueOf((String) propertyMap.get(UPGRADE_SUSPENDED));
-        // If either the status is ABORTED or request to be suspended, then both should be set.
-        if ((status == HostRoleStatus.ABORTED || suspended)) {
-          if (status == HostRoleStatus.ABORTED && !suspended) {
-            throw new IllegalArgumentException(String.format(
-                "If the status is set to ABORTED, must also set property %s to true", UPGRADE_SUSPENDED));
-          }
-          if (status != HostRoleStatus.ABORTED && suspended) {
-            throw new IllegalArgumentException(String.format(
-                "If property %s is set to true, must also set the status to ABORTED", UPGRADE_SUSPENDED));
-          }
-        }
       }
 
       setUpgradeRequestStatus(requestIdProperty, status, propertyMap);
 
-      // when the status of the upgrade's request is changing, we also update
-      // the suspended flag
+      // When the status of the upgrade's request is changing, we also update the suspended flag.
       upgradeEntity.setSuspended(suspended);
       s_upgradeDAO.merge(upgradeEntity);
     }