This is an automated email from the ASF dual-hosted git repository.

ncole pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by 
this push:
     new 22c2e5b  [AMBARI-24197] Change Orchestrator for Lifecycle groupings 
(#1629)
22c2e5b is described below

commit 22c2e5b3d57a12ce23d8a9eee4b95370972b2f9e
Author: ncole <[email protected]>
AuthorDate: Wed Jun 27 10:06:55 2018 -0400

    [AMBARI-24197] Change Orchestrator for Lifecycle groupings (#1629)
---
 .../internal/UpgradePlanResourceProvider.java      |  14 ++-
 .../internal/UpgradeResourceProvider.java          | 134 ++++++++-------------
 .../apache/ambari/server/state/UpgradeContext.java |  32 +++--
 .../apache/ambari/server/state/UpgradeHelper.java  |  65 +++++++++-
 .../ambari/server/state/stack/UpgradePack.java     |  25 ----
 .../custom_actions/scripts/mpack_packages.py       |   3 +-
 ambari-server/src/main/resources/upgrade-pack.xsd  |   2 -
 .../mpacks-v2/upgrade-packs/upgrade-basic.xml      |   3 -
 8 files changed, 149 insertions(+), 129 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProvider.java
index a2308a8..04dbcbc 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProvider.java
@@ -78,12 +78,23 @@ public class UpgradePlanResourceProvider extends 
AbstractControllerResourceProvi
 
   public static final String UPGRADE_PLAN_TYPE                        = 
UPGRADE_PLAN + "upgrade_type";
   public static final String UPGRADE_PLAN_DIRECTION                   = 
UPGRADE_PLAN + "direction";
+  /**
+   * Skip slave/client component failures if the tasks are skippable.
+   */
   public static final String UPGRADE_PLAN_SKIP_FAILURES               = 
UPGRADE_PLAN + "skip_failures";
   public static final String UPGRADE_PLAN_SKIP_PREREQUISITE_CHECKS    = 
UPGRADE_PLAN + "skip_prerequisite_checks";
   public static final String UPGRADE_PLAN_SKIP_SERVICE_CHECKS         = 
UPGRADE_PLAN + "skip_service_checks";
+  /**
+   * Skip service check failures if the tasks are skippable.
+   */
   public static final String UPGRADE_PLAN_SKIP_SERVICE_CHECK_FAILURES = 
UPGRADE_PLAN + "skip_service_check_failures";
   public static final String UPGRADE_PLAN_FAIL_ON_CHECK_WARNINGS      = 
UPGRADE_PLAN + "fail_on_check_warnings";
   public static final String UPGRADE_PLAN_SERVICE_GROUPS              = 
UPGRADE_PLAN + "servicegroups";
+  /**
+   * Skip manual verification tasks for hands-free upgrade/downgrade 
experience.
+   */
+  public static final String UPGRADE_SKIP_MANUAL_VERIFICATION = UPGRADE_PLAN + 
"skip_manual_verification";
+
 
   private static final Map<Resource.Type, String> KEY_PROPERTY_IDS = 
ImmutableMap.<Resource.Type, String>builder()
       .put(Resource.Type.UpgradePlan, UPGRADE_PLAN_ID)
@@ -293,7 +304,6 @@ public class UpgradePlanResourceProvider extends 
AbstractControllerResourceProvi
       entity.setSkipServiceChecks(skip);
     }
 
-    Long clusterId = cluster.getClusterId();
     List<UpgradePlanDetailEntity> details = new ArrayList<>();
 
     serviceGroupJsons.stream()
@@ -321,7 +331,7 @@ public class UpgradePlanResourceProvider extends 
AbstractControllerResourceProvi
         } else {
           // !!! TODO find the upgrade pack in the target that will update the
           // service group
-          detail.setUpgradePack("foo");
+          detail.setUpgradePack("TODO");
         }
 
         // !!! TODO During create, we have to resolve the config changes and 
persist them
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 a5aec09..1de76d1 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
@@ -27,8 +27,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import org.apache.ambari.annotations.Experimental;
 import org.apache.ambari.annotations.ExperimentalFeature;
