You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/08/19 20:59:01 UTC

ambari git commit: Storm components were stopped during RU and can not be started (Dmitry Lysnichenko via ncole)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 e662dcb7c -> c8282d691


Storm components were stopped during RU and can not be started (Dmitry Lysnichenko via ncole)


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

Branch: refs/heads/branch-2.4
Commit: c8282d6917311aba1eb52885030177210fcc54a0
Parents: e662dcb
Author: Nate Cole <nc...@hortonworks.com>
Authored: Fri Aug 19 16:58:52 2016 -0400
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Fri Aug 19 16:58:52 2016 -0400

----------------------------------------------------------------------
 .../StormUpgradeKerberosDescriptorConfig.java   | 144 +++++++++++++++++++
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml |   4 +
 .../stacks/HDP/2.3/upgrades/upgrade-2.5.xml     |   2 +
 .../HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml |   4 +
 .../stacks/HDP/2.4/upgrades/upgrade-2.5.xml     |   2 +
 5 files changed, 156 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c8282d69/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/StormUpgradeKerberosDescriptorConfig.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/StormUpgradeKerberosDescriptorConfig.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/StormUpgradeKerberosDescriptorConfig.java
new file mode 100644
index 0000000..07bdaa6
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/StormUpgradeKerberosDescriptorConfig.java
@@ -0,0 +1,144 @@
+/*
+  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
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  <p>
+  http://www.apache.org/licenses/LICENSE-2.0
+  <p>
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+package org.apache.ambari.server.serveraction.upgrades;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.agent.CommandReport;
+import org.apache.ambari.server.orm.dao.ArtifactDAO;
+import org.apache.ambari.server.orm.entities.ArtifactEntity;
+import org.apache.ambari.server.serveraction.AbstractServerAction;
+import org.apache.ambari.server.state.kerberos.KerberosConfigurationDescriptor;
+import org.apache.ambari.server.state.kerberos.KerberosDescriptor;
+import org.apache.ambari.server.state.kerberos.KerberosDescriptorFactory;
+import org.apache.ambari.server.state.kerberos.KerberosServiceDescriptor;
+
+import com.google.inject.Inject;
+
+
+/**
+ * Update Kerberos Descriptor Storm properties when upgrading to Storm 1.0
+ */
+public class StormUpgradeKerberosDescriptorConfig extends AbstractServerAction {
+
+
+  public static final String KERBEROS_DESCRIPTOR = "kerberos_descriptor";
+  public static final String STORM = "STORM";
+  public static final String NEW_PART = "org.apache";
+  public static final String OLD_PART = "backtype";
+
+  @Inject
+  ArtifactDAO artifactDAO;
+
+  protected StormUpgradeKerberosDescriptorConfig() {
+  }
+
+  /**
+   * Lists config types and properties that may be replaced "backtype" to "org.apache"
+   */
+  private static final HashMap<String, String[]> TARGET_PROPERTIES = new HashMap<String, String[]>() {{
+    put("storm-site", new String[]{
+        "nimbus.authorizer",
+        "storm.principal.tolocal",
+        "drpc.authorizer"
+    });
+
+  }};
+
+  /**
+   * Update Kerberos Descriptor Storm properties when upgrading to Storm 1.0
+   * <p/>
+   * Finds the relevant artifact entities and iterates through them to process each independently.
+   */
+  @Override
+  public CommandReport execute(ConcurrentMap<String, Object> requestSharedDataContext)
+      throws AmbariException, InterruptedException {
+
+    String msg = "";
+
+    List<ArtifactEntity> artifactEntities = artifactDAO.findByName(KERBEROS_DESCRIPTOR);
+
+    if (artifactEntities != null) {
+      for (ArtifactEntity artifactEntity : artifactEntities) {
+        if (artifactEntity == null) {
+          continue;
+        }
+        msg = updateKerberosDescriptorConfigurations(msg, artifactEntity);
+      }
+    } else {
+      msg = msg + MessageFormat.format("{0} not found\n", KERBEROS_DESCRIPTOR);
+    }
+
+    msg = MessageFormat.format("{0}\n Successfully replace properties", msg);
+    return createCommandReport(0, HostRoleStatus.COMPLETED, "{}", msg, "");
+  }
+
+  private String updateKerberosDescriptorConfigurations(String msg, ArtifactEntity artifactEntity) {
+    Map<String, Object> data = artifactEntity.getArtifactData();
+
+    if (data != null) {
+      final KerberosDescriptor kerberosDescriptor = new KerberosDescriptorFactory().createInstance(data);
+
+      if (kerberosDescriptor != null) {
+        // Get the service that needs to be updated
+        KerberosServiceDescriptor serviceDescriptor = kerberosDescriptor.getService(STORM);
+
+        if (serviceDescriptor != null) {
+          for (String configType : TARGET_PROPERTIES.keySet()) {
+            // Get the configuration that needs to be updated
+            KerberosConfigurationDescriptor configurationDescriptor = serviceDescriptor.getConfiguration(configType);
+
+            if (configurationDescriptor != null) {
+              for (String key : TARGET_PROPERTIES.get(configType)) {
+                // Get the configuration properties that needs to be updated
+                String value = configurationDescriptor.getProperty(key);
+                if (value != null) {
+                  value = value.replace(OLD_PART, NEW_PART);
+                  configurationDescriptor.putProperty(key, value);
+                  msg = msg + MessageFormat.format("{0}={1}, \n", key, value);
+                } else {
+                  msg = msg + MessageFormat.format("{0} not found in {1}\n", key, configType);
+                }
+
+                artifactEntity.setArtifactData(kerberosDescriptor.toMap());
+                artifactDAO.merge(artifactEntity);
+              }
+            } else {
+              msg = msg + MessageFormat.format("{0} not found\n", configType);
+            }
+          }
+        } else {
+          msg = msg + MessageFormat.format("{0} not found\n", STORM);
+        }
+        artifactEntity.setArtifactData(kerberosDescriptor.toMap());
+        artifactDAO.merge(artifactEntity);
+      } else {
+        msg = msg + "KerberosDescriptor not created from data";
+      }
+    } else {
+      msg = msg + MessageFormat.format("{0} not found\n", "artifactData");
+    }
+    return msg;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8282d69/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
index 65a7880..b9067c7 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.5.xml
@@ -427,6 +427,10 @@
       <execute-stage service="STORM" component="NIMBUS" title="Apply config changes for Nimbus">
         <task xsi:type="configure" id="hdp_2_5_0_0_upgrade_storm_1.0"/>
       </execute-stage>
+      <execute-stage service="STORM" component="NIMBUS" title="Apply config changes for Nimbus in KerberosDescriptor">
+        <task xsi:type="server_action" summary="Upgrade Storm Security Configs to 1.0"
+              class="org.apache.ambari.server.serveraction.upgrades.StormUpgradeKerberosDescriptorConfig"/>
+      </execute-stage>
 
       <execute-stage service="STORM" component="NIMBUS" title="Apply config changes for Storm">
         <!-- Remove Atlas configs that were incorrectly added to storm-site instead of Atlas' application.properties. -->

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8282d69/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
index a256d2f..7237a6a 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.5.xml
@@ -985,6 +985,8 @@
         <pre-upgrade>
           <task xsi:type="configure" id="hdp_2_5_0_0_remove_ranger_storm_audit_db" />
           <task xsi:type="configure" id="hdp_2_5_0_0_upgrade_storm_1.0"/>
+          <task xsi:type="server_action" summary="Upgrade Storm Security Configs to 1.0"
+                class="org.apache.ambari.server.serveraction.upgrades.StormUpgradeKerberosDescriptorConfig"/>
 
           <!-- Remove Atlas configs that were incorrectly added to storm-site instead of Atlas' application.properties. -->
           <task xsi:type="configure" id="hdp_2_5_0_0_remove_storm_atlas_configs" />

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8282d69/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
index 98e5038..1cc9529 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.5.xml
@@ -377,6 +377,10 @@
       <execute-stage service="STORM" component="NIMBUS" title="Apply config changes for Nimbus">
         <task xsi:type="configure" id="hdp_2_5_0_0_upgrade_storm_1.0"/>
       </execute-stage>
+      <execute-stage service="STORM" component="NIMBUS" title="Apply config changes for Nimbus in KerberosDescriptor">
+        <task xsi:type="server_action" summary="Upgrade Storm Security Configs to 1.0"
+              class="org.apache.ambari.server.serveraction.upgrades.StormUpgradeKerberosDescriptorConfig"/>
+      </execute-stage>
 
       <execute-stage service="STORM" component="NIMBUS" title="Apply config changes for Storm">
         <!-- Remove Atlas configs that were incorrectly added to storm-site instead of Atlas' application.properties. -->

http://git-wip-us.apache.org/repos/asf/ambari/blob/c8282d69/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
index a4eb513..f20ad06 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.5.xml
@@ -954,6 +954,8 @@
         <pre-upgrade>
           <task xsi:type="configure" id="hdp_2_5_0_0_remove_ranger_storm_audit_db" />
           <task xsi:type="configure" id="hdp_2_5_0_0_upgrade_storm_1.0"/>
+          <task xsi:type="server_action" summary="Upgrade Storm Security Configs to 1.0"
+                class="org.apache.ambari.server.serveraction.upgrades.StormUpgradeKerberosDescriptorConfig"/>
 
           <!-- Remove Atlas configs that were incorrectly added to storm-site instead of Atlas' application.properties. -->
           <task xsi:type="configure" id="hdp_2_5_0_0_remove_storm_atlas_configs" />