You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2015/10/30 06:11:28 UTC

ambari git commit: AMBARI-13635: Express Upgrade: HDP 2.2 -> HDP 2.3 upgrade blocked on Updating configuration ranger-hdfs-policymgr-ssl (jluniya)

Repository: ambari
Updated Branches:
  refs/heads/trunk 028143c40 -> 3ff718e3a


AMBARI-13635: Express Upgrade: HDP 2.2 -> HDP 2.3 upgrade blocked on Updating configuration ranger-hdfs-policymgr-ssl (jluniya)


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

Branch: refs/heads/trunk
Commit: 3ff718e3ae1e4756ce83d72369f8a5c8733bb391
Parents: 028143c
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Thu Oct 29 22:11:21 2015 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Thu Oct 29 22:11:21 2015 -0700

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       | 10 ++--
 .../upgrades/UpdateDesiredStackAction.java      | 49 +++++++++++++++-----
 .../HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml | 16 +++----
 .../HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml | 17 ++++---
 4 files changed, 59 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3ff718e3/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 59eaa10..7978a7a 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
@@ -170,6 +170,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   private static final String COMMAND_PARAM_VERSION = VERSION;
   private static final String COMMAND_PARAM_CLUSTER_NAME = "clusterName";
   private static final String COMMAND_PARAM_DIRECTION = "upgrade_direction";
+  private static final String COMMAND_PARAM_UPGRADE_PACK = "upgrade_pack";
   // TODO AMBARI-12698, change this variable name since it is no longer always a restart. Possible values are rolling_upgrade or nonrolling_upgrade
   // This will involve changing Script.py
   private static final String COMMAND_PARAM_RESTART_TYPE = "restart_type";
@@ -273,7 +274,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
    * @param controller
    *          the controller
    */
