ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnettle...@apache.org
Subject ambari git commit: AMBARI-13778. Submitting kerberos descriptor should be optional in Blueprint or Cluster template json. (Sandor Magyari via rnettleton)
Date Mon, 09 Nov 2015 15:50:47 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 84dfed996 -> 65e87e692


AMBARI-13778. Submitting kerberos descriptor should be optional in Blueprint or Cluster template
json. (Sandor Magyari via rnettleton)


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

Branch: refs/heads/branch-2.1
Commit: 65e87e692992d9eabe0110bd07cf7ba8935d39d6
Parents: 84dfed9
Author: Bob Nettleton <rnettleton@hortonworks.com>
Authored: Mon Nov 9 10:49:51 2015 -0500
Committer: Bob Nettleton <rnettleton@hortonworks.com>
Committed: Mon Nov 9 10:49:51 2015 -0500

----------------------------------------------------------------------
 .../server/topology/SecurityConfigurationFactory.java    | 11 ++++-------
 .../apache/ambari/server/topology/TopologyManager.java   |  8 ++++++--
 .../topology/SecurityConfigurationFactoryTest.java       |  2 +-
 3 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/65e87e69/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfigurationFactory.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfigurationFactory.java
index 5f8cde1..8a31a42 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfigurationFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfigurationFactory.java
@@ -99,12 +99,6 @@ public class SecurityConfigurationFactory {
 
       Object descriptorJsonMap = securityProperties.get(KERBEROS_DESCRIPTOR_PROPERTY_ID);
 
-      if (descriptorReference == null && descriptorJsonMap == null) {
-        LOGGER.error("Both kerberos descriptor and kerberos descriptor reference are null
in the security configuration!");
-        throw new IllegalArgumentException(KERBEROS_DESCRIPTOR_PROPERTY_ID + " or "
-            + KERBEROS_DESCRIPTOR_REFERENCE_PROPERTY_ID + " is required for KERBEROS security
setup.");
-      }
-
       if (descriptorReference != null && descriptorJsonMap != null) {
         LOGGER.error("Both kerberos descriptor and kerberos descriptor reference are set
in the security configuration!");
         throw new IllegalArgumentException("Usage of properties : " + KERBEROS_DESCRIPTOR_PROPERTY_ID
+ " and "
@@ -120,9 +114,12 @@ public class SecurityConfigurationFactory {
           descriptorReference = persistKerberosDescriptor(descriptorText);
         }
         securityConfiguration = new SecurityConfiguration(SecurityType.KERBEROS, descriptorReference,
descriptorText);
-      } else { // this means the reference is not null
+      } else if (descriptorReference != null) { // this means the reference is not null
         LOGGER.debug("Found descriptor reference: {}", descriptorReference);
         securityConfiguration = loadSecurityConfigurationByReference(descriptorReference);
+      } else {
+        LOGGER.debug("There is no security descriptor found in the request");
+        securityConfiguration = new SecurityConfiguration(SecurityType.KERBEROS);
       }
     } else {
       LOGGER.debug("There is no security configuration found in the request");

http://git-wip-us.apache.org/repos/asf/ambari/blob/65e87e69/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index 7f571ce..a688464 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -139,7 +139,10 @@ public class TopologyManager {
       // create Cluster resource with security_type = KERBEROS, this will trigger cluster
Kerberization
       // upon host install task execution
       ambariContext.createAmbariResources(topology, clusterName, securityConfiguration.getType());
-      submitKerberosDescriptorAsArtifact(clusterName, securityConfiguration.getDescriptor());
+      if (securityConfiguration.getDescriptor() != null) {
+        submitKerberosDescriptorAsArtifact(clusterName, securityConfiguration.getDescriptor());
+      }
+
       Credential credential = request.getCredentialsMap().get(KDC_ADMIN_CREDENTIAL);
       if (credential == null) {
         throw new InvalidTopologyException(KDC_ADMIN_CREDENTIAL + " is missing from request.");
@@ -219,7 +222,8 @@ public class TopologyManager {
       // todo - perform this logic at request creation instead!
       LOG.debug("There's no security configuration in the request, retrieving it from the
associated blueprint");
       securityConfiguration = request.getBlueprint().getSecurity();
-      if (securityConfiguration.getType() == SecurityType.KERBEROS) {
+      if (securityConfiguration.getType() == SecurityType.KERBEROS &&
+        securityConfiguration.getDescriptorReference() != null) {
         securityConfiguration = securityConfigurationFactory.loadSecurityConfigurationByReference
           (securityConfiguration.getDescriptorReference());
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/65e87e69/ambari-server/src/test/java/org/apache/ambari/server/topology/SecurityConfigurationFactoryTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/SecurityConfigurationFactoryTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/topology/SecurityConfigurationFactoryTest.java
index bf9556f..e991ead 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/SecurityConfigurationFactoryTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/SecurityConfigurationFactoryTest.java
@@ -102,7 +102,7 @@ public class SecurityConfigurationFactoryTest {
         kdEntityCaptor.getValue().getName());
   }
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void testCreateKerberosSecurityWithoutDescriptor() throws Exception {
     Map<String, Object> reuqestMap = new HashMap<>();
     Map<String, Object> security = new HashMap<>();


Mime
View raw message