ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [05/50] [abbrv] ambari git commit: AMBARI-13889: Upgrade from 2.1.2 to 2.1.3 fails with Security enabled due to missing Accumulo configuration (Josh Elser via jluniya)
Date Wed, 18 Nov 2015 16:51:01 GMT
AMBARI-13889: Upgrade from 2.1.2 to 2.1.3 fails with Security enabled due to missing Accumulo
configuration (Josh Elser via jluniya)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 4892c9bf5fc77ced4996850b759b8212691b8b6b
Parents: 696b439
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Mon Nov 16 15:31:47 2015 -0800
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Mon Nov 16 15:31:47 2015 -0800

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog213.java       | 21 +++++++
 .../server/upgrade/UpgradeCatalog213Test.java   | 63 ++++++++++++++++++++
 2 files changed, 84 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4892c9bf/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
index 634d42e..1278e31 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
@@ -59,6 +59,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.RepositoryVersionState;
+import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.StackInfo;
 import org.apache.ambari.server.state.alert.SourceType;
@@ -297,6 +298,7 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
     updateRangerEnvConfig();
     updateZookeeperLog4j();
     updateHiveConfig();
+    updateAccumuloConfigs();
   }
 
   /**
@@ -1099,6 +1101,25 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
     return hiveEnvContent.replaceFirst(oldHeapSizeRegex, Matcher.quoteReplacement(newHeapSizeRegex));
   }
 
+  protected void updateAccumuloConfigs() throws AmbariException {
+    AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
+    for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values())
{
+      // If security type is set to Kerberos, update Kerberos-related configs
+      if(cluster.getSecurityType() == SecurityType.KERBEROS) {
+        Config clientProps = cluster.getDesiredConfigByType("client");
+        if (clientProps != null) {
+          Map<String, String> properties = clientProps.getProperties();
+          if (properties == null) {
+            properties = new HashMap<String, String>();
+          }
+          // <2.1.3 did not account for a custom service principal.
+          // Need to ensure that the client knows the server's principal (the primary) to
properly authenticate.
+          properties.put("kerberos.server.primary", "{{bare_accumulo_principal}}");
+          updateConfigurationPropertiesForCluster(cluster, "client", properties, true, false);
+        }
+      } // else -- no special client-configuration is necessary.
+    }
+  }
 
   private String memoryToIntMb(String memorySize) {
     if (memorySize == null) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/4892c9bf/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
index c609bcc..421246c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
@@ -77,6 +77,7 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.RepositoryVersionState;
+import org.apache.ambari.server.state.SecurityType;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.StackInfo;
@@ -237,6 +238,7 @@ public class UpgradeCatalog213Test {
     Method updateAlertDefinitions = UpgradeCatalog213.class.getDeclaredMethod("updateAlertDefinitions");
     Method updateRangerEnvConfig = UpgradeCatalog213.class.getDeclaredMethod("updateRangerEnvConfig");
     Method updateHiveConfig = UpgradeCatalog213.class.getDeclaredMethod("updateHiveConfig");
+    Method updateAccumuloConfigs = UpgradeCatalog213.class.getDeclaredMethod("updateAccumuloConfigs");
 
     UpgradeCatalog213 upgradeCatalog213 = createMockBuilder(UpgradeCatalog213.class)
       .addMockedMethod(updateAMSConfigs)
@@ -251,6 +253,7 @@ public class UpgradeCatalog213Test {
       .addMockedMethod(updateHadoopEnvConfig)
       .addMockedMethod(updateRangerEnvConfig)
       .addMockedMethod(updateHiveConfig)
+      .addMockedMethod(updateAccumuloConfigs)
       .createMock();
 
     upgradeCatalog213.updateHbaseEnvConfig();
@@ -276,6 +279,8 @@ public class UpgradeCatalog213Test {
     expectLastCall().once();
     upgradeCatalog213.updateHiveConfig();
     expectLastCall().once();
+    upgradeCatalog213.updateAccumuloConfigs();
+    expectLastCall().once();
 
     replay(upgradeCatalog213);
 
@@ -1256,4 +1261,62 @@ public class UpgradeCatalog213Test {
     Assert.assertEquals(expectedResult, upgradeCatalog213.updateHiveEnvContent(testContent));
   }
 
+  @Test
+  public void testUpdateAccumuloConfigs() throws Exception {
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+
+    // We start with no client properties (< 2.1.3).
+    final Map<String, String> originalClientProperties = new HashMap<String, String>();
+    // And should get the following property on upgrade.
+    final Map<String, String> updatedClientProperties = new HashMap<String, String>()
{
+      {
+        put("kerberos.server.primary", "{{bare_accumulo_principal}}");
+      }
+    };
+    
+    final Config clientConfig = easyMockSupport.createNiceMock(Config.class);
+
+    final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+      @Override
+      protected void configure() {
+        bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+        bind(Clusters.class).toInstance(mockClusters);
+        bind(EntityManager.class).toInstance(entityManager);
+
+        bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+        bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+      }
+    });
+
+    expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+    expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+      put("normal", mockClusterExpected);
+    }}).once();
+
+    // Enable KERBEROS
+    expect(mockClusterExpected.getSecurityType()).andReturn(SecurityType.KERBEROS).once();
+    // Mock out our empty original properties
+    expect(mockClusterExpected.getDesiredConfigByType("client")).andReturn(clientConfig).atLeastOnce();
+    expect(clientConfig.getProperties()).andReturn(originalClientProperties).atLeastOnce();
+
+    UpgradeCatalog213 upgradeCatalog213 = createMockBuilder(UpgradeCatalog213.class)
+            .withConstructor(Injector.class)
+            .withArgs(mockInjector)
+            .addMockedMethod("updateConfigurationPropertiesForCluster", Cluster.class, String.class,
+                    Map.class, boolean.class, boolean.class)
+            .createMock();
+    // Verify that we get this method called with the updated properties
+    upgradeCatalog213.updateConfigurationPropertiesForCluster(mockClusterExpected,
+            "client", updatedClientProperties, true, false);
+    expectLastCall().once();
+
+    // Run it
+    easyMockSupport.replayAll();
+    replay(upgradeCatalog213);
+    upgradeCatalog213.updateAccumuloConfigs();
+    easyMockSupport.verifyAll();
+  }
 }


Mime
View raw message