This is an automated email from the ASF dual-hosted git repository. adoroszlai 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 ab3e2b6 AMBARI-25041. Scale hosts does not install component if service is in maintenance mode (#2720) ab3e2b6 is described below commit ab3e2b6f17057cbe78d5e3f9385b83394c2aca6a Author: Doroszlai, Attila <6454655+adorosz...@users.noreply.github.com> AuthorDate: Thu Dec 13 16:37:12 2018 +0100 AMBARI-25041. Scale hosts does not install component if service is in maintenance mode (#2720) --- .../internal/HostComponentResourceProvider.java | 6 +++++- .../controller/internal/RequestOperationLevel.java | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java index 7cb532a..8ba2623 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java @@ -396,6 +396,9 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro Map<String, String> requestInfo = new HashMap<>(); requestInfo.put("context", String.format("Install components on host %s", hostname)); requestInfo.put(CLUSTER_PHASE_PROPERTY, CLUSTER_PHASE_INITIAL_INSTALL); + // although the operation is really for a specific host, the level needs to be set to HostComponent + // to make sure that any service in maintenance mode does not prevent install/start on the new host during scale-up + requestInfo.putAll(RequestOperationLevel.propertiesFor(Resource.Type.HostComponent, cluster)); addProvisionActionProperties(skipInstallForComponents, dontSkipInstallForComponents, requestInfo); Request installRequest = PropertyHelper.getUpdateRequest(installProperties, requestInfo); @@ -469,6 +472,8 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro Map<String, String> requestInfo = new HashMap<>(); requestInfo.put("context", String.format("Start components on host %s", hostName)); requestInfo.put(CLUSTER_PHASE_PROPERTY, CLUSTER_PHASE_INITIAL_START); + // see rationale for marking the operation as HostComponent-level at "Install components on host" + requestInfo.putAll(RequestOperationLevel.propertiesFor(Resource.Type.HostComponent, cluster)); requestInfo.put(Setting.SETTING_NAME_SKIP_FAILURE, Boolean.toString(skipFailure)); Predicate clusterPredicate = new EqualsPredicate<>(CLUSTER_NAME, cluster); @@ -532,7 +537,6 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro return requestStages.getRequestStatusResponse(); } - /** * Update the host component identified by the given request object with the * values carried by the given request object. diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java index ed43722..2e1e18e 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java @@ -21,6 +21,8 @@ import java.util.Map; import org.apache.ambari.server.controller.spi.Resource; +import com.google.common.collect.ImmutableMap; + /** * Operation level is specified along with some requests. It identifies * the logical level, at which the operation is executed. @@ -183,4 +185,23 @@ public class RequestOperationLevel { ", hostName='" + hostName + '\'' + '}'; } + + /** + * Create a map of required properties to be added to a request info map which is + * then used to create a {@link RequestOperationLevel} object. + * Other properties (service name, host name, host component name) can be set on + * the request info map itself as needed. + * + * @param type resource type for which to calculate the operation level + * @param clusterName cluster name + * @return immutable map with required properties: operation level and cluster name + * @throws IllegalArgumentException if the given resource {@code type} is not mapped to any operation level + */ + public static Map<String, String> propertiesFor(Resource.Type type, String clusterName) { + return ImmutableMap.of( + OPERATION_LEVEL_ID, getExternalLevelName(type.name()), + OPERATION_CLUSTER_ID, clusterName + ); + } + }