You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2018/05/24 17:13:53 UTC

[ambari] branch trunk updated: [AMBARI-23946]. Stack upgrade from 2.6.5 to 3.0.0 fails because WebHCat component doesn't exist

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

ncole pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 44ddda4  [AMBARI-23946]. Stack upgrade from 2.6.5 to 3.0.0 fails because WebHCat component doesn't exist
44ddda4 is described below

commit 44ddda469fb605ae82dd062cdc17efbc0323a738
Author: Nate Cole <nc...@hortonworks.com>
AuthorDate: Thu May 24 11:58:24 2018 -0400

    [AMBARI-23946]. Stack upgrade from 2.6.5 to 3.0.0 fails because WebHCat component doesn't exist
---
 .../server/agent/stomp/AgentReportsController.java |  2 +-
 .../server/controller/ActionExecutionContext.java  | 21 +++++----
 .../AmbariCustomCommandExecutionHelper.java        |  4 +-
 .../ClusterStackVersionResourceProvider.java       |  4 +-
 .../internal/HostStackVersionResourceProvider.java |  4 +-
 .../internal/UpgradeResourceProvider.java          | 52 +++++++++++++---------
 .../apache/ambari/server/state/ConfigHelper.java   |  8 +++-
 .../apache/ambari/server/state/UpgradeContext.java | 27 +++++++++++
 .../stack/upgrade/RepositoryVersionHelper.java     |  8 ++--
 9 files changed, 86 insertions(+), 44 deletions(-)

diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentReportsController.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentReportsController.java
index 885b308..1ba0063 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentReportsController.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/stomp/AgentReportsController.java
@@ -105,7 +105,7 @@ public class AgentReportsController {
   public ReportsResponse handleAlertsStatus(@Header String simpSessionId, Alert[] message) throws AmbariException {
     String hostName = agentSessionManager.getHost(simpSessionId).getHostName();
     List<Alert> alerts = Arrays.asList(message);
-    LOG.info("Handling {} alerts status for host {}", alerts.size(), hostName);
+    LOG.debug("Handling {} alerts status for host {}", alerts.size(), hostName);
     hh.getHeartbeatProcessor().processAlerts(hostName, alerts);
     return new ReportsResponse();
   }
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
index b677e7f..e7a6430 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ActionExecutionContext.java
@@ -27,7 +27,7 @@ import org.apache.ambari.server.actionmanager.TargetHostType;
 import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.controller.internal.RequestOperationLevel;
 import org.apache.ambari.server.controller.internal.RequestResourceFilter;
-import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
+import org.apache.ambari.server.state.StackId;
 
 /**
  * The context required to create tasks and stages for a custom action
@@ -44,7 +44,7 @@ public class ActionExecutionContext {
   private String expectedComponentName;
   private boolean hostsInMaintenanceModeExcluded = true;
   private boolean allowRetry = false;
-  private RepositoryVersionEntity repositoryVersion;
+  private StackId stackId;
 
   /**
    * If {@code true}, instructs Ambari not to worry about whether or not the
@@ -182,31 +182,30 @@ public class ActionExecutionContext {
   }
 
   /**
-   * Gets the stack/version to use for generating stack-associated values for a
+   * Gets the stack to use for generating stack-associated values for a
    * command. In some cases the cluster's stack is not the correct one to use,
    * such as when distributing a repository.
    *
-   * @return the repository for the stack/version to use when generating
+   * @return the stack to use when generating
    *         stack-specific content for the command.
-   *
-   * @return
    */
-  public RepositoryVersionEntity getRepositoryVersion() {
-    return repositoryVersion;
+  public StackId getStackId() {
+    return stackId;
   }
 
   /**
-   * Sets the stack/version to use for generating stack-associated values for a
+   * Sets the stack to use for generating stack-associated values for a
    * command. In some cases the cluster's stack is not the correct one to use,
    * such as when distributing a repository.
    *
    * @param stackId
    *          the stackId to use for stack-based properties on the command.
    */
-  public void setRepositoryVersion(RepositoryVersionEntity repositoryVersion) {
-    this.repositoryVersion = repositoryVersion;
+  public void setStackId(StackId stackId) {
+    this.stackId = stackId;
   }
 
+
   /**
    * Adds a command visitor that will be invoked after a command is created.  Provides access
    * to the command.
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index 982f627..4c69991 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -321,8 +321,8 @@ public class AmbariCustomCommandExecutionHelper {
 
     // grab the stack ID from the service first, and use the context's if it's set
     StackId stackId = service.getDesiredStackId();
-    if (null != actionExecutionContext.getRepositoryVersion()) {
-      stackId = actionExecutionContext.getRepositoryVersion().getStackId();
+    if (null != actionExecutionContext.getStackId()) {
+      stackId = actionExecutionContext.getStackId();
     }
 
     AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
index 8358525..c9a826f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
@@ -722,10 +722,10 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
     ActionExecutionContext actionContext = new ActionExecutionContext(cluster.getClusterName(),
         INSTALL_PACKAGES_ACTION, Collections.singletonList(filter), roleParams);
 
-    actionContext.setRepositoryVersion(repoVersion);
+    actionContext.setStackId(repoVersion.getStackId());
     actionContext.setTimeout(Short.valueOf(configuration.getDefaultAgentTaskTimeout(true)));
 
-    repoVersionHelper.addCommandRepositoryToContext(actionContext, osEntity);
+    repoVersionHelper.addCommandRepositoryToContext(actionContext, repoVersion, osEntity);
 
     return actionContext;
   }
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
index 707337d..ae3e2f9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
@@ -446,9 +446,9 @@ public class HostStackVersionResourceProvider extends AbstractControllerResource
             Collections.singletonList(filter),
             roleParams);
     actionContext.setTimeout(Short.valueOf(configuration.getDefaultAgentTaskTimeout(true)));
-    actionContext.setRepositoryVersion(repoVersionEnt);
+    actionContext.setStackId(repoVersionEnt.getStackId());
 
-    repoVersionHelper.addCommandRepositoryToContext(actionContext, osEntity);
+    repoVersionHelper.addCommandRepositoryToContext(actionContext, repoVersionEnt, osEntity);
 
     String caption = String.format(INSTALL_PACKAGES_FULL_NAME + " on host %s", hostName);
     RequestStageContainer req = createRequest(caption);
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 c00121b..6cf87d3 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
@@ -800,12 +800,24 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     // HDP 2.2 to 2.4 should start with HDP 2.2 and merge in HDP 2.3's config-upgrade.xml
     ConfigUpgradePack configUpgradePack = ConfigurationPackBuilder.build(upgradeContext);
 
+    // !!! effectiveStack in an EU must start as the source stack, since we're generating
+    // commands for the "old" version
+    StackId effectiveStack = upgradeContext.getTargetStack();
+    if (upgradeContext.getType() == UpgradeType.NON_ROLLING) {
+      effectiveStack = upgradeContext.getSourceStack();
+    }
+
     // create the upgrade and request
     for (UpgradeGroupHolder group : groups) {
+
+      if (upgradeContext.getType() == UpgradeType.NON_ROLLING
+          && UpdateStackGrouping.class.equals(group.groupClass)) {
+        effectiveStack = upgradeContext.getTargetStack();
+      }
+
       List<UpgradeItemEntity> itemEntities = new ArrayList<>();
 
       for (StageWrapper wrapper : group.items) {
-        RepositoryVersionEntity effectiveRepositoryVersion = upgradeContext.getRepositoryVersion();
 
         switch(wrapper.getType()) {
           case SERVER_SIDE_ACTION:{
@@ -826,7 +838,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
                 itemEntity.setHosts(wrapper.getHostsJson());
 
                 injectVariables(configHelper, cluster, itemEntity);
-                if (makeServerSideStage(group, upgradeContext, effectiveRepositoryVersion, req,
+                if (makeServerSideStage(group, upgradeContext, effectiveStack, req,
                     itemEntity, (ServerSideActionTask) task, configUpgradePack)) {
                   itemEntities.add(itemEntity);
                 }
@@ -883,7 +895,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
             injectVariables(configHelper, cluster, itemEntity);
 
             // upgrade items match a stage
-            createStage(group, upgradeContext, effectiveRepositoryVersion, req, itemEntity, wrapper);
+            createStage(group, upgradeContext, effectiveStack, req, itemEntity, wrapper);
 
             break;
           }
@@ -970,7 +982,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   }
 
   private void createStage(UpgradeGroupHolder group, UpgradeContext context,
-      RepositoryVersionEntity effectiveRepositoryVersion,
+      StackId stackId,
       RequestStageContainer request, UpgradeItemEntity entity, StageWrapper wrapper)
           throws AmbariException {
 
@@ -983,15 +995,15 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
       case START:
       case STOP:
       case RESTART:
-        makeCommandStage(context, request, effectiveRepositoryVersion, entity, wrapper, skippable,
+        makeCommandStage(context, request, stackId, entity, wrapper, skippable,
             supportsAutoSkipOnFailure, allowRetry);
         break;
       case UPGRADE_TASKS:
-        makeActionStage(context, request, effectiveRepositoryVersion, entity, wrapper, skippable,
+        makeActionStage(context, request, stackId, entity, wrapper, skippable,
             supportsAutoSkipOnFailure, allowRetry);
         break;
       case SERVICE_CHECK:
-        makeServiceCheckStage(context, request, effectiveRepositoryVersion, entity, wrapper,
+        makeServiceCheckStage(context, request, stackId, entity, wrapper,
             skippable, supportsAutoSkipOnFailure, allowRetry);
         break;
       default:
@@ -1041,7 +1053,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
    * @throws AmbariException
    */
   private void makeActionStage(UpgradeContext context, RequestStageContainer request,
-      RepositoryVersionEntity effectiveRepositoryVersion, UpgradeItemEntity entity,
+      StackId stackId, UpgradeItemEntity entity,
       StageWrapper wrapper, boolean skippable, boolean supportsAutoSkipOnFailure,
       boolean allowRetry) throws AmbariException {
 
@@ -1093,11 +1105,11 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
         new ArrayList<>(wrapper.getHosts()));
 
     ActionExecutionContext actionContext = buildActionExecutionContext(cluster, context,
-        EXECUTE_TASK_ROLE, effectiveRepositoryVersion, Collections.singletonList(filter), params,
+        EXECUTE_TASK_ROLE, stackId, Collections.singletonList(filter), params,
         allowRetry, wrapper.getMaxTimeout(s_configuration));
 
     ExecuteCommandJson jsons = s_commandExecutionHelper.get().getCommandJson(actionContext,
-        cluster, effectiveRepositoryVersion.getStackId(), null);
+        cluster, stackId, null);
 
     Stage stage = s_stageFactory.get().createNew(request.getId().longValue(), "/tmp/ambari",
         cluster.getClusterName(), cluster.getClusterId(), entity.getText(), jsons.getCommandParamsForStage(),
@@ -1137,7 +1149,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
    * @throws AmbariException
    */
   private void makeCommandStage(UpgradeContext context, RequestStageContainer request,
-      RepositoryVersionEntity effectiveRepositoryVersion, UpgradeItemEntity entity,
+      StackId stackId, UpgradeItemEntity entity,
       StageWrapper wrapper, boolean skippable, boolean supportsAutoSkipOnFailure,
       boolean allowRetry) throws AmbariException {
 
@@ -1174,7 +1186,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     applyAdditionalParameters(wrapper, commandParams);
 
     ActionExecutionContext actionContext = buildActionExecutionContext(cluster, context, function,
-        effectiveRepositoryVersion, filters, commandParams, allowRetry,
+        stackId, filters, commandParams, allowRetry,
         wrapper.getMaxTimeout(s_configuration));
 
     // commands created here might be for future components which have not been
@@ -1182,7 +1194,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     actionContext.setIsFutureCommand(true);
 
     ExecuteCommandJson jsons = s_commandExecutionHelper.get().getCommandJson(actionContext,
-        cluster, effectiveRepositoryVersion.getStackId(), null);
+        cluster, stackId, null);
 
     Stage stage = s_stageFactory.get().createNew(request.getId().longValue(), "/tmp/ambari",
         cluster.getClusterName(), cluster.getClusterId(), entity.getText(), jsons.getCommandParamsForStage(),
@@ -1214,7 +1226,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
   }
 
   private void makeServiceCheckStage(UpgradeContext context, RequestStageContainer request,
-      RepositoryVersionEntity effectiveRepositoryVersion, UpgradeItemEntity entity,
+      StackId stackId, UpgradeItemEntity entity,
       StageWrapper wrapper, boolean skippable, boolean supportsAutoSkipOnFailure,
       boolean allowRetry) throws AmbariException {
 
@@ -1232,11 +1244,11 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     applyAdditionalParameters(wrapper, commandParams);
 
     ActionExecutionContext actionContext = buildActionExecutionContext(cluster, context,
-        "SERVICE_CHECK", effectiveRepositoryVersion, filters, commandParams, allowRetry,
+        "SERVICE_CHECK", stackId, filters, commandParams, allowRetry,
         wrapper.getMaxTimeout(s_configuration));
 
     ExecuteCommandJson jsons = s_commandExecutionHelper.get().getCommandJson(actionContext,
-        cluster, effectiveRepositoryVersion.getStackId(), null);
+        cluster, stackId, null);
 
     Stage stage = s_stageFactory.get().createNew(request.getId().longValue(), "/tmp/ambari",
         cluster.getClusterName(), cluster.getClusterId(), entity.getText(), jsons.getCommandParamsForStage(),
@@ -1271,7 +1283,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
    * @throws AmbariException
    */
   private boolean makeServerSideStage(UpgradeGroupHolder group, UpgradeContext context,
-      RepositoryVersionEntity effectiveRepositoryVersion, RequestStageContainer request,
+      StackId stackId, RequestStageContainer request,
       UpgradeItemEntity entity, ServerSideActionTask task, ConfigUpgradePack configUpgradePack)
       throws AmbariException {
 
@@ -1407,7 +1419,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
     }
 
     ActionExecutionContext actionContext = buildActionExecutionContext(cluster, context,
-        Role.AMBARI_SERVER_ACTION.toString(), effectiveRepositoryVersion, Collections.emptyList(),
+        Role.AMBARI_SERVER_ACTION.toString(), stackId, Collections.emptyList(),
         commandParams, group.allowRetry, Short.valueOf((short) -1));
 
     ExecuteCommandJson jsons = s_commandExecutionHelper.get().getCommandJson(actionContext,
@@ -1628,14 +1640,14 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
    * @return the {@link ActionExecutionContext}.
    */
   private ActionExecutionContext buildActionExecutionContext(Cluster cluster,
-      UpgradeContext context, String role, RepositoryVersionEntity repositoryVersion,
+      UpgradeContext context, String role, StackId stackId,
       List<RequestResourceFilter> resourceFilters, Map<String, String> commandParams,
       boolean allowRetry, short timeout) {
 
     ActionExecutionContext actionContext = new ActionExecutionContext(cluster.getClusterName(),
         role, resourceFilters, commandParams);
 
-    actionContext.setRepositoryVersion(repositoryVersion);
+    actionContext.setStackId(stackId);
     actionContext.setTimeout(timeout);
     actionContext.setRetryAllowed(allowRetry);
     actionContext.setAutoSkipFailures(context.isComponentFailureAutoSkipped());
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
index 4e5fba5..5d30436 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
@@ -870,6 +870,12 @@ public class ConfigHelper {
     }
 
     for (Service service : cluster.getServices().values()) {
+      // !!! the services map is from the stack, which may not contain services in the cluster.
+      // This is the case for upgrades where the target stack may remove services
+      if (!servicesMap.containsKey(service.getName())) {
+        continue;
+      }
+
       Set<PropertyInfo> serviceProperties = new HashSet<>(servicesMap.get(service.getName()).getProperties());
       for (PropertyInfo serviceProperty : serviceProperties) {
         if (serviceProperty.getPropertyTypes().contains(propertyType)) {
@@ -1476,7 +1482,7 @@ public class ConfigHelper {
       }
       stale = stale | staleEntry;
     }
-    
+
     String refreshCommand = calculateRefreshCommand(stackInfo.getRefreshCommandConfiguration(), sch, changedProperties);
 
     if (STALE_CONFIGS_CACHE_ENABLED) {
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 1515ded..d5fd729 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
@@ -998,6 +998,33 @@ public class UpgradeContext {
   }
 
   /**
+   * Gets the single target stack for the upgrade.  By definition, ALL the targets,
+   * despite the versions, should have the same stack.  The source stacks may be different
+   * from the target, but all the source stacks must also be the same.
+   * <p/>
+   *
+   * @return the target stack for this upgrade (never {@code null}).
+   */
+  public StackId getTargetStack() {
+    RepositoryVersionEntity repo = m_targetRepositoryMap.values().iterator().next();
+    return repo.getStackId();
+  }
+
+  /**
+   * Gets the single source stack for the upgrade depending on the
+   * direction.  By definition, ALL the source stacks, despite the versions, should have
+   * the same stack.  The target stacks may be different from the source, but all the target
+   * stacks must also be the same.
+   * <p/>
+   *
+   * @return the source stack for this upgrade (never {@code null}).
+   */
+  public StackId getSourceStack() {
+    RepositoryVersionEntity repo = m_sourceRepositoryMap.values().iterator().next();
+    return repo.getStackId();
+  }
+
+  /**
    * Gets the set of services which will participate in the upgrade. The
    * services available in the repository are comapred against those installed
    * in the cluster to arrive at the final subset.
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
index e9f21dc..d3f442e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/RepositoryVersionHelper.java
@@ -453,8 +453,8 @@ public class RepositoryVersionHelper {
     // host params and then return
     if (null == repositoryVersion) {
       // see if the action context has a repository set to use for the command
-      if (null != actionContext.getRepositoryVersion()) {
-        StackId stackId = actionContext.getRepositoryVersion().getStackId();
+      if (null != actionContext.getStackId()) {
+        StackId stackId = actionContext.getStackId();
         hostLevelParams.put(KeyNames.STACK_NAME, stackId.getStackName());
         hostLevelParams.put(KeyNames.STACK_VERSION, stackId.getStackVersion());
       }
@@ -574,9 +574,8 @@ public class RepositoryVersionHelper {
    * @param osEntity      the OS family
    */
   public void addCommandRepositoryToContext(ActionExecutionContext context,
-                                            RepoOsEntity osEntity) throws SystemException {
+      final RepositoryVersionEntity repoVersion, RepoOsEntity osEntity) throws SystemException {
 
-    final RepositoryVersionEntity repoVersion = context.getRepositoryVersion();
     final CommandRepository commandRepo = getCommandRepository(repoVersion, osEntity);
 
     ClusterVersionSummary summary = null;
@@ -594,7 +593,6 @@ public class RepositoryVersionHelper {
 
     final ClusterVersionSummary clusterSummary = summary;
 
-
     context.addVisitor(command -> {
       if (null == command.getRepositoryFile()) {
         command.setRepositoryFile(commandRepo);

-- 
To stop receiving notification emails like this one, please contact
ncole@apache.org.