@@ -66,6 +64,7 @@ import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
 import org.apache.ambari.server.orm.dao.HostRoleCommandStatusSummaryDTO;
 import org.apache.ambari.server.orm.dao.RequestDAO;
 import org.apache.ambari.server.orm.dao.UpgradeDAO;
+import org.apache.ambari.server.orm.dao.UpgradePlanDAO;
 import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
 import org.apache.ambari.server.orm.entities.MpackEntity;
 import org.apache.ambari.server.orm.entities.RequestEntity;
@@ -73,13 +72,13 @@ import org.apache.ambari.server.orm.entities.UpgradeEntity;
 import org.apache.ambari.server.orm.entities.UpgradeGroupEntity;
 import org.apache.ambari.server.orm.entities.UpgradeHistoryEntity;
 import org.apache.ambari.server.orm.entities.UpgradeItemEntity;
+import org.apache.ambari.server.orm.entities.UpgradePlanEntity;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.security.authorization.AuthorizationHelper;
 import org.apache.ambari.server.security.authorization.ResourceType;
 import org.apache.ambari.server.security.authorization.RoleAuthorization;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.UpgradeContext;
 import org.apache.ambari.server.state.UpgradeContextFactory;
@@ -105,6 +104,7 @@ import org.codehaus.jackson.annotate.JsonProperty;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import com.google.gson.JsonArray;
@@ -134,22 +134,27 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
   public static final String UPGRADE_REQUEST_STATUS = "Upgrade/request_status";
   public static final String UPGRADE_SUSPENDED = "Upgrade/suspended";
   public static final String UPGRADE_ABORT_REASON = "Upgrade/abort_reason";
+  @Deprecated
   public static final String UPGRADE_SKIP_PREREQUISITE_CHECKS = 
"Upgrade/skip_prerequisite_checks";
+  @Deprecated
   public static final String UPGRADE_FAIL_ON_CHECK_WARNINGS = 
"Upgrade/fail_on_check_warnings";
 
   /**
    * Skip slave/client component failures if the tasks are skippable.
    */
+  @Deprecated
   public static final String UPGRADE_SKIP_FAILURES = "Upgrade/skip_failures";
 
   /**
    * Skip service check failures if the tasks are skippable.
    */
+  @Deprecated
   public static final String UPGRADE_SKIP_SC_FAILURES = 
"Upgrade/skip_service_check_failures";
 
   /**
    * Skip manual verification tasks for hands-free upgrade/downgrade 
experience.
    */
+  @Deprecated
   public static final String UPGRADE_SKIP_MANUAL_VERIFICATION = 
