ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [2/2] ambari git commit: AMBARI-12706. Stop-and-Start Upgrade: Handle Downgrade path (additional patch) (dgrinenko via dlysnichenko)
Date Tue, 27 Oct 2015 08:17:25 GMT
AMBARI-12706. Stop-and-Start Upgrade: Handle Downgrade path (additional patch) (dgrinenko via
dlysnichenko)


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

Branch: refs/heads/trunk
Commit: 2aef6ff29882ad9349c8874945aab40a51c6d1e2
Parents: f9e7366
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Tue Oct 27 10:15:51 2015 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Tue Oct 27 10:17:05 2015 +0200

----------------------------------------------------------------------
 .../internal/UpgradeResourceProvider.java       | 24 +++++++++++---
 .../ambari/server/state/UpgradeContext.java     |  2 +-
 .../HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml |  6 ++--
 .../HDP/2.2/upgrades/nonrolling-upgrade-2.2.xml |  6 ++--
 .../HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml | 34 +++++++++++++++-----
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml | 12 +++----
 .../server/state/stack/UpgradePackTest.java     |  2 --
 .../2.1.1/upgrades/upgrade_test_nonrolling.xml  |  2 ++
 8 files changed, 57 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2aef6ff2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index c253d1f..9b6176c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -96,8 +96,10 @@ import org.apache.ambari.server.state.stack.upgrade.ConfigureTask;
 import org.apache.ambari.server.state.stack.upgrade.Direction;
 import org.apache.ambari.server.state.stack.upgrade.Grouping;
 import org.apache.ambari.server.state.stack.upgrade.ManualTask;
+import org.apache.ambari.server.state.stack.upgrade.RestartGrouping;
 import org.apache.ambari.server.state.stack.upgrade.ServerSideActionTask;
 import org.apache.ambari.server.state.stack.upgrade.StageWrapper;
+import org.apache.ambari.server.state.stack.upgrade.StopGrouping;
 import org.apache.ambari.server.state.stack.upgrade.Task;
 import org.apache.ambari.server.state.stack.upgrade.TaskWrapper;
 import org.apache.ambari.server.state.stack.upgrade.UpdateStackGrouping;
@@ -663,10 +665,20 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
       throw new AmbariException(String.format("%s is required", UPGRADE_CLUSTER_NAME));
     }
 
+    // Default to ROLLING upgrade, but attempt to read from properties.
+    UpgradeType upgradeType = UpgradeType.ROLLING;
+    if (requestMap.containsKey(UPGRADE_TYPE)) {
+      try {
+        upgradeType = UpgradeType.valueOf(requestMap.get(UPGRADE_TYPE).toString());
+      } catch(Exception e){
+        throw new AmbariException(String.format("Property %s has an incorrect value of %s.",
UPGRADE_TYPE, requestMap.get(UPGRADE_TYPE)));
+      }
+    }
+
     Cluster cluster = getManagementController().getClusters().getCluster(clusterName);
     ConfigHelper configHelper = getManagementController().getConfigHelper();
 
-    // the version being upgraded or downgraded to (ie hdp-2.2.1.0-1234)
+    // the version being upgraded or downgraded to (ie 2.2.1.0-1234)
     final String version = (String) requestMap.get(UPGRADE_VERSION);
 
     MasterHostResolver resolver = direction.isUpgrade()
@@ -793,13 +805,17 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
               itemEntities.add(itemEntity);
 
               // At this point, need to change the effective Stack Id so that subsequent
tasks run on the newer value.
-              // TODO AMBARI-12698, check if this works during a Stop-the-World Downgrade.
-              if (UpdateStackGrouping.class.equals(group.groupClass)) {
+              if (upgradeType == UpgradeType.NON_ROLLING && UpdateStackGrouping.class.equals(group.groupClass))
{
+                if (direction.isUpgrade()) {
+                  ctx.setEffectiveStackId(ctx.getTargetStackId());
+                } else {
+                  ctx.setEffectiveStackId(ctx.getOriginalStackId());
+                }
+              } else if (UpdateStackGrouping.class.equals(group.groupClass)) {
                 ctx.setEffectiveStackId(ctx.getTargetStackId());
               }
 
               injectVariables(configHelper, cluster, itemEntity);
-
               makeServerSideStage(ctx, req, itemEntity, (ServerSideActionTask) task, skippable,
                   allowRetry, configUpgradePack);
             }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2aef6ff2/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
