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 2015/06/04 00:00:35 UTC
ambari git commit: AMBARI-11659. Blueprint processor filters should
have better error handling for invalid configuration types. (rnettleton)
Repository: ambari
Updated Branches:
refs/heads/trunk 01f702976 -> d59c24bec
AMBARI-11659. Blueprint processor filters should have better error handling for invalid configuration types. (rnettleton)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d59c24be
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d59c24be
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d59c24be
Branch: refs/heads/trunk
Commit: d59c24becc5ec553ef2dae23056b9d3beafde697
Parents: 01f7029
Author: Bob Nettleton <rn...@hortonworks.com>
Authored: Wed Jun 3 17:59:23 2015 -0400
Committer: Bob Nettleton <rn...@hortonworks.com>
Committed: Wed Jun 3 18:00:20 2015 -0400
----------------------------------------------------------------------
.../BlueprintConfigurationProcessor.java | 9 ++-
.../BlueprintConfigurationProcessorTest.java | 76 ++++++++++++++++++++
2 files changed, 83 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/d59c24be/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 9deea1f..c6ff56c 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
@@ -721,8 +721,13 @@ public class BlueprintConfigurationProcessor {
*/
private static boolean shouldPropertyBeExcludedForClusterUpdate(String propertyName, String propertyValue, String propertyType, ClusterTopology topology) {
for(PropertyFilter filter : clusterUpdatePropertyFilters) {
- if (!filter.isPropertyIncluded(propertyName, propertyValue, propertyType, topology)) {
- return true;
+ try {
+ if (!filter.isPropertyIncluded(propertyName, propertyValue, propertyType, topology)) {
+ return true;
+ }
+ } catch (Throwable throwable) {
+ // if any error occurs during a filter execution, just log it
+ LOG.warn("Error occurred while attempting to process the property '" + propertyName + "' with a filter. This may indicate a config error.", throwable);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/d59c24be/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 64da8ac..d957836 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
@@ -3459,6 +3459,82 @@ public class BlueprintConfigurationProcessorTest {
}
@Test
+ public void testHiveConfigClusterUpdatePropertiesFilterAuthenticationOffFilterThrowsError() throws Exception {
+ // reset the stack mock, since we need more than the default behavior for this test
+ reset(stack);
+
+ final String expectedHostGroupName = "host_group_1";
+
+ Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
+ Map<String, String> hiveSiteProperties = new HashMap<String, String>();
+ properties.put("hive-site", hiveSiteProperties);
+
+ // setup properties for Hive to simulate the case of Hive Authentication being off
+ hiveSiteProperties.put("hive.server2.authentication", "NONE");
+ hiveSiteProperties.put("hive.server2.authentication.kerberos.keytab", " ");
+ hiveSiteProperties.put("hive.server2.authentication.kerberos.principal", " ");
+
+ Map<String, Stack.ConfigProperty> mapOfMetadata =
+ new HashMap<String, Stack.ConfigProperty>();
+
+ // simulate the stack dependencies for these Hive properties, that are dependent upon
+ // hive.server2.authorization being enabled
+ Stack.ConfigProperty configProperty1 =
+ new Stack.ConfigProperty("hive-site", "hive.server2.authentication.kerberos.keytab", " ") {
+ @Override
+ Set<PropertyDependencyInfo> getDependsOnProperties() {
+ PropertyDependencyInfo dependencyInfo = new PropertyDependencyInfo("hive-site", "hive.server2.authentication");
+ return Collections.singleton(dependencyInfo);
+ }
+ };
+
+ Stack.ConfigProperty configProperty2 =
+ new Stack.ConfigProperty("hive-site", "hive.server2.authentication.kerberos.principal", " ") {
+ @Override
+ Set<PropertyDependencyInfo> getDependsOnProperties() {
+ PropertyDependencyInfo dependencyInfo = new PropertyDependencyInfo("hive-site", "hive.server2.authentication");
+ return Collections.singleton(dependencyInfo);
+ }
+ };
+
+ mapOfMetadata.put("hive.server2.authentication.kerberos.keytab", configProperty1);
+ mapOfMetadata.put("hive.server2.authentication.kerberos.principal", configProperty2);
+
+ // 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
+ // simulate the case of the stack object throwing a RuntimeException, to indicate a config error
+ expect(stack.getServiceForConfigType("hive-site")).andThrow(new RuntimeException("unexpected error!!"));
+ expect(stack.getConfigurationPropertiesWithMetadata("HIVE", "hive-site")).andReturn(mapOfMetadata).atLeastOnce();
+
+ Configuration clusterConfig = new Configuration(properties, Collections.<String, Map<String, Map<String, String>>>emptyMap());
+
+ Collection<String> hgComponents = new HashSet<String>();
+ hgComponents.add("NAMENODE");
+ List<String> hosts = new ArrayList<String>();
+ hosts.add("some-hose");
+ TestHostGroup group1 = new TestHostGroup(expectedHostGroupName, hgComponents, hosts);
+
+
+ Collection<TestHostGroup> hostGroups = new HashSet<TestHostGroup>();
+ hostGroups.add(group1);
+
+ ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups);
+ BlueprintConfigurationProcessor updater = new BlueprintConfigurationProcessor(topology);
+
+ // call top-level cluster config update method
+ updater.doUpdateForClusterCreate();
+
+ assertTrue("hive.server2.authentication.kerberos.keytab should not have been filtered, due to error condition",
+ hiveSiteProperties.containsKey("hive.server2.authentication.kerberos.keytab"));
+ assertTrue("hive.server2.authentication.kerberos.principal should not have been filtered, due to error condition",
+ hiveSiteProperties.containsKey("hive.server2.authentication.kerberos.principal"));
+ }
+
+ @Test
public void testHiveConfigClusterUpdatePropertiesFilterAuthenticationOn() throws Exception {
// reset the stack mock, since we need more than the default behavior for this test
reset(stack);