You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rn...@apache.org on 2016/06/10 21:16:26 UTC

ambari git commit: AMBARI-17151. Blueprint deployments fail when services manually removed from stack definitions. (rnettleton)

Repository: ambari
Updated Branches:
  refs/heads/trunk 07f94cb7a -> e0dd3bf62


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/e0dd3bf6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e0dd3bf6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e0dd3bf6

Branch: refs/heads/trunk
Commit: e0dd3bf6218fc8c2733e936aa24bfc87fd60739e
Parents: 07f94cb
Author: Bob Nettleton <rn...@hortonworks.com>
Authored: Fri Jun 10 17:15:32 2016 -0400
Committer: Bob Nettleton <rn...@hortonworks.com>
Committed: Fri Jun 10 17:16:17 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/e0dd3bf6/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/e0dd3bf6/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";