index a856ffc..40f0bd9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
@@ -117,7 +117,7 @@ public class UpgradeContext {
         m_effectiveStackId = targetStackId;
         break;
       case NON_ROLLING:
-        m_effectiveStackId = sourceStackId;
+        m_effectiveStackId = (direction.isUpgrade())? sourceStackId : targetStackId;
         break;
       default:
         m_effectiveStackId = targetStackId;

http://git-wip-us.apache.org/repos/asf/ambari/blob/2aef6ff2/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml
b/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml
index 5c3fa87..29e54c3 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1/upgrades/nonrolling-upgrade-2.3.xml
@@ -47,6 +47,7 @@
     </group>
 
     <group xsi:type="stop" name="STOP_HIGH_LEVEL_SERVICE_COMPONENTS" title="Stop Components
for High-Level Services">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 
@@ -118,6 +119,7 @@
     </group>
 
     <group xsi:type="stop" name="STOP_LOW_LEVEL_SERVICE_COMPONENTS" title="Stop Components
for Core Services (HDFS, HBase, ZooKeeper and Ranger)">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 
@@ -139,10 +141,6 @@
       </service>
     </group>
 
-    <group name="Marker for Downgrade" title="Marker for Downgrade">
-      <direction>UPGRADE</direction>
-      <!-- TODO, if the user attempts a downgrade before this step, they can simply abort.
-->
-    </group>
 
     <group xsi:type="cluster" name="Restore Backups" title="Restore Backups">
       <direction>DOWNGRADE</direction>

http://git-wip-us.apache.org/repos/asf/ambari/blob/2aef6ff2/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.2.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.2.xml
b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.2.xml
index c245cc5..63f9f8d 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.2.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.2.xml
@@ -47,6 +47,7 @@
     </group>
 
     <group xsi:type="stop" name="STOP_HIGH_LEVEL_SERVICE_COMPONENTS" title="Stop Components
for High-Level Services">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 
@@ -142,6 +143,7 @@
     </group>
 
     <group xsi:type="stop" name="STOP_LOW_LEVEL_SERVICE_COMPONENTS" title="Stop Components
for Core Services (HDFS, HBase, ZooKeeper and Ranger)">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 
@@ -168,10 +170,6 @@
       </service>
     </group>
 
-    <group name="Marker for Downgrade" title="Marker for Downgrade">
-      <direction>UPGRADE</direction>
-      <!-- TODO, if the user attempts a downgrade before this step, they can simply abort.
-->
-    </group>
 
     <group xsi:type="cluster" name="Restore Backups" title="Restore Backups">
       <direction>DOWNGRADE</direction>

http://git-wip-us.apache.org/repos/asf/ambari/blob/2aef6ff2/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml
b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml
index abf142e..6a939d0 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/upgrades/nonrolling-upgrade-2.3.xml
@@ -21,10 +21,8 @@
   <target>2.3.*.*</target>
   <target-stack>HDP-2.3</target-stack>
   <type>NON_ROLLING</type>
-  <downgrade-allowed>false</downgrade-allowed>
-  <prechecks>
-    <!--TODO: do we have any?-->
-  </prechecks>
+  <prerequisite-checks>
+  </prerequisite-checks>
   <order>
     <group xsi:type="cluster" name="PRE_CLUSTER" title="Prepare Upgrade">
       <skippable>true</skippable>
@@ -48,7 +46,30 @@
       </execute-stage>
     </group>
 
+    <!--
+    On an HDP 2.3 to 2.2 downgrade, the /etc/component/conf must be turned back from a symlink
+    into a normal directory. This will avoid the circular symbolic link that will happen
after
+    hdp-select sets /usr/hdp/current/component back to 2.2:
+
+    # new symlink created for 2.3
+    /etc/flume/conf -> /usr/hdp/current/flume-server/conf
+
+    # circular reference from 2.2 (current)
+    /usr/hdp/2.2.0.0-1234/flume/conf -> /etc/flume/conf
+    /usr/hdp/current/flume-server/conf -> /etc/flume/conf
+    -->
+    <group xsi:type="cluster" name="RESTORE_CONFIG_DIRS" title="Restore Configuration
Directories">
+      <direction>DOWNGRADE</direction>
+      <execute-stage title="Restore configuration directories and remove HDP 2.3 symlinks">
+        <task xsi:type="execute">
+          <script>scripts/ru_set_all.py</script>
+          <function>unlink_all_configs</function>
+        </task>
+      </execute-stage>
+    </group>
+
     <group xsi:type="stop" name="STOP_HIGH_LEVEL_SERVICE_COMPONENTS" title="Stop Components
for High-Level Services">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 
@@ -147,6 +168,7 @@
     </group>
 
     <group xsi:type="stop" name="STOP_LOW_LEVEL_SERVICE_COMPONENTS" title="Stop Components
for Core Services (HDFS, HBase, ZooKeeper and Ranger)">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 
@@ -173,10 +195,6 @@
       </service>
     </group>
 
-    <group name="Marker for Downgrade" title="Marker for Downgrade">
-      <direction>UPGRADE</direction>
-      <!-- TODO, if the user attempts a downgrade before this step, they can simply abort.
-->
-    </group>
 
     <group xsi:type="cluster" name="Restore Backups" title="Restore Backups">
       <direction>DOWNGRADE</direction>

http://git-wip-us.apache.org/repos/asf/ambari/blob/2aef6ff2/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
index 6eca441..407b22b 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.3.xml
@@ -21,9 +21,8 @@
   <target>2.3.*.*</target>
   <target-stack>HDP-2.3</target-stack>
   <type>NON_ROLLING</type>
-  <prechecks>
-    <!--TODO: do we have any?-->
-  </prechecks>
+  <prerequisite-checks>
+  </prerequisite-checks>
   <order>
     <group xsi:type="cluster" name="PRE_CLUSTER" title="Prepare Upgrade">
       <skippable>true</skippable>
@@ -48,6 +47,7 @@
     </group>
 
     <group xsi:type="stop" name="STOP_HIGH_LEVEL_SERVICE_COMPONENTS" title="Stop Components
for High-Level Services">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 
@@ -150,6 +150,7 @@
     </group>
 
     <group xsi:type="stop" name="STOP_LOW_LEVEL_SERVICE_COMPONENTS" title="Stop Components
for Core Services (HDFS, HBase, ZooKeeper and Ranger)">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 
@@ -179,11 +180,6 @@
       </service>
     </group>
 
-    <group name="Marker for Downgrade" title="Marker for Downgrade">
-      <direction>UPGRADE</direction>
-      <!-- TODO (Alejandro), if the user attempts a downgrade before this step, they can
simply abort. -->
-    </group>
-
     <group xsi:type="cluster" name="Restore Backups" title="Restore Backups">
       <direction>DOWNGRADE</direction>
       <skippable>true</skippable>

http://git-wip-us.apache.org/repos/asf/ambari/blob/2aef6ff2/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
index 82a72be..eaf31f7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
@@ -245,8 +245,6 @@ public class UpgradePackTest {
       "POST_CLUSTER");
 
     List<String> expected_down = Arrays.asList(
-      "Stop High-Level Daemons",
-      "Stop Low-Level Daemons",
       "Restore Backups",
       "UPDATE_DESIRED_STACK_ID",
       "ALL_HOST_OPS",

http://git-wip-us.apache.org/repos/asf/ambari/blob/2aef6ff2/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
index c1e03e0..4c1f472 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.1.1/upgrades/upgrade_test_nonrolling.xml
@@ -45,6 +45,7 @@
     </group>
 
     <group xsi:type="stop" name="Stop High-Level Daemons" title="Stop Daemons for High-Level
Services">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 
@@ -72,6 +73,7 @@
     </group>
 
     <group xsi:type="stop" name="Stop Low-Level Daemons" title="Stop Daemons for Low-Level
Services">
+      <direction>UPGRADE</direction>
       <skippable>true</skippable>
       <service-check>false</service-check>
 


Mime
View raw message