Repository: ambari
Updated Branches:
  refs/heads/trunk eaf27bfd6 -> a32919904


AMBARI-14668. Kerberos specifical properties reverted during secured cluster 
deploy via blueprint.(vbrodetskyi)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a3291990
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a3291990
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a3291990

Branch: refs/heads/trunk
Commit: a329199047c7b0566c14653c56a669a6ebf4369e
Parents: eaf27bf
Author: Vitaly Brodetskyi <[email protected]>
Authored: Fri Jan 15 19:38:03 2016 +0200
Committer: Vitaly Brodetskyi <[email protected]>
Committed: Fri Jan 15 19:38:03 2016 +0200

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         |  3 ++-
 .../topology/ClusterConfigurationRequest.java   | 27 +++++++++++++-------
 .../ClusterConfigurationRequestTest.java        |  1 +
 3 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a3291990/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 80d545f..41126f8 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -2385,7 +2385,8 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
                   // occur (like distribute keytabs)
                   if((oldSchState == State.INIT || oldSchState == 
State.INSTALL_FAILED) && kerberosHelper.isClusterKerberosEnabled(cluster)) {
                     // check if host component already exists, if it exists no 
need to reset kerberos configs
-                    if (!hostComponentAlreadyExists(cluster, scHost)) {
+                    // check if it's blueprint install. If it is, then do not 
call kerberos.configureService
+                    if (!hostComponentAlreadyExists(cluster, scHost) && 
!("INITIAL_INSTALL".equals(requestProperties.get("phase")))) {
                       try {
                         kerberosHelper.configureService(cluster, scHost);
                       } catch (KerberosInvalidConfigurationException e) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3291990/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
index 16d983a..1e89272 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
@@ -123,6 +123,8 @@ public class ClusterConfigurationRequest {
     Cluster cluster = getCluster();
     Blueprint blueprint = clusterTopology.getBlueprint();
 
+    Configuration stackDefaults = 
blueprint.getStack().getConfiguration(blueprint.getServices());
+    Map<String, Map<String, String>> stackDefaultProps = 
stackDefaults.getProperties();
     Configuration clusterConfiguration = clusterTopology.getConfiguration();
     Map<String, Map<String, String>> existingConfigurations = 
clusterConfiguration.getFullProperties();
     // add clusterHostInfo containing components to hosts map, based on 
Topology, to use this one instead of
@@ -141,15 +143,22 @@ public class ClusterConfigurationRequest {
         .getServiceConfigurationUpdates(cluster, existingConfigurations,
         new HashSet<String>(blueprint.getServices()), false);
 
-     for (String configType : updatedConfigs.keySet()) {
-       Map<String, String> propertyMap = updatedConfigs.get(configType);
-       for (String property : propertyMap.keySet()) {
-         LOG.debug("Update Kerberos related config property: {} {} {}", 
configType, property, propertyMap.get
-           (property));
-          clusterConfiguration.setProperty(configType, property, 
propertyMap.get(property));
-       }
-     }
-      updatedConfigTypes.addAll(updatedConfigs.keySet());
+      for (String configType : updatedConfigs.keySet()) {
+        Map<String, String> propertyMap = updatedConfigs.get(configType);
+        Map<String, String> clusterConfigProperties = 
existingConfigurations.get(configType);
+        Map<String, String> stackDefaultConfigProperties = 
stackDefaultProps.get(configType);
+        for (String property : propertyMap.keySet()) {
+          if (clusterConfigProperties == null || 
!clusterConfigProperties.containsKey(property)
+                 || (clusterConfigProperties.get(property) == null && 
stackDefaultConfigProperties.get(property) == null)
+                 || (clusterConfigProperties.get(property) != null && 
clusterConfigProperties.get(property).equals(stackDefaultConfigProperties.get(property))))
 {
+            LOG.debug("Update Kerberos related config property: {} {} {}", 
configType, property, propertyMap.get
+              (property));
+            clusterConfiguration.setProperty(configType, property, 
propertyMap.get(property));
+            updatedConfigTypes.add(configType);
+          }
+        }
+      }
+
     } catch (KerberosInvalidConfigurationException e) {
       LOG.error("An exception occurred while doing Kerberos related 
configuration update: " + e, e);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/a3291990/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java
index 96abe9d..d1886b9 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterConfigurationRequestTest.java
@@ -116,6 +116,7 @@ public class ClusterConfigurationRequestTest {
     services.add("KERBEROS");
     services.add("ZOOKEPER");
     expect(blueprint.getServices()).andReturn(services).anyTimes();
+    expect(stack.getConfiguration(services)).andReturn(stackConfig).once();
 
     List<String> hdfsComponents = new ArrayList<>();
     hdfsComponents.add("NAMENODE");

Reply via email to