-  UpgradeResourceProvider(AmbariManagementController controller) {
+  public UpgradeResourceProvider(AmbariManagementController controller) {
     super(PROPERTY_IDS, KEY_PROPERTY_IDS, controller);
   }
 
@@ -825,7 +826,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
 
               injectVariables(configHelper, cluster, itemEntity);
               makeServerSideStage(ctx, req, itemEntity, (ServerSideActionTask) task, skippable,
-                  allowRetry, configUpgradePack);
+                  allowRetry, pack, configUpgradePack);
             }
           }
         } else {
@@ -908,7 +909,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
    *          which services are effected.
    * @throws AmbariException
    */
-  void applyStackAndProcessConfigurations(String stackName, Cluster cluster, String version, Direction direction, UpgradePack upgradePack)
+  public void applyStackAndProcessConfigurations(String stackName, Cluster cluster, String version, Direction direction, UpgradePack upgradePack)
       throws AmbariException {
     RepositoryVersionEntity targetRve = s_repoVersionDAO.findByStackNameAndVersion(stackName, version);
     if (null == targetRve) {
@@ -1368,7 +1369,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
    */
   private void makeServerSideStage(UpgradeContext context, RequestStageContainer request,
       UpgradeItemEntity entity, ServerSideActionTask task, boolean skippable, boolean allowRetry,
-      ConfigUpgradePack configUpgradePack)
+      UpgradePack upgradePack, ConfigUpgradePack configUpgradePack)
           throws AmbariException {
 
     Cluster cluster = context.getCluster();
@@ -1380,6 +1381,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     commandParams.put(COMMAND_PARAM_ORIGINAL_STACK, context.getOriginalStackId().getStackId());
     commandParams.put(COMMAND_PARAM_TARGET_STACK, context.getTargetStackId().getStackId());
     commandParams.put(COMMAND_DOWNGRADE_FROM_VERSION, context.getDowngradeFromVersion());
+    commandParams.put(COMMAND_PARAM_UPGRADE_PACK, upgradePack.getName());
 
     // Notice that this does not apply any params because the input does not specify a stage.
     // All of the other actions do use additional params.

http://git-wip-us.apache.org/repos/asf/ambari/blob/3ff718e3/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
index b676c9b..63330fc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
@@ -16,17 +16,22 @@
  * limitations under the License.
  */
 package org.apache.ambari.server.serveraction.upgrades;
+import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.VERSION;
 
 import com.google.inject.Inject;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
 import org.apache.ambari.server.agent.CommandReport;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.controller.AmbariServer;
+import org.apache.ambari.server.controller.internal.UpgradeResourceProvider;
 import org.apache.ambari.server.serveraction.AbstractServerAction;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.StackInfo;
+import org.apache.ambari.server.state.stack.UpgradePack;
+import org.apache.ambari.server.state.stack.upgrade.Direction;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -42,19 +47,24 @@ import java.util.concurrent.ConcurrentMap;
  */
 public class UpdateDesiredStackAction extends AbstractServerAction {
 
+  private static final String COMMAND_PARAM_VERSION = VERSION;
+  private static final String COMMAND_DOWNGRADE_FROM_VERSION = "downgrade_from_version";
+  private static final String COMMAND_PARAM_DIRECTION = "upgrade_direction";
+  private static final String COMMAND_PARAM_UPGRADE_PACK = "upgrade_pack";
+
   /**
    * The original "current" stack of the cluster before the upgrade started.
    * This is the same regardless of whether the current direction is
-   * {@link org.apache.ambari.server.state.stack.upgrade.Direction#UPGRADE} or {@link org.apache.ambari.server.state.stack.upgrade.Direction#DOWNGRADE}.
+   * {@link Direction#UPGRADE} or {@link Direction#DOWNGRADE}.
    */
-  public static final String ORIGINAL_STACK_KEY = "original_stack";
+  private static final String COMMAND_PARAM_ORIGINAL_STACK = "original_stack";
 
   /**
    * The target upgrade stack before the upgrade started. This is the same
-   * regardless of whether the current direction is {@link org.apache.ambari.server.state.stack.upgrade.Direction#UPGRADE} or
-   * {@link org.apache.ambari.server.state.stack.upgrade.Direction#DOWNGRADE}.
+   * regardless of whether the current direction is {@link Direction#UPGRADE} or
+   * {@link Direction#DOWNGRADE}.
    */
-  public static final String TARGET_STACK_KEY = "target_stack";
+  private static final String COMMAND_PARAM_TARGET_STACK = "target_stack";
 
   /**
    * The Cluster that this ServerAction implementation is executing on.
@@ -70,11 +80,19 @@ public class UpdateDesiredStackAction extends AbstractServerAction {
       throws AmbariException, InterruptedException {
     Map<String, String> commandParams = getExecutionCommand().getCommandParams();
 
-    StackId originalStackId = new StackId(commandParams.get(ORIGINAL_STACK_KEY));
-    StackId targetStackId = new StackId(commandParams.get(TARGET_STACK_KEY));
+    StackId originalStackId = new StackId(commandParams.get(COMMAND_PARAM_ORIGINAL_STACK));
+    StackId targetStackId = new StackId(commandParams.get(COMMAND_PARAM_TARGET_STACK));
+    Direction direction = Direction.UPGRADE;
+    if(commandParams.containsKey(COMMAND_PARAM_DIRECTION)
+        && "downgrade".equals(commandParams.get(COMMAND_PARAM_DIRECTION).toLowerCase())) {
+      direction = Direction.DOWNGRADE;
+    }
+    String version = commandParams.get(COMMAND_PARAM_VERSION);
+    String upgradePackName = commandParams.get(COMMAND_PARAM_UPGRADE_PACK);
     String clusterName = getExecutionCommand().getClusterName();
+    UpgradePack upgradePack = ambariMetaInfo.getUpgradePacks(originalStackId.getStackName(), originalStackId.getStackVersion()).get(upgradePackName);
 
-    return updateDesiredStack(clusterName, originalStackId, targetStackId);
+    return updateDesiredStack(clusterName, originalStackId, targetStackId, version, direction, upgradePack);
   }
 
   /**
@@ -85,7 +103,9 @@ public class UpdateDesiredStackAction extends AbstractServerAction {
    * @paran targetStackId the stack Id that was desired for this upgrade.
    * @return the command report to return
    */
-  private CommandReport updateDesiredStack(String clusterName, StackId originalStackId, StackId targetStackId)
+  private CommandReport updateDesiredStack(
+      String clusterName, StackId originalStackId, StackId targetStackId,
+      String version, Direction direction, UpgradePack upgradePack)
       throws AmbariException, InterruptedException {
     StringBuilder out = new StringBuilder();
     StringBuilder err = new StringBuilder();
@@ -93,6 +113,8 @@ public class UpdateDesiredStackAction extends AbstractServerAction {
     try {
       Cluster cluster = clusters.getCluster(clusterName);
       StackId currentClusterStackId = cluster.getCurrentStackVersion();
+      out.append(String.format("Params: %s %s %s %s %s %s",
+          clusterName, originalStackId.getStackId(), targetStackId.getStackId(), version, direction.getText(false), upgradePack.getName()));
 
       out.append(String.format("Checking if can update the Desired Stack Id to %s. The cluster's current Stack Id is %s\n", targetStackId.getStackId(), currentClusterStackId.getStackId()));
 
@@ -100,7 +122,7 @@ public class UpdateDesiredStackAction extends AbstractServerAction {
       StackInfo desiredClusterStackInfo = ambariMetaInfo.getStack(targetStackId.getStackName(), targetStackId.getStackVersion());
       if (null == desiredClusterStackInfo) {
         String message = String.format("Parameter %s has an invalid value: %s. That Stack Id does not exist.\n",
-            TARGET_STACK_KEY, targetStackId.getStackId());
+            COMMAND_PARAM_TARGET_STACK, targetStackId.getStackId());
         err.append(message);
         out.append(message);
         return createCommandReport(-1, HostRoleStatus.FAILED, "{}", out.toString(), err.toString());
@@ -110,7 +132,7 @@ public class UpdateDesiredStackAction extends AbstractServerAction {
       if (!currentClusterStackId.equals(originalStackId)) {
         String message = String.format("Parameter %s has invalid value: %s. " +
             "The cluster is currently on stack %s, " + currentClusterStackId.getStackId() +
-            ", yet the parameter to this function indicates a different value.\n", ORIGINAL_STACK_KEY, targetStackId.getStackId(), currentClusterStackId.getStackId());
+            ", yet the parameter to this function indicates a different value.\n", COMMAND_PARAM_ORIGINAL_STACK, originalStackId.getStackId(), currentClusterStackId.getStackId());
         err.append(message);
         out.append(message);
         return createCommandReport(-1, HostRoleStatus.FAILED, "{}", out.toString(), err.toString());
@@ -123,7 +145,10 @@ public class UpdateDesiredStackAction extends AbstractServerAction {
         return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", out.toString(), err.toString());
       }
 
-      cluster.setDesiredStackVersion(targetStackId, true);
+      // Create Create new configurations that are a merge between the current stack and the desired stack
+      // Also updates the desired stack version.
+      UpgradeResourceProvider upgradeResourceProvider = new UpgradeResourceProvider(AmbariServer.getController());
+      upgradeResourceProvider.applyStackAndProcessConfigurations(targetStackId.getStackName(), cluster, version, direction, upgradePack);
       String message = String.format("Success! Set cluster's %s Desired Stack Id to %s.\n", clusterName, targetStackId.getStackId());
       out.append(message);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3ff718e3/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml b/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml
index f8dcd8a..acab000 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml
@@ -176,6 +176,14 @@
       </execute-stage>
     </group>
 
+    <!-- After processing this group, will change the effective Stack of the UpgradeContext object. -->
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_STACK_ID" title="Update Target Stack">
+      <execute-stage title="Update Target Stack" service="" component="">
+        <task xsi:type="server_action" class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+        </task>
+      </execute-stage>
+    </group>
+
     <group xsi:type="cluster" name="Upgrade service configs" title="Upgrade service configs">
       <direction>UPGRADE</direction>   <!--  prevent config changes on downgrade -->
       <skippable>false</skippable>
@@ -288,14 +296,6 @@
 
     </group>
 
-    <!-- After processing this group, will change the effective Stack of the UpgradeContext object. -->
-    <group xsi:type="update-stack" name="UPDATE_DESIRED_STACK_ID" title="Update Target Stack">
-      <execute-stage title="Update Target Stack" service="" component="">
-        <task xsi:type="server_action" class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
-        </task>
-      </execute-stage>
-    </group>
-
     <!-- Invoke hdp-select set all after all components have been stopped by 
     before starting new ones. This step must be done here in order to
     ensure that components which rely on other components (like ZKFC on hadoop)

http://git-wip-us.apache.org/repos/asf/ambari/blob/3ff718e3/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml
index b043879..34d9edb 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml
@@ -248,6 +248,14 @@
       </execute-stage>
     </group>
 
+    <!-- After processing this group, will change the effective Stack of the UpgradeContext object. -->
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_STACK_ID" title="Update Target Stack">
+      <execute-stage title="Update Target Stack" service="" component="">
+        <task xsi:type="server_action" class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+        </task>
+      </execute-stage>
+    </group>
+
     <group xsi:type="cluster" name="Upgrade service configs" title="Upgrade service configs">
       <direction>UPGRADE</direction>   <!--  prevent config changes on downgrade -->
       <skippable>false</skippable>
@@ -467,15 +475,6 @@
 
     </group>
 
-
-    <!-- After processing this group, will change the effective Stack of the UpgradeContext object. -->
-    <group xsi:type="update-stack" name="UPDATE_DESIRED_STACK_ID" title="Update Target Stack">
-      <execute-stage title="Update Target Stack" service="" component="">
-        <task xsi:type="server_action" class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
-        </task>
-      </execute-stage>
-    </group>
-
     <!-- Invoke hdp-select set all after all components have been stopped but
     before starting new ones. This step must be done here in order to
     ensure that components which rely on other components (like ZKFC on hadoop)