Repository: ambari Updated Branches: refs/heads/branch-2.4 80adb61a4 -> 9357758eb
AMBARI-17151. Blueprint deployments fail when services manually removed from stack definitions. (rnettleton) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9357758e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9357758e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9357758e Branch: refs/heads/branch-2.4 Commit: 9357758eb3bb7c4045842703ca8aa43e44db86cb Parents: 80adb61 Author: Bob Nettleton <[email protected]> Authored: Fri Jun 10 17:25:23 2016 -0400 Committer: Bob Nettleton <[email protected]> Committed: Fri Jun 10 17:25:23 2016 -0400 ---------------------------------------------------------------------- .../BlueprintConfigurationProcessor.java | 15 ++++++- .../BlueprintConfigurationProcessorTest.java | 45 ++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9357758e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java index de70a2c..ac0b836 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java @@ -2778,7 +2778,20 @@ public class BlueprintConfigurationProcessor { for(String configType: excludedConfigTypes) { LOG.debug("Handling excluded config type [{}] for blueprint service: [{}]", configType, blueprintService); - String blueprintServiceForExcludedConfig = stack.getServiceForConfigType(configType); + String blueprintServiceForExcludedConfig; + + try { + blueprintServiceForExcludedConfig = stack.getServiceForConfigType(configType); + } catch (IllegalArgumentException illegalArgumentException) { + LOG.warn("Error encountered while trying to obtain the service name for config type [" + configType + + "]. Further processing on this excluded config type will be skipped. " + + "This usually means that a service's definitions have been manually removed from the Ambari stack definitions. " + + "If the stack definitions have not been changed manually, this may indicate a stack definition error in Ambari. ", illegalArgumentException); + // skip this type for any further processing + continue; + } + + if (!blueprintServices.contains(blueprintServiceForExcludedConfig)) { LOG.debug("Service [{}] for excluded config type [{}] is not present in the blueprint. " + "Ignoring excluded config entries.", blueprintServiceForExcludedConfig, configType); http://git-wip-us.apache.org/repos/asf/ambari/blob/9357758e/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java index 9ec0a09..ae28bc0 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessorTest.java @@ -4186,6 +4186,51 @@ public class BlueprintConfigurationProcessorTest { } @Test + public void testExcludedPropertiesHandlingWhenExcludedConfigServiceIsNotFoundInStack() throws Exception { + reset(stack); + + // defaults from init() method that we need + expect(stack.getName()).andReturn("testStack").anyTimes(); + expect(stack.getVersion()).andReturn("1").anyTimes(); + expect(stack.isMasterComponent((String) anyObject())).andReturn(false).anyTimes(); + + // customized stack calls for this test only + Set<String> excludedConfigTypes = new HashSet<String>(); + excludedConfigTypes.add("oozie-site"); + excludedConfigTypes.add("storm-site"); + expect(stack.getExcludedConfigurationTypes("FALCON")).andReturn(excludedConfigTypes); + expect(stack.getExcludedConfigurationTypes("OOZIE")).andReturn(Collections.<String>emptySet()); + expect(stack.getConfigurationProperties("FALCON", "oozie-site")).andReturn(Collections.singletonMap("oozie.service.ELService.ext.functions.coord-job-submit-instances", "testValue")).anyTimes(); + expect(stack.getServiceForConfigType("oozie-site")).andReturn("OOZIE").anyTimes(); + // simulate the case where the STORM service has been removed manually from the stack definitions + expect(stack.getServiceForConfigType("storm-site")).andThrow(new IllegalArgumentException("TEST: Configuration not found in stack definitions!")); + + Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>(); + Configuration clusterConfig = new Configuration(properties, Collections.<String, Map<String, Map<String, String>>>emptyMap()); + + Collection<String> hgComponents = new HashSet<String>(); + hgComponents.add("FALCON_SERVER"); + hgComponents.add("FALCON_CLIENT"); + hgComponents.add("OOZIE_SERVER"); + hgComponents.add("OOZIE_CLIENT"); + List<String> hosts = new ArrayList<String>(); + hosts.add("c6401.apache.ambari.org"); + hosts.add("serverTwo"); + TestHostGroup group1 = new TestHostGroup("host_group_1", hgComponents, hosts); + + Collection<TestHostGroup> hostGroups = new HashSet<TestHostGroup>(); + hostGroups.add(group1); + + ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups); + BlueprintConfigurationProcessor updater = new BlueprintConfigurationProcessor(topology); + + updater.doUpdateForClusterCreate(); + + assertEquals("Falcon Broker URL property not properly exported", + "testValue", clusterConfig.getPropertyValue("oozie-site", "oozie.service.ELService.ext.functions.coord-job-submit-instances")); + } + + @Test public void testFalconConfigClusterUpdate() throws Exception { final String expectedHostName = "c6401.apache.ambari.org"; final String expectedPortNum = "808080";
