AMBARI-21643 - Annotate upgrade packs for scope (jonathanhurley)

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

Branch: refs/heads/branch-2.6
Commit: ecd1b203296691c497d42bdafff3c94f9edf97a2
Parents: d9b9302
Author: Jonathan Hurley <jhur...@hortonworks.com>
Authored: Thu Aug 3 08:26:57 2017 -0400
Committer: Jonathan Hurley <jhur...@hortonworks.com>
Committed: Thu Aug 3 12:15:58 2017 -0400

----------------------------------------------------------------------
 .../upgrades/upgrade_nonrolling_new_stack.xml   |   6 +-
 .../2.1.1/upgrades/upgrade_test_nonrolling.xml  |   4 +-
 .../api/services/WidgetLayoutService.java       |  23 ++-
 .../internal/UpgradeResourceProvider.java       |   4 +-
 .../upgrades/UpdateDesiredRepositoryAction.java | 198 +++++++++++++++++++
 .../upgrades/UpdateDesiredStackAction.java      | 198 -------------------
 .../upgrades/nonrolling-upgrade-to-hdp-2.6.xml  |   6 +-
 .../upgrades/nonrolling-upgrade-to-hdp-2.6.xml  |   6 +-
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml |   6 +-
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml |   7 +-
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml |   7 +-
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml |   7 +-
 .../stacks/HDP/2.3/upgrades/upgrade-2.4.xml     |   1 +
 .../stacks/HDP/2.3/upgrades/upgrade-2.5.xml     |   1 +
 .../stacks/HDP/2.3/upgrades/upgrade-2.6.xml     |   1 +
 .../HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml |   6 +-
 .../HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml |   6 +-
 .../HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml |   6 +-
 .../stacks/HDP/2.4/upgrades/upgrade-2.5.xml     |   1 +
 .../stacks/HDP/2.4/upgrades/upgrade-2.6.xml     |   1 +
 .../HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml |   6 +-
 .../HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml |   6 +-
 .../HDP/2.6/upgrades/nonrolling-upgrade-2.6.xml |   6 +-
 .../1.0/upgrades/nonrolling-upgrade-2.0.xml     |   6 +-
 .../upgrades/UpgradeActionTest.java             |   6 +-
 .../server/state/stack/UpgradePackTest.java     |   4 +-
 .../upgrades/upgrade_nonrolling_new_stack.xml   |   6 +-
 .../2.1.1/upgrades/upgrade_test_nonrolling.xml  |   4 +-
 28 files changed, 275 insertions(+), 264 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
----------------------------------------------------------------------
diff --git 
a/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
 
b/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
index ad6174c..1443324 100644
--- 
a/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
+++ 
b/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
@@ -237,9 +237,9 @@
     </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">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories" service="" 
component="">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
----------------------------------------------------------------------
diff --git 
a/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
 
b/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
index 9f57ca8..f7dd720 100644
--- 
a/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
+++ 
b/ambari-funtest/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
@@ -105,9 +105,9 @@
     </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 Desired Stack Id">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Desired Stack Id">
       <execute-stage title="Update Desired Stack Id" service="" component="">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/java/org/apache/ambari/server/api/services/WidgetLayoutService.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/WidgetLayoutService.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/WidgetLayoutService.java
index 3902236..511ff4f 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/WidgetLayoutService.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/WidgetLayoutService.java
@@ -17,19 +17,23 @@
  */
 package org.apache.ambari.server.api.services;
 
-import com.sun.jersey.core.util.Base64;
-import org.apache.ambari.server.api.resources.ResourceInstance;
-import org.apache.ambari.server.controller.spi.Resource;
+import java.util.HashMap;
+import java.util.Map;
 