"Upgrade/skip_manual_verification";
 
   /**
@@ -200,12 +205,40 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
   private static final Set<String> PK_PROPERTY_IDS = new HashSet<>(
       Arrays.asList(UPGRADE_REQUEST_ID, UPGRADE_CLUSTER_NAME));
 
-  private static final Set<String> PROPERTY_IDS = new HashSet<>();
+  private static final Set<String> PROPERTY_IDS = Sets.newHashSet(
+      UPGRADE_CLUSTER_NAME,
+      UPGRADE_PLAN_ID,
+      UPGRADE_TYPE,
+      UPGRADE_ID,
+      UPGRADE_REQUEST_ID,
+      UPGRADE_SUMMARY,
+      UPGRADE_VERSIONS,
+      UPGRADE_DIRECTION,
+      UPGRADE_DOWNGRADE_ALLOWED,
+      UPGRADE_SUSPENDED,
+      UPGRADE_SKIP_FAILURES,
+      UPGRADE_SKIP_SC_FAILURES,
+      UPGRADE_SKIP_MANUAL_VERIFICATION,
+      UPGRADE_SKIP_PREREQUISITE_CHECKS,
+      UPGRADE_FAIL_ON_CHECK_WARNINGS,
+      UPGRADE_HOST_ORDERED_HOSTS,
+      UPGRADE_REVERT_UPGRADE_ID,
+
+      REQUEST_CONTEXT_ID,
+      REQUEST_CREATE_TIME_ID,
+      REQUEST_END_TIME_ID,
+      REQUEST_EXCLUSIVE_ID,
+      REQUEST_PROGRESS_PERCENT_ID,
+      REQUEST_START_TIME_ID,
+      REQUEST_STATUS_PROPERTY_ID,
+      REQUEST_TYPE_ID);
+
+  private static final Map<Resource.Type, String> KEY_PROPERTY_IDS = 
ImmutableMap.of(
+      Resource.Type.Upgrade, UPGRADE_REQUEST_ID,
+      Resource.Type.Cluster, UPGRADE_CLUSTER_NAME);
 
   private static final String DEFAULT_REASON_TEMPLATE = "Aborting upgrade %s";
 
-  private static final Map<Resource.Type, String> KEY_PROPERTY_IDS = new 
HashMap<>();
-
   @Inject
   protected static UpgradeDAO s_upgradeDAO = null;
 
@@ -258,39 +291,8 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
   @Inject
   private RequestDAO requestDAO;
 
-  static {
-    // properties
-    PROPERTY_IDS.add(UPGRADE_CLUSTER_NAME);
-    PROPERTY_IDS.add(UPGRADE_PLAN_ID);
-    PROPERTY_IDS.add(UPGRADE_TYPE);
-    PROPERTY_IDS.add(UPGRADE_ID);
-    PROPERTY_IDS.add(UPGRADE_REQUEST_ID);
-    PROPERTY_IDS.add(UPGRADE_SUMMARY);
-    PROPERTY_IDS.add(UPGRADE_VERSIONS);
-    PROPERTY_IDS.add(UPGRADE_DIRECTION);
-    PROPERTY_IDS.add(UPGRADE_DOWNGRADE_ALLOWED);
-    PROPERTY_IDS.add(UPGRADE_SUSPENDED);
-    PROPERTY_IDS.add(UPGRADE_SKIP_FAILURES);
-    PROPERTY_IDS.add(UPGRADE_SKIP_SC_FAILURES);
-    PROPERTY_IDS.add(UPGRADE_SKIP_MANUAL_VERIFICATION);
-    PROPERTY_IDS.add(UPGRADE_SKIP_PREREQUISITE_CHECKS);
-    PROPERTY_IDS.add(UPGRADE_FAIL_ON_CHECK_WARNINGS);
-    PROPERTY_IDS.add(UPGRADE_HOST_ORDERED_HOSTS);
-    PROPERTY_IDS.add(UPGRADE_REVERT_UPGRADE_ID);
-
-    PROPERTY_IDS.add(REQUEST_CONTEXT_ID);
-    PROPERTY_IDS.add(REQUEST_CREATE_TIME_ID);
-    PROPERTY_IDS.add(REQUEST_END_TIME_ID);
-    PROPERTY_IDS.add(REQUEST_EXCLUSIVE_ID);
-    PROPERTY_IDS.add(REQUEST_PROGRESS_PERCENT_ID);
-    PROPERTY_IDS.add(REQUEST_START_TIME_ID);
-    PROPERTY_IDS.add(REQUEST_STATUS_PROPERTY_ID);
-    PROPERTY_IDS.add(REQUEST_TYPE_ID);
-
-    // keys
-    KEY_PROPERTY_IDS.put(Resource.Type.Upgrade, UPGRADE_REQUEST_ID);
-    KEY_PROPERTY_IDS.put(Resource.Type.Cluster, UPGRADE_CLUSTER_NAME);
-  }
+  @Inject
+  private UpgradePlanDAO upgradePlanDAO;
 
   private static final Logger LOG = 
LoggerFactory.getLogger(UpgradeResourceProvider.class);
 
@@ -320,6 +322,13 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
     final String clusterName = (String) requestMap.get(UPGRADE_CLUSTER_NAME);
     final Cluster cluster;
 
+    if (!requestMap.containsKey(UPGRADE_PLAN_ID)) {
+      throw new SystemException(String.format("%s must be specified", 
UPGRADE_PLAN_ID));
+    }
+
+    long upgradePlanId = 
Long.valueOf(requestMap.get(UPGRADE_PLAN_ID).toString());
+    final UpgradePlanEntity upgradePlan = 
upgradePlanDAO.findByPK(upgradePlanId);
+
     try {
       cluster = clusters.get().getCluster(clusterName);
     } catch (AmbariException e) {
@@ -341,7 +350,7 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
         final UpgradeContext upgradeContext = 
s_upgradeContextFactory.create(cluster, requestMap);
 
         try {
-          return createUpgrade(upgradeContext);
+          return createUpgrade(upgradeContext, upgradePlan);
         } catch (Exception e) {
           LOG.error("Error appears during upgrade task submitting", e);
 
@@ -655,42 +664,6 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
   }
 
   /**
-   * Inject variables into the
-   * {@link org.apache.ambari.server.orm.entities.UpgradeItemEntity}, whose
-   * tasks may use strings like {{configType/propertyName}} that need to be
-   * retrieved from the properties.
-   *
-   * @param configHelper
-   *          Configuration Helper
-   * @param cluster
-   *          Cluster
-   * @param upgradeItem
-   *          the item whose tasks will be injected.
-   */
-  private void injectVariables(ConfigHelper configHelper, Cluster cluster,
-      UpgradeItemEntity upgradeItem) {
-    final String regexp = "(\\{\\{.*?\\}\\})";
-
-    String task = upgradeItem.getTasks();
-    if (task != null && !task.isEmpty()) {
-      Matcher m = Pattern.compile(regexp).matcher(task);
-      while (m.find()) {
-        String origVar = m.group(1);
-        String configValue = 
configHelper.getPlaceholderValueFromDesiredConfigurations(cluster,
-            origVar);
-
-        if (null != configValue) {
-          task = task.replace(origVar, configValue);
-        } else {
-          LOG.error("Unable to retrieve value for {}", origVar);
-        }
-
-      }
-      upgradeItem.setTasks(task);
-    }
-  }
-
-  /**
    * Creates the upgrade. All Request/Stage/Task and Upgrade entities will 
exist
    * in the database when this method completes.
    * <p/>
@@ -705,16 +678,14 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
    * @throws AmbariException
    * @throws AuthorizationException
    */
