AMBARI-21129. Nimbus fails to start when Ambari is upgraded to 2.5.1, EU to HDP 2.6.1, and cluster is then Kerberized (alejandro)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3f908852 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3f908852 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3f908852 Branch: refs/heads/branch-feature-AMBARI-12556 Commit: 3f9088524e276671fb0ea8252ce7c1f7ea149cda Parents: 57f4461 Author: Alejandro Fernandez <afernan...@hortonworks.com> Authored: Fri Jun 2 15:33:09 2017 -0700 Committer: Alejandro Fernandez <afernan...@hortonworks.com> Committed: Fri Jun 2 15:33:09 2017 -0700 ---------------------------------------------------------------------- .../server/upgrade/UpgradeCatalog251.java | 45 +++++++++++++++++++- .../internal/UpgradeResourceProviderTest.java | 1 - .../server/upgrade/UpgradeCatalog251Test.java | 13 ++++-- 3 files changed, 53 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/3f908852/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java index 9255daf..119d9ce 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog251.java @@ -1,4 +1,4 @@ -/* +/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -19,6 +19,7 @@ package org.apache.ambari.server.upgrade; import java.sql.SQLException; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -50,6 +51,7 @@ public class UpgradeCatalog251 extends AbstractUpgradeCatalog { private static final String REQUEST_TABLE = "request"; private static final String CLUSTER_HOST_INFO_COLUMN = "cluster_host_info"; private static final String REQUEST_ID_COLUMN = "request_id"; + protected static final String STORM_ENV_CONFIG = "storm-env"; /** @@ -106,6 +108,7 @@ public class UpgradeCatalog251 extends AbstractUpgradeCatalog { protected void executeDMLUpdates() throws AmbariException, SQLException { addNewConfigurationsFromXml(); updateKAFKAConfigs(); + updateSTORMConfigs(); } /** @@ -166,4 +169,44 @@ public class UpgradeCatalog251 extends AbstractUpgradeCatalog { dbAccessor.moveColumnToAnotherTable(STAGE_TABLE, sourceColumn, REQUEST_ID_COLUMN, REQUEST_TABLE, targetColumn, REQUEST_ID_COLUMN, false); } + + /** + * Make sure storm-env changes are applied to anyone upgrading to HDP-2.6.1 Storm + * If the base version was before Ambari 2.5.0, this method should wind up doing nothing. + * @throws AmbariException + */ + protected void updateSTORMConfigs() throws AmbariException { + AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); + Clusters clusters = ambariManagementController.getClusters(); + if (clusters != null) { + Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); + if (clusterMap != null && !clusterMap.isEmpty()) { + for (final Cluster cluster : clusterMap.values()) { + Set<String> installedServices = cluster.getServices().keySet(); + + // Technically, this should be added when the cluster is Kerberized on HDP 2.6.1, but is safe to add even + // without security or on an older stack version (such as HDP 2.5) + // The problem is that Kerberizing a cluster does not invoke Stack Advisor and has no easy way of setting + // these configs, so instead, add them as long as Storm is present. + if (installedServices.contains("STORM")) { + Config stormEnv = cluster.getDesiredConfigByType(STORM_ENV_CONFIG); + String content = stormEnv.getProperties().get("content"); + if (content != null && !content.contains("STORM_AUTOCREDS_LIB_DIR")) { + Map<String, String> newProperties = new HashMap<>(); + String stormEnvConfigs = "\n# set storm-auto creds\n" + + "# check if storm_jaas.conf in config, only enable storm_auto_creds in secure mode.\n" + + "STORM_JAAS_CONF=$STORM_HOME/conf/storm_jaas.conf\n" + + "STORM_AUTOCREDS_LIB_DIR=$STORM_HOME/external/storm-autocreds\n" + + "if [ -f $STORM_JAAS_CONF ] && [ -d $STORM_AUTOCREDS_LIB_DIR ]; then\n" + + " export STORM_EXT_CLASSPATH=$STORM_AUTOCREDS_LIB_DIR\n" + + "fi\n"; + content += stormEnvConfigs; + newProperties.put("content", content); + updateConfigurationPropertiesForCluster(cluster, "storm-env", newProperties, true, false); + } + } + } + } + } + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/3f908852/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java index a4f5e9a..8f59c07 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java @@ -96,7 +96,6 @@ import org.apache.ambari.server.state.UpgradeContext; import org.apache.ambari.server.state.UpgradeHelper; import org.apache.ambari.server.state.UpgradeState; import org.apache.ambari.server.state.stack.upgrade.Direction; -import org.apache.ambari.server.state.stack.upgrade.StageWrapper; import org.apache.ambari.server.state.stack.upgrade.UpgradeType; import org.apache.ambari.server.topology.TopologyManager; import org.apache.ambari.server.utils.StageUtils; http://git-wip-us.apache.org/repos/asf/ambari/blob/3f908852/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog251Test.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog251Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog251Test.java index fda5f0e..5750e04 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog251Test.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog251Test.java @@ -178,13 +178,15 @@ public class UpgradeCatalog251Test { @Test public void testExecuteDMLUpdates() throws Exception { - Method updateKAFKAConfigs = UpgradeCatalog251.class.getDeclaredMethod("updateKAFKAConfigs"); Method addNewConfigurationsFromXml = AbstractUpgradeCatalog.class.getDeclaredMethod("addNewConfigurationsFromXml"); + Method updateKAFKAConfigs = UpgradeCatalog251.class.getDeclaredMethod("updateKAFKAConfigs"); + Method updateSTORMConfigs = UpgradeCatalog251.class.getDeclaredMethod("updateSTORMConfigs"); UpgradeCatalog251 upgradeCatalog251 = createMockBuilder(UpgradeCatalog251.class) - .addMockedMethod(updateKAFKAConfigs) - .addMockedMethod(addNewConfigurationsFromXml) - .createMock(); + .addMockedMethod(addNewConfigurationsFromXml) + .addMockedMethod(updateKAFKAConfigs) + .addMockedMethod(updateSTORMConfigs) + .createMock(); upgradeCatalog251.addNewConfigurationsFromXml(); expectLastCall().once(); @@ -194,6 +196,9 @@ public class UpgradeCatalog251Test { upgradeCatalog251.updateKAFKAConfigs(); expectLastCall().once(); + + upgradeCatalog251.updateSTORMConfigs(); + expectLastCall().once(); replay(upgradeCatalog251, dbAccessor);