-import javax.ws.rs.*;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.controller.spi.Resource;
 
 /**
  * WidgetLayout Service
@@ -64,7 +68,6 @@ public class WidgetLayoutService extends BaseService {
   @GET
   @Produces("text/plain")
   public Response getServices(String body, @Context HttpHeaders headers, 
@Context UriInfo ui) {
-    System.out.println("###########");
     return handleRequest(headers, body, ui, Request.Type.GET,
             createResource(null));
   }
@@ -112,7 +115,7 @@ public class WidgetLayoutService extends BaseService {
   }
 
   private ResourceInstance createResource(String widgetLayoutId) {
-    Map<Resource.Type,String> mapIds = new HashMap<Resource.Type, String>();
+    Map<Resource.Type,String> mapIds = new HashMap<>();
     mapIds.put(Resource.Type.WidgetLayout, widgetLayoutId);
     mapIds.put(Resource.Type.Cluster, clusterName);
     return createResource(Resource.Type.WidgetLayout, mapIds);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/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 83a9510..4a28f56 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
@@ -643,7 +643,7 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
 
     List<UpgradeGroupHolder> groups = s_upgradeHelper.createSequence(pack, 
upgradeContext);
 
-    // Non Rolling Upgrades require a group with name 
"UPDATE_DESIRED_STACK_ID".
+    // Non Rolling Upgrades require a group with name 
"UPDATE_DESIRED_REPOSITORY_ID".
     // This is needed as a marker to indicate which version to use when an 
upgrade is paused.
     if (pack.getType() == UpgradeType.NON_ROLLING) {
       boolean foundUpdateDesiredRepositoryIdGrouping = false;
@@ -686,7 +686,7 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
 
     During a {@link UpgradeType.NON_ROLLING} upgrade, the stack is applied 
during the middle of the upgrade (after
     stopping all services), and the configs are applied immediately before 
starting the services.
-    The Upgrade Pack is responsible for calling {@link 
org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction}
+    The Upgrade Pack is responsible for calling {@link 
org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction}
     at the appropriate moment during the orchestration.
     */
     if (pack.getType() == UpgradeType.ROLLING) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredRepositoryAction.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredRepositoryAction.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredRepositoryAction.java
