Преглед изворни кода

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

Vitaly Brodetskyi пре 9 година
родитељ
комит
a329199047

+ 2 - 1
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) {

+ 18 - 9
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);
     }

+ 1 - 0
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");