Browse Source

AMBARI-241. Support cluster wipeout in orchestrator. Contributed by Hitesh Shah.

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1339459 13f79535-47bb-0310-9956-ffa450edef68
Jitendra Nath Pandey 13 years ago
parent
commit
4eb9ce648e

+ 2 - 0
CHANGES.txt

@@ -2,6 +2,8 @@ Ambari Change log
 
 Release 0.x.x - unreleased
 
+  AMBARI-241. Support cluster wipeout in orchestrator. (Hitesh via jitendra)
+
   AMBARI-292. HTML being spewed in the Review+Deploy page. (Varun Kapoor via jitendra)
 
   AMBARI-291. Fix yui packaging in the rpm. (jitendra)

+ 24 - 13
hmc/php/orchestrator/Cluster.php

@@ -66,6 +66,8 @@ class Cluster {
       $this->logger->log_error("Failed to get cluster services.");
       return array("result" => -1, "error" => "Failed to get cluster services from DB.");
     }
+    $n = count($services);
+    $this->logger->log_info("Deploying HDP with $n services.... DryRun=$dryRun");
     $result = $this->_installAllServices($services,
         $transaction->createSubTransaction(), $dryRun);
     if ($result['result'] !== 0) {
@@ -82,7 +84,8 @@ class Cluster {
     return $result;
   }
 
-  private function _uninstallAllServices($services, $transaction, $dryRun) {
+  private function _uninstallAllServices($services, $transaction, $dryRun,
+      $wipeoutData = FALSE) {
     $n = count($services);
     $this->logger->log_info("Uninstalling HDP with $n services.... DryRun=$dryRun");
     $this->setState(State::UNINSTALLING, $transaction, $dryRun);
@@ -115,7 +118,7 @@ class Cluster {
       }
       $nodes = $result["nodes"];
       $result = $this->puppet->kickPuppet($nodes, $transaction, $this->name,
-          $result["componentMapping"]);
+          $result["componentMapping"], array ("wipeoutData" => $wipeoutData));
       $this->logger->log_debug("Puppet kick response for uninstalling "
           . "cluster=" . $this->name
           . ", txn=" . $transaction->toString()
@@ -157,12 +160,13 @@ class Cluster {
    return array("result" => 0, "error" => "");
   }
 
-  private function _uninstallAll($transaction, $dryRun) {
+  private function _uninstallAll($transaction, $dryRun, $wipeoutData = FALSE) {
     $services = $this->db->getClusterServices();
     if ($services == FALSE) {
       $this->logger->log_error("Failed to get cluster services.");
       return array("result" => -1, "error" => "Failed to get cluster services from DB.");
     }
+    $this->logger->log_info("Uninstalling HDP.... DryRun=$dryRun");
     $result = $this->_stopAllServices($services,
         $transaction->createSubTransaction(), $dryRun);
     if ($result['result']  !== 0) {
@@ -170,7 +174,7 @@ class Cluster {
       return $result;
     }
     $result = $this->_uninstallAllServices($services,
-        $transaction->createSubTransaction(), $dryRun);
+        $transaction->createSubTransaction(), $dryRun, $wipeoutData);
     if ($result['result']  !== 0) {
       $this->logger->log_error("Failed to uninstall services.");
       return $result;
@@ -182,16 +186,19 @@ class Cluster {
    * Function to stop & uninstall HDP across the whole cluster
    * @param transaction transactionId for the operation
    */
-  public function uninstallHDP($transaction) {
-    $this->currentAction = "UNINSTALL";
+  public function uninstallHDP($transaction, $wipeoutData = FALSE) {
+    $this->currentAction = "Uninstall";
+    $this->logger->log_info("Uninstalling HDP, wipeoutDataFlag="
+        . $wipeoutData);
 
-    // Don't care about either DB states or error handling
-    $this->_uninstallAll($transaction->createSubTransaction(), TRUE);
+    $this->_uninstallAll($transaction->createSubTransaction(), TRUE,
+        $wipeoutData);
 
     $this->resetSubTxnId();
     $this->db->reset();
 
-    $this->_uninstallAll($transaction->createSubTransaction(), FALSE);
+    return $this->_uninstallAll($transaction->createSubTransaction(), FALSE,
+        $wipeoutData);
   }
 
   /**
@@ -259,7 +266,7 @@ class Cluster {
       return $result;
     }
     $result = $this->_restartDashboardAndNagios($transaction->createSubTransaction(),
-        $dryRun);
+        TRUE);
     if ($result['result'] !== 0) {
       return $result;
     }
@@ -279,7 +286,7 @@ class Cluster {
     }
 
     $result = $this->_restartDashboardAndNagios($transaction->createSubTransaction(),
-        $dryRun);
+        FALSE);
 
     return $result;
   }
@@ -362,7 +369,7 @@ class Cluster {
   }
 
   private function _installNodes($transaction, $hostCompMapping, $dryRun) {
-    $this->logger->log_info("INSTALL NODES dryRun=" . $dryRun);
+    $this->logger->log_info("Installing on nodes dryRun=" . $dryRun);
     $this->currentAction = "InstallNodes";
     $hostsToInstall = array();
     $allHosts = array();
@@ -437,7 +444,7 @@ class Cluster {
   }
 
   private function _startNodes($transaction, $hostCompMapping, $dryRun) {
-    $this->logger->log_info("START NODES dryRun=" . $dryRun);
+    $this->logger->log_info("Starting nodes dryRun=" . $dryRun);
 
     $this->currentAction = "StartNodes";
     $hostsToStart = array();
@@ -628,6 +635,8 @@ class Cluster {
    */
   public function startAllServices($transaction) {
     $services = $this->db->getClusterServices();
+    $n = count($services);
+    $this->logger->log_info("Starting $n services");
     $result = $this->_startAllServices($services, $transaction, TRUE);
     if ($result['result'] !== 0) {
       return $result;
@@ -671,6 +680,8 @@ class Cluster {
    */
   public function stopAllServices($transaction) {
     $services = $this->db->getClusterServices();
+    $n = count($services);
+    $this->logger->log_info("Stopping $n services");
     $result = $this->_stopAllServices($services, $transaction, TRUE);
     if ($result['result'] !== 0) {
       return $result;

+ 8 - 3
hmc/php/orchestrator/ClusterMain.php

@@ -20,7 +20,7 @@ Usage:
   -x/--txn-id             Transaction ID
   -d/--db-path            DB Path
   -a/--action             Action - deploy, deployNode, startAll, stopAll,
-                          uninstallAll, reconfigure
+                          uninstallAll, reconfigure, wipeout
   -s/--service            Service - names of services
   -n/--node               Node - hostname of node to take action on
   -r/--dry-run            Dry-run only
@@ -55,7 +55,8 @@ $ACTIONS = array (
   "uninstallAll",
   "start",
   "stop",
-  "reconfigure"
+  "reconfigure",
+  "wipeout"
 );
 
 function validateAndCreateDBHandle($dbPath) {
@@ -309,7 +310,11 @@ if ($action == "deploy") {
 } else if ($action == "stopAll") {
   $result = $cluster->stopAllServices($transaction);
 } else if ($action == "uninstallAll") {
-  $result = $cluster->uninstallHDP($transaction);
+  $wipeoutData = FALSE;
+  $result = $cluster->uninstallHDP($transaction, $wipeoutData);
+} else if ($action == "wipeout") {
+  $wipeoutData = TRUE;
+  $result = $cluster->uninstallHDP($transaction, $wipeoutData);
 } else if ($action == "start") {
   $result = $cluster->startServices($transaction, $serviceNames);
 } else if ($action == "stop") {

+ 9 - 5
hmc/php/orchestrator/HMC.php

@@ -505,15 +505,19 @@ class HMC {
     return $response;
   }
 
-  public function uninstallHDP() {
-    $this->logger->log_debug("Triggering uninstall"
+  public function uninstallHDP($wipeoutData = FALSE) {
+    $this->logger->log_info("Triggering uninstall"
          . ", clusterName=" . $this->clusterName
          );
     $action = "uninstallHDP";
-    $msg = "Uninstalling cluster";
+    $msg = "Uninstalling cluster, wipeout=" . $wipeoutData;
     $args = " -c " . $this->clusterName
-        . " -d " . $this->dbPath
-        . " -a uninstallAll ";
+        . " -d " . $this->dbPath;
+    if (!$wipeoutData) {
+      $args .= " -a uninstallAll ";
+    } else {
+      $args .= " -a wipeout ";
+    }
     return $this->internalTrigger($action, $msg, $args);
   }
 

+ 1 - 1
hmc/php/orchestrator/Service.php

@@ -300,7 +300,7 @@ class Service {
       return array("result" => 0, "error" => "");
     }
 
-    // Ensure state is INSTALLED or STOPPED
+    // Ensure state is INSTALLED or STOPPED or FAILED
     if ($this->state !== State::INSTALLED
         && $this->state !== State::STARTING
         && $this->state !== State::STOPPING

+ 1 - 0
hmc/php/puppet/PuppetInvoker.php

@@ -200,6 +200,7 @@
       $this->writeVersionFile($versionFile, $txnId);
 
       if ($dryRun) {
+        $successfullNodes = $nodes;
         return $this->createGenKickWaitResponse($kickFailedNodes, $failureResponseNodes,
            $timedoutNodes, $successfullNodes, $nodes);
       }