new file mode 100644
index 0000000..9242dae
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredRepositoryAction.java
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.serveraction.upgrades;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+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.configuration.Configuration;
+import org.apache.ambari.server.orm.dao.HostVersionDAO;
+import org.apache.ambari.server.orm.entities.HostVersionEntity;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
+import org.apache.ambari.server.serveraction.ServerAction;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.RepositoryType;
+import org.apache.ambari.server.state.RepositoryVersionState;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.UpgradeContext;
+import org.apache.ambari.server.state.stack.upgrade.Direction;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+import com.google.inject.persist.Transactional;
+
+/**
+ * Action that represents updating the Desired Stack Id during the middle of a 
stack upgrade (typically NonRolling).
+ * In a {@link 
org.apache.ambari.server.state.stack.upgrade.UpgradeType#NON_ROLLING}, the 
effective Stack Id is
+ * actually changed half-way through calculating the Actions, and this serves 
to update the database to make it
+ * evident to the user at which point it changed.
+ */
+public class UpdateDesiredRepositoryAction extends AbstractUpgradeServerAction 
{
+
+  /**
+   * Logger.
+   */
+  private static final Logger LOG = 
LoggerFactory.getLogger(UpdateDesiredRepositoryAction.class);
+
+
+  /**
+   * The Cluster that this ServerAction implementation is executing on.
+   */
+  @Inject
+  private Clusters clusters;
+
+  /**
+   * The Ambari configuration.
+   */
+  @Inject
+  private Configuration m_configuration;
+
+  /**
+   * Used for restting host version states on downgrade.
+   */
+  @Inject
+  private HostVersionDAO m_hostVersionDAO;
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public CommandReport execute(ConcurrentMap<String, Object> 
requestSharedDataContext)
+      throws AmbariException, InterruptedException {
+
+    String clusterName = getExecutionCommand().getClusterName();
+    Cluster cluster = clusters.getCluster(clusterName);
+    UpgradeContext upgradeContext = getUpgradeContext(cluster);
+
+    Map<String, String> roleParams = getExecutionCommand().getRoleParams();
+
+    // Make a best attempt at setting the username
+    String userName;
+    if (roleParams != null && 
roleParams.containsKey(ServerAction.ACTION_USER_NAME)) {
+      userName = roleParams.get(ServerAction.ACTION_USER_NAME);
+    } else {
+      userName = m_configuration.getAnonymousAuditName();
+      LOG.warn(String.format("Did not receive role parameter %s, will save 
configs using anonymous username %s", ServerAction.ACTION_USER_NAME, userName));
+    }
+
+    return updateDesiredRepositoryVersion(cluster, upgradeContext, userName);
+  }
+
+  /**
+   * Sets the desired repository version for services participating in the
+   * upgrade.
+   *
+   * @param cluster
+   *          the cluster
+   * @param upgradeContext
+   *          the upgrade context
+   * @param userName
+   *          username performing the action
+   * @return the command report to return
+   */
+  @Transactional
+  CommandReport updateDesiredRepositoryVersion(
+      Cluster cluster, UpgradeContext upgradeContext, String userName)
+      throws AmbariException, InterruptedException {
+
+    StringBuilder out = new StringBuilder();
+    StringBuilder err = new StringBuilder();
+
+    try {
+      // the desired repository message to put in the command report - this 
will
+      // change based on the type of upgrade and the services participating
+      if (upgradeContext.getDirection() == Direction.UPGRADE) {
+        final String message;
+        RepositoryVersionEntity targetRepositoryVersion = 
upgradeContext.getRepositoryVersion();
+
+        if (upgradeContext.getOrchestrationType() == RepositoryType.STANDARD) {
+          message = MessageFormat.format(
+              "Updating the desired repository version to {0} for all cluster 
services.",
+              targetRepositoryVersion.getVersion());
+        } else {
+          Set<String> servicesInUpgrade = 
upgradeContext.getSupportedServices();
+          message = MessageFormat.format(
+              "Updating the desired repository version to {0} for the 
following services: {1}",
+              targetRepositoryVersion.getVersion(), 
StringUtils.join(servicesInUpgrade, ','));
+        }
+
+        out.append(message).append(System.lineSeparator());
+
+        // move the cluster's desired stack as well
+        StackId targetStackId = targetRepositoryVersion.getStackId();
+        cluster.setDesiredStackVersion(targetStackId);
+      }
+
+      if( upgradeContext.getDirection() == Direction.DOWNGRADE ){
+        String message = "Updating the desired repository back their original 
values for the following services:";
+        out.append(message).append(System.lineSeparator());
+
+        Map<String, RepositoryVersionEntity> targetVersionsByService = 
upgradeContext.getTargetVersions();
+        for (String serviceName : targetVersionsByService.keySet()) {
+          RepositoryVersionEntity repositoryVersion = 
targetVersionsByService.get(serviceName);
+
+          message = String.format("  %s to %s", serviceName, 
repositoryVersion.getVersion());
+          out.append(message).append(System.lineSeparator());
+        }        
+      }
+
+      // move repositories to the right version and create/revert configs
+      m_upgradeHelper.updateDesiredRepositoriesAndConfigs(upgradeContext);
+
+      // a downgrade must force host versions back to INSTALLED for the
+      // repository which failed to be upgraded.
+      if (upgradeContext.getDirection() == Direction.DOWNGRADE) {
+        RepositoryVersionEntity downgradeFromRepositoryVersion = 
upgradeContext.getRepositoryVersion();
+        out.append(String.format("Setting host versions back to %s for 
repository version %s",
+            RepositoryVersionState.INSTALLED, 
downgradeFromRepositoryVersion.getVersion()));
+
+        List<HostVersionEntity> hostVersionsToReset = 
m_hostVersionDAO.findHostVersionByClusterAndRepository(
+            cluster.getClusterId(), downgradeFromRepositoryVersion);
+
+        for (HostVersionEntity hostVersion : hostVersionsToReset) {
+          if( hostVersion.getState() != RepositoryVersionState.NOT_REQUIRED ){
+            hostVersion.setState(RepositoryVersionState.INSTALLED);
+          }
+        }
+        
+        // move the cluster's desired stack back to it's current stack on 
downgrade
+        StackId targetStackId = cluster.getCurrentStackVersion();
+        cluster.setDesiredStackVersion(targetStackId);        
+      }
+
+      return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", 
out.toString(), err.toString());
+    } catch (Exception e) {
+      StringWriter sw = new StringWriter();
+      e.printStackTrace(new PrintWriter(sw));
+      err.append(sw);
+
+      return createCommandReport(-1, HostRoleStatus.FAILED, "{}", 
out.toString(), err.toString());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/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
deleted file mode 100644
index 40f238c..0000000
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/UpdateDesiredStackAction.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.ambari.server.serveraction.upgrades;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-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.configuration.Configuration;
-import org.apache.ambari.server.orm.dao.HostVersionDAO;
-import org.apache.ambari.server.orm.entities.HostVersionEntity;
-import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
-import org.apache.ambari.server.serveraction.ServerAction;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.RepositoryType;
-import org.apache.ambari.server.state.RepositoryVersionState;
-import org.apache.ambari.server.state.StackId;
-import org.apache.ambari.server.state.UpgradeContext;
-import org.apache.ambari.server.state.stack.upgrade.Direction;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Inject;
-import com.google.inject.persist.Transactional;
-
-/**
- * Action that represents updating the Desired Stack Id during the middle of a 
stack upgrade (typically NonRolling).
- * In a {@link 
org.apache.ambari.server.state.stack.upgrade.UpgradeType#NON_ROLLING}, the 
effective Stack Id is
- * actually changed half-way through calculating the Actions, and this serves 
to update the database to make it
- * evident to the user at which point it changed.
- */
-public class UpdateDesiredStackAction extends AbstractUpgradeServerAction {
-
-  /**
-   * Logger.
-   */
-  private static final Logger LOG = 
LoggerFactory.getLogger(UpdateDesiredStackAction.class);
-
-
-  /**
-   * The Cluster that this ServerAction implementation is executing on.
-   */
-  @Inject
-  private Clusters clusters;
-
-  /**
-   * The Ambari configuration.
-   */
-  @Inject
-  private Configuration m_configuration;
-
-  /**
-   * Used for restting host version states on downgrade.
-   */
-  @Inject
-  private HostVersionDAO m_hostVersionDAO;
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public CommandReport execute(ConcurrentMap<String, Object> 
requestSharedDataContext)
-      throws AmbariException, InterruptedException {
-
-    String clusterName = getExecutionCommand().getClusterName();
-    Cluster cluster = clusters.getCluster(clusterName);
-    UpgradeContext upgradeContext = getUpgradeContext(cluster);
-
-    Map<String, String> roleParams = getExecutionCommand().getRoleParams();
-
-    // Make a best attempt at setting the username
-    String userName;
-    if (roleParams != null && 
roleParams.containsKey(ServerAction.ACTION_USER_NAME)) {
-      userName = roleParams.get(ServerAction.ACTION_USER_NAME);
-    } else {
-      userName = m_configuration.getAnonymousAuditName();
-      LOG.warn(String.format("Did not receive role parameter %s, will save 
configs using anonymous username %s", ServerAction.ACTION_USER_NAME, userName));
-    }
-
-    return updateDesiredRepositoryVersion(cluster, upgradeContext, userName);
-  }
-
-  /**
-   * Sets the desired repository version for services participating in the
-   * upgrade.
-   *
-   * @param cluster
-   *          the cluster
-   * @param upgradeContext
-   *          the upgrade context
-   * @param userName
-   *          username performing the action
-   * @return the command report to return
-   */
-  @Transactional
-  CommandReport updateDesiredRepositoryVersion(
-      Cluster cluster, UpgradeContext upgradeContext, String userName)
-      throws AmbariException, InterruptedException {
-
-    StringBuilder out = new StringBuilder();
-    StringBuilder err = new StringBuilder();
-
-    try {
-      // the desired repository message to put in the command report - this 
will
-      // change based on the type of upgrade and the services participating
-      if (upgradeContext.getDirection() == Direction.UPGRADE) {
-        final String message;
-        RepositoryVersionEntity targetRepositoryVersion = 
upgradeContext.getRepositoryVersion();
-
-        if (upgradeContext.getOrchestrationType() == RepositoryType.STANDARD) {
-          message = MessageFormat.format(
-              "Updating the desired repository version to {0} for all cluster 
services.",
-              targetRepositoryVersion.getVersion());
-        } else {
-          Set<String> servicesInUpgrade = 
upgradeContext.getSupportedServices();
-          message = MessageFormat.format(
-              "Updating the desired repository version to {0} for the 
following services: {1}",
-              targetRepositoryVersion.getVersion(), 
StringUtils.join(servicesInUpgrade, ','));
-        }
-
-        out.append(message).append(System.lineSeparator());
-
-        // move the cluster's desired stack as well
-        StackId targetStackId = targetRepositoryVersion.getStackId();
-        cluster.setDesiredStackVersion(targetStackId);
-      }
-
-      if( upgradeContext.getDirection() == Direction.DOWNGRADE ){
-        String message = "Updating the desired repository back their original 
values for the following services:";
-        out.append(message).append(System.lineSeparator());
-
-        Map<String, RepositoryVersionEntity> targetVersionsByService = 
upgradeContext.getTargetVersions();
-        for (String serviceName : targetVersionsByService.keySet()) {
-          RepositoryVersionEntity repositoryVersion = 
targetVersionsByService.get(serviceName);
-
-          message = String.format("  %s to %s", serviceName, 
repositoryVersion.getVersion());
-          out.append(message).append(System.lineSeparator());
-        }        
-      }
-
-      // move repositories to the right version and create/revert configs
-      m_upgradeHelper.updateDesiredRepositoriesAndConfigs(upgradeContext);
-
-      // a downgrade must force host versions back to INSTALLED for the
-      // repository which failed to be upgraded.
-      if (upgradeContext.getDirection() == Direction.DOWNGRADE) {
-        RepositoryVersionEntity downgradeFromRepositoryVersion = 
upgradeContext.getRepositoryVersion();
-        out.append(String.format("Setting host versions back to %s for 
repository version %s",
-            RepositoryVersionState.INSTALLED, 
downgradeFromRepositoryVersion.getVersion()));
-
-        List<HostVersionEntity> hostVersionsToReset = 
m_hostVersionDAO.findHostVersionByClusterAndRepository(
-            cluster.getClusterId(), downgradeFromRepositoryVersion);
-
-        for (HostVersionEntity hostVersion : hostVersionsToReset) {
-          if( hostVersion.getState() != RepositoryVersionState.NOT_REQUIRED ){
-            hostVersion.setState(RepositoryVersionState.INSTALLED);
-          }
-        }
-        
-        // move the cluster's desired stack back to it's current stack on 
downgrade
-        StackId targetStackId = cluster.getCurrentStackVersion();
-        cluster.setDesiredStackVersion(targetStackId);        
-      }
-
-      return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", 
out.toString(), err.toString());
-    } catch (Exception e) {
-      StringWriter sw = new StringWriter();
-      e.printStackTrace(new PrintWriter(sw));
-      err.append(sw);
-
-      return createCommandReport(-1, HostRoleStatus.FAILED, "{}", 
out.toString(), err.toString());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
 
b/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
index 1fe0382..1970741 100644
--- 
a/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
+++ 
b/ambari-server/src/main/resources/stacks/BigInsights/4.2.5/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
@@ -174,9 +174,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/BigInsights/4.2/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/BigInsights/4.2/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
 
b/ambari-server/src/main/resources/stacks/BigInsights/4.2/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
index 55736cf..e4fc5d4 100644
--- 
a/ambari-server/src/main/resources/stacks/BigInsights/4.2/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
+++ 
b/ambari-server/src/main/resources/stacks/BigInsights/4.2/upgrades/nonrolling-upgrade-to-hdp-2.6.xml
@@ -169,9 +169,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
index ebdae5f..c542e8c 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
@@ -240,9 +240,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml
index 981c7d5..03a6d36 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.4.xml
@@ -241,9 +241,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>
@@ -450,6 +450,7 @@
     that are installed on the hosts but not known by Ambari.
     -->
     <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All 
Hosts">
+      <scope>COMPLETE</scope>
       <skippable>true</skippable>
       <supports-auto-skip-failure>false</supports-auto-skip-failure>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
index 00af91e..625980a 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
@@ -258,9 +258,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>
@@ -610,6 +610,7 @@
     that are installed on the hosts but not known by Ambari.
     -->
     <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All 
Hosts">
+      <scope>COMPLETE</scope>
       <skippable>true</skippable>
       <supports-auto-skip-failure>false</supports-auto-skip-failure>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
index ca3c193..498f423 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
@@ -260,9 +260,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>
@@ -703,6 +703,7 @@
     that are installed on the hosts but not known by Ambari.
     -->
     <group xsi:type="cluster" name="ALL_HOST_OPS" title="Set Version On All 
Hosts">
+      <scope>COMPLETE</scope>
       <skippable>true</skippable>
       <supports-auto-skip-failure>false</supports-auto-skip-failure>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
index c15c9d4..bd55e7c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.4.xml
@@ -426,6 +426,7 @@
     </group>
 
     <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
+      <scope>COMPLETE</scope>
       <execute-stage title="Update remaining HDP stack to {{version}}">
         <task xsi:type="execute">
           <script>scripts/ru_set_all.py</script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
index 2beed1d..f76bb5a 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
@@ -496,6 +496,7 @@
     </group>
 
     <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
+      <scope>COMPLETE</scope>
       <execute-stage title="Update remaining HDP stack to {{version}}">
         <task xsi:type="execute">
           <script>scripts/ru_set_all.py</script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml 
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
index cf2c257..538223a 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
@@ -498,6 +498,7 @@
     </group>
 
     <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
+      <scope>COMPLETE</scope>
       <execute-stage title="Update remaining HDP stack to {{version}}">
         <task xsi:type="execute">
           <script>scripts/ru_set_all.py</script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml
index e42b8b2..78c3ae4 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.4.xml
@@ -240,9 +240,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
index a5d6368..1fc8175 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
@@ -252,9 +252,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
index 6e899ee..0fd5c5b 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
@@ -254,9 +254,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml 
b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
index 5fe0d2e..26d36d4 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
@@ -481,6 +481,7 @@
     </group>
 
     <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
+      <scope>COMPLETE</scope>
       <execute-stage title="Update remaining HDP stack to {{version}}">
         <task xsi:type="execute">
           <script>scripts/ru_set_all.py</script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml 
b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
index 4e14e83..00a10c5 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
@@ -487,6 +487,7 @@
     </group>
 
     <group xsi:type="cluster" name="ALL_HOST_OPS" title="Finalize Hosts">
+      <scope>COMPLETE</scope>
       <execute-stage title="Update remaining HDP stack to {{version}}">
         <task xsi:type="execute">
           <script>scripts/ru_set_all.py</script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml
index d1774ae..3504be7 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.5.xml
@@ -260,9 +260,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
index ce10e8b..1697604 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
@@ -266,9 +266,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction"/>
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction"/>
       </execute-stage>
     </group>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/HDP/2.6/upgrades/nonrolling-upgrade-2.6.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/HDP/2.6/upgrades/nonrolling-upgrade-2.6.xml
 
b/ambari-server/src/main/resources/stacks/HDP/2.6/upgrades/nonrolling-upgrade-2.6.xml
index df609cd..86b3956 100644
--- 
a/ambari-server/src/main/resources/stacks/HDP/2.6/upgrades/nonrolling-upgrade-2.6.xml
+++ 
b/ambari-server/src/main/resources/stacks/HDP/2.6/upgrades/nonrolling-upgrade-2.6.xml
@@ -277,9 +277,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml
 
b/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml
index 7078a6e..5d24ff8 100644
--- 
a/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml
+++ 
b/ambari-server/src/main/resources/stacks/PERF/1.0/upgrades/nonrolling-upgrade-2.0.xml
@@ -72,9 +72,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction"/>
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction"/>
       </execute-stage>
     </group>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
index 6907f32..e570132 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
@@ -289,12 +289,12 @@ public class UpgradeActionTest {
   }
 
   /***
-   * During an Express Upgrade that crosses a stack version, Ambari calls 
UpdateDesiredStackAction
+   * During an Express Upgrade that crosses a stack version, Ambari calls 
UpdateDesiredRepositoryAction
    * in order to change the stack and apply configs.
    * The configs that are applied must be saved with the username that is 
passed in the role params.
    */
   @Test
-  public void testExpressUpgradeUpdateDesiredStackAction() throws Exception {
+  public void testExpressUpgradeUpdateDesiredRepositoryAction() throws 
Exception {
     StackId sourceStack = HDP_21_STACK;
     StackId targetStack = HDP_22_STACK;
     String sourceRepo = HDP_2_1_1_0;
@@ -349,7 +349,7 @@ public class UpgradeActionTest {
     hostRoleCommand.setExecutionCommandWrapper(new 
ExecutionCommandWrapper(executionCommand));
 
     // Call the action to change the desired stack and apply the configs from 
the Config Pack called by the Upgrade Pack.
-    UpdateDesiredStackAction action = 
m_injector.getInstance(UpdateDesiredStackAction.class);
+    UpdateDesiredRepositoryAction action = 
m_injector.getInstance(UpdateDesiredRepositoryAction.class);
     action.setExecutionCommand(executionCommand);
     action.setHostRoleCommand(hostRoleCommand);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
index e628c80..39b02a4 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
@@ -272,7 +272,7 @@ public class UpgradePackTest {
       "Stop High-Level Daemons",
       "Backups",
       "Stop Low-Level Daemons",
-      "UPDATE_DESIRED_STACK_ID",
+      "UPDATE_DESIRED_REPOSITORY_ID",
       "ALL_HOST_OPS",
       "ZOOKEEPER",
       "HDFS",
@@ -281,7 +281,7 @@ public class UpgradePackTest {
 
     List<String> expected_down = Arrays.asList(
       "Restore Backups",
-      "UPDATE_DESIRED_STACK_ID",
+      "UPDATE_DESIRED_REPOSITORY_ID",
       "ALL_HOST_OPS",
       "ZOOKEEPER",
       "HDFS",

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
index 9d53714..913b885 100644
--- 
a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
+++ 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_nonrolling_new_stack.xml
@@ -237,9 +237,9 @@
     </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">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Target Repositories">
+      <execute-stage title="Update Target Repositories">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd1b203/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
index dcddbc5..3dd4bc5 100644
--- 
a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
+++ 
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
@@ -107,9 +107,9 @@
     </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 Desired Stack Id">
+    <group xsi:type="update-stack" name="UPDATE_DESIRED_REPOSITORY_ID" 
title="Update Desired Stack Id">
       <execute-stage title="Update Desired Stack Id">
-        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredStackAction">
+        <task xsi:type="server_action" 
class="org.apache.ambari.server.serveraction.upgrades.UpdateDesiredRepositoryAction">
         </task>
       </execute-stage>
     </group>

Reply via email to