-  protected UpgradeEntity createUpgrade(UpgradeContext upgradeContext)
+  protected UpgradeEntity createUpgrade(UpgradeContext upgradeContext, 
UpgradePlanEntity upgradePlan)
       throws AmbariException, AuthorizationException {
 
     UpgradePack pack = upgradeContext.getUpgradePack();
     Cluster cluster = upgradeContext.getCluster();
     Direction direction = upgradeContext.getDirection();
 
-    ConfigHelper configHelper = getManagementController().getConfigHelper();
-
-    List<UpgradeGroupHolder> groups = s_upgradeHelper.createSequence(pack, 
upgradeContext);
+    List<UpgradeGroupHolder> groups = 
s_upgradeHelper.createSequence(upgradeContext, upgradePlan);
 
     if (groups.isEmpty()) {
       throw new AmbariException("There are no groupings available");
@@ -795,7 +766,6 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
             itemEntity.setTasks(wrapper.getTasksJson());
             itemEntity.setHosts(wrapper.getHostsJson());
 
-            injectVariables(configHelper, cluster, itemEntity);
             if (makeServerSideStage(group, upgradeContext, null, req,
                 itemEntity, (ServerSideActionTask) task, configUpgradePack)) {
               itemEntities.add(itemEntity);
@@ -808,8 +778,6 @@ public class UpgradeResourceProvider extends 
AbstractControllerResourceProvider
           itemEntity.setHosts(wrapper.getHostsJson());
           itemEntities.add(itemEntity);
 
-          injectVariables(configHelper, cluster, itemEntity);
-
           // upgrade items match a stage
           createStage(group, upgradeContext, null, req, itemEntity, wrapper);
         }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
index 9e3b5ec..09a06f6 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
@@ -48,6 +48,7 @@ import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
 import 
org.apache.ambari.server.controller.internal.AbstractControllerResourceProvider;
 import 
org.apache.ambari.server.controller.internal.PreUpgradeCheckResourceProvider;
+import org.apache.ambari.server.controller.internal.UpgradeResourceProvider;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.Predicate;
@@ -58,6 +59,7 @@ import 
org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.orm.dao.UpgradeDAO;
+import org.apache.ambari.server.orm.dao.UpgradePlanDAO;
 import org.apache.ambari.server.orm.entities.MpackEntity;
 import org.apache.ambari.server.orm.entities.ServiceGroupEntity;
 import org.apache.ambari.server.orm.entities.UpgradeEntity;
@@ -222,18 +224,25 @@ public class UpgradeContext {
   @Inject
   private Configuration configuration;
 
+  /**
+   * Constructor for {@link UpgradeContextFactory#create(Cluster, Map)} that 
is used
+   * when making an upgrade context from {@link UpgradeResourceProvider}
+   */
   @AssistedInject
   public UpgradeContext(@Assisted Cluster cluster,
-      @Assisted Map<String, Object> upgradeRequestMap, Gson gson, 
UpgradeHelper upgradeHelper,
-      UpgradeDAO upgradeDAO, ConfigHelper configHelper)
+      @Assisted Map<String, Object> upgradeRequestMap, Gson gson,
+      AmbariMetaInfo metaInfo,
+      UpgradeHelper upgradeHelper, UpgradeDAO upgradeDAO, ConfigHelper 
configHelper,
+      UpgradePlanDAO upgradePlanDAO)
       throws AmbariException {
     // injected constructor dependencies
     m_gson = gson;
-    m_upgradeHelper = upgradeHelper;
     m_upgradeDAO = upgradeDAO;
     m_cluster = cluster;
+    m_metaInfo = metaInfo;
     m_isRevert = upgradeRequestMap.containsKey(UPGRADE_REVERT_UPGRADE_ID);
 
+
     if (m_isRevert) {
       m_revertUpgradeId = 
Long.valueOf(upgradeRequestMap.get(UPGRADE_REVERT_UPGRADE_ID).toString());
       UpgradeEntity revertUpgrade = 
m_upgradeDAO.findUpgrade(m_revertUpgradeId);
@@ -292,7 +301,13 @@ public class UpgradeContext {
       // !!! direction can ONLY be an downgrade on revert
       m_direction = Direction.DOWNGRADE;
     } else {
-      UpgradePlanEntity upgradePlan = null;
+      if (!upgradeRequestMap.containsKey(UPGRADE_PLAN_ID)) {
+        throw new AmbariException("An upgrade can only be started from an 
Upgrade Plan.");
+      }
+
+      Long upgradePlanId = 
Long.valueOf(upgradeRequestMap.get(UPGRADE_PLAN_ID).toString());
+      UpgradePlanEntity upgradePlan = upgradePlanDAO.findByPK(upgradePlanId);
+
       m_direction = upgradePlan.getDirection();
 
       // depending on the direction, we must either have a target repository 
or an upgrade we are downgrading from
@@ -341,8 +356,8 @@ public class UpgradeContext {
     // optionally skip failures - this can be supplied on either the request or
     // in the upgrade pack explicitely, however the request will always 
override
     // the upgrade pack if explicitely specified
-    boolean skipComponentFailures = 
m_upgradePack.isComponentFailureAutoSkipped();
-    boolean skipServiceCheckFailures = 
m_upgradePack.isServiceCheckFailureAutoSkipped();
+    boolean skipComponentFailures = false;
+    boolean skipServiceCheckFailures = false;
 
     // only override the upgrade pack if set on the request
     if (upgradeRequestMap.containsKey(UPGRADE_SKIP_FAILURES)) {
@@ -370,7 +385,8 @@ public class UpgradeContext {
   }
 
   /**
-   * Constructor.
+   * Constructor for {@link UpgradeContextFactory#create(Cluster, 
UpgradeEntity)} that
+   * loads an upgrade context from storage.
    *
    * @param cluster
    *          the cluster that the upgrade is for
@@ -782,7 +798,7 @@ public class UpgradeContext {
    * @throws AmbariException
    */
   private UpgradeType calculateUpgradeType(Map<String, Object> 
upgradeRequestMap,
-                                           UpgradeEntity upgradeEntity) throws 
AmbariException{
+                                           UpgradeEntity upgradeEntity) throws 
AmbariException {
 
     UpgradeType upgradeType = UpgradeType.ROLLING;
 
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java 
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
index cedab34..ea559bc 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
@@ -35,6 +35,7 @@ import java.util.stream.Collectors;
 import org.apache.ambari.annotations.Experimental;
 import org.apache.ambari.annotations.ExperimentalFeature;
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.StackAccessException;
 import org.apache.ambari.server.agent.stomp.AgentConfigsHolder;
 import org.apache.ambari.server.agent.stomp.MetadataHolder;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -62,6 +63,7 @@ import org.apache.ambari.server.orm.dao.StackDAO;
 import org.apache.ambari.server.orm.entities.ClusterConfigEntity;
 import org.apache.ambari.server.orm.entities.ServiceConfigEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
+import org.apache.ambari.server.orm.entities.UpgradePlanEntity;
 import org.apache.ambari.server.stack.HostsType;
 import org.apache.ambari.server.stack.MasterHostResolver;
 import org.apache.ambari.server.state.stack.UpgradePack;
@@ -305,29 +307,82 @@ public class UpgradeHelper {
    return pack;
   }
 
+  /**
+   * Generates a list of UpgradeGroupHolder items that are used to execute 
either
+   * an upgrade or a downgrade.  Each lifecycle is processed one-by-one from 
the upgrade packs
+   *
+   * @param context
+   *          the upgrade context
+   * @param upgradePlan
+   *          the upgrade plan to execute
+   */
+  public List<UpgradeGroupHolder> createSequence(UpgradeContext context,
+      UpgradePlanEntity upgradePlan) throws AmbariException {
+
+    // !!! TODO there is a ton of work to do here for merging upgrade packs 
across lifecycles
+
+    List<UpgradeGroupHolder> groups = new ArrayList<>();
+
+    for (LifecycleType lifecycle : LifecycleType.ordered()) {
+
+      upgradePlan.getDetails().forEach(detail -> {
+        long mpackId = detail.getMpackTargetId();
+        StackId stackId = 
m_ambariMetaInfoProvider.get().getMpack(mpackId).getStackId();
+        final StackInfo stack;
+        try {
+          stack = m_ambariMetaInfoProvider.get().getStack(stackId);
+        } catch (StackAccessException e) {
+          LOG.info("Cannot access stack ");
+          return;
+        }
+        String upgradePackName = detail.getUpgradePack();
+
+        UpgradePack upgradePack = stack.getUpgradePacks().get(upgradePackName);
+        if (null == upgradePack) {
+          throw new IllegalArgumentException(
+              String.format("Upgrade detail cannot find upgrade pack %s for 
%s", upgradePackName, stackId));
+        }
+
+        try {
+          groups.addAll(createSequence(context, upgradePack, lifecycle));
+        } catch (AmbariException e) {
+          throw new IllegalArgumentException(e);
+        }
+      });
+    }
+
+    return groups;
+  }
 
   /**
    * Generates a list of UpgradeGroupHolder items that are used to execute 
either
    * an upgrade or a downgrade.
    *
-   * @param upgradePack
-   *          the upgrade pack
    * @param context
    *          the context that wraps key fields required to perform an upgrade
+   * @param upgradePack
+   *          the upgrade pack
+   * @param lifecycleType
+   *          the lifecycle type to search
    * @return the list of holders
    */
-  public List<UpgradeGroupHolder> createSequence(UpgradePack upgradePack,
-      UpgradeContext context) throws AmbariException {
+  private List<UpgradeGroupHolder> createSequence(UpgradeContext context, 
UpgradePack upgradePack,
+      LifecycleType lifecycleType) throws AmbariException {
 
     Cluster cluster = context.getCluster();
     MasterHostResolver mhr = context.getResolver();
 
+    List<Grouping> groupings = upgradePack.getGroups(lifecycleType, 
context.getDirection());
+    if (groupings.isEmpty()) {
+      return Collections.emptyList();
+    }
+
     // Note, only a Rolling Upgrade uses processing tasks.
     Map<String, Map<String, ProcessingComponent>> allTasks = 
upgradePack.getTasks();
     List<UpgradeGroupHolder> groups = new ArrayList<>();
 
     UpgradeGroupHolder previousGroupHolder = null;
-    for (Grouping group : upgradePack.getGroups(LifecycleType.UPGRADE, 
context.getDirection())) {
+    for (Grouping group : groupings) {
 
       // if there is a condition on the group, evaluate it and skip scheduling
       // of this group if the condition has not been satisfied
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
index 3841497..8286c70 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
@@ -103,12 +103,6 @@ public class UpgradePack {
   @XmlElement(name = "downgrade-allowed", required = false)
   private boolean downgradeAllowed = true;
 
-  /**
-   * {@code true} to automatically skip service check failures. The default is
-   * {@code false}.
-   */
-  @XmlElement(name = "skip-service-check-failures")
-  private boolean skipServiceCheckFailures = false;
 
   @XmlTransient
   private Map<String, List<String>> m_orders = null;
@@ -188,25 +182,6 @@ public class UpgradePack {
   }
 
   /**
-   * Gets whether skippable components that failed are automatically skipped.
-   *
-   * @return the skipComponentFailures
-   */
-  public boolean isComponentFailureAutoSkipped() {
-    return skipFailures;
-  }
-
-  /**
-   * Gets whether skippable service checks that failed are automatically
-   * skipped.
-   *
-   * @return the skipServiceCheckFailures
-   */
-  public boolean isServiceCheckFailureAutoSkipped() {
-    return skipServiceCheckFailures;
-  }
-
-  /**
    * Used to get all groups defined for an upgrade.  This method is deprecated 
as orchestration
    * will change to per-lifecycle.  At the time of writing, keep this for 
compilation purposes.
    * @return
diff --git 
a/ambari-server/src/main/resources/custom_actions/scripts/mpack_packages.py 
b/ambari-server/src/main/resources/custom_actions/scripts/mpack_packages.py
index f956075..98589ae 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/mpack_packages.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/mpack_packages.py
@@ -103,7 +103,6 @@ class MpackPackages(Script):
       raise Fail("Failed to distribute repositories/install packages")
 
     # Initial list of versions, used to compute the new version installed
-
     try:
       ret_code = self.install_packages(package_list)
 
@@ -137,6 +136,8 @@ class MpackPackages(Script):
     packages_installed_before = []
 
     try:
+      Script.repository_util.create_repo_files()
+
       repositories = config['repositoryFile']['repositories']
       command_repos = CommandRepository(config['repositoryFile'])
       repository_ids = [repository['repoId'] for repository in repositories]
diff --git a/ambari-server/src/main/resources/upgrade-pack.xsd 
b/ambari-server/src/main/resources/upgrade-pack.xsd
index 9f3005e..27baeaf 100644
--- a/ambari-server/src/main/resources/upgrade-pack.xsd
+++ b/ambari-server/src/main/resources/upgrade-pack.xsd
@@ -406,8 +406,6 @@
       <xs:sequence>
         <xs:element name="target" type="xs:string" />
         <xs:element name="target-stack" type="xs:string" />
-        <xs:element name="skip-failures" minOccurs="0" type="xs:boolean" />
-        <xs:element name="skip-service-check-failures" minOccurs="0" 
type="xs:boolean" />
         <xs:element name="downgrade-allowed" minOccurs="0" type="xs:boolean" />
         <xs:element name="type" type="upgrade-kind-type" />
         <xs:element name="prerequisite-checks" type="prerequisite-check-type" 
minOccurs="0" />
diff --git 
a/ambari-server/src/test/resources/mpacks-v2/upgrade-packs/upgrade-basic.xml 
b/ambari-server/src/test/resources/mpacks-v2/upgrade-packs/upgrade-basic.xml
index e948534..c1ee1dd 100644
--- a/ambari-server/src/test/resources/mpacks-v2/upgrade-packs/upgrade-basic.xml
+++ b/ambari-server/src/test/resources/mpacks-v2/upgrade-packs/upgrade-basic.xml
@@ -19,8 +19,6 @@
 <upgrade xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:noNamespaceSchemaLocation="upgrade-pack.xsd">
   <target>2.6.*.*</target>
   <target-stack>HDP-2.6</target-stack>
-  <skip-failures>false</skip-failures>
-  <skip-service-check-failures>false</skip-service-check-failures>
   <type>rolling</type>
   
   <prerequisite-checks>
@@ -474,7 +472,6 @@
   <lifecycle type="finalize">
     <order>
       <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>

Reply via email to