Przeglądaj źródła

AMBARI-301. Uninstall should not stop HMC. Contributed by Vikram.

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1343004 13f79535-47bb-0310-9956-ffa450edef68
Jitendra Nath Pandey 13 lat temu
rodzic
commit
81c66aded1

+ 1 - 1
hmc/php/frontend/uninstall/cleanupProcesses.php

@@ -11,7 +11,7 @@ $logger = new HMCLogger("CleanupProcesses");
 $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
 
 function getCommandLine() {
-  $cmdLine = "touch /etc/default/hadoop-env.sh ; killall puppet; killall java; killall jsvc; rm -rf /grid/?/hadoop/*;  rm -rf /var/log/puppet_agent.log; yum erase -y zookeeper* oozie* sqoop* pig* hbase* hadoop* hadoop-conf-pseudo* hdp_mon_dashboard; rm -rf /etc/hadoop/; rm -rf /etc/hbase; rm -rf /etc/oozie; rm -rf /etc/pig; rm -rf /etc/zookeeper; rm -rf /etc/sqoop ; rm -rf /etc/hive ; rm -rf /etc/hcatalog; rm -rf /etc/yum.repos.d/hdp* ; rm -rf /etc/yum.repos.d/cloudera* ; rm -rf /etc/yum.repos.d/cdh* ; rm -rf /var/run/hbase; rm -rf /var/run/zookeeper /var/run/hadoop /var/run/oozie /var/run/templeton /var/run/hive";
+  $cmdLine = "touch /etc/default/hadoop-env.sh ; killall puppet; rm -rf /var/log/puppet_agent.log; rm -rf /etc/yum.repos.d/hdp* ; ";
   $cmdLine = $cmdLine . 'sleep $[ $RANDOM % 5 ]; ';
   return $cmdLine;
 }

+ 0 - 34
hmc/php/frontend/uninstall/deleteLogDirs.php

@@ -1,34 +0,0 @@
-<?php
-
-include_once '../util/Logger.php';
-include_once '../conf/Config.inc';
-include_once 'localDirs.php';
-include_once "../util/lock.php";
-include_once '../db/HMCDBAccessor.php';
-include_once './uninstall/uninstallUtil.php';
-
-$logger = new HMCLogger("CleanupLogDirs");
-$dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
-
-function getCommandLine() {
-  $cmdLine = "rm -rf /var/log/hadoop /var/log/hbase /var/log/zookeeper /var/log/hive /var/log/oozie /var/log/templeton /grid/?/hadoop /grid/?/hdp ";
-  $cmdLine = $cmdLine . 'sleep $[ $RANDOM % 5 ]; ';
-  return $cmdLine;
-}
-
-$clusterName = $argv[1];
-$deployUser = $argv[2];
-$rootTxnId = $argv[3];
-$mySubTxnId = $argv[4];
-$parentSubTxnId = $argv[5];
-$hostsStr = $argv[6];
-
-$cmdLine = getCommandLine();
-// stage name should match corr. stage in stages.php
-$stageName = "LogCleanup";
-
-handleUninstallTransaction($clusterName, $deployUser, $rootTxnId,
-  $mySubTxnId, $parentSubTxnId, $hostsStr,
-  $stageName, $cmdLine, $dbAccessor, $logger);
-
-?>

+ 0 - 8
hmc/php/frontend/uninstall/stages.php

@@ -5,14 +5,6 @@ $stagesInfo = array(
       "description" => "Cleaning up processes",
       "scriptName" => "./uninstall/cleanupProcesses.php",
       ),
-    "YumCleanupAndHttpDStop" => array(
-      "description" => "Yum cleanup and httpd stop",
-      "scriptName" => "./uninstall/yumCleanupHttpdStop.php",
-      ),
-    "LogCleanup" => array(
-      "description" => "Log directories cleanup",
-      "scriptName" => "./uninstall/deleteLogDirs.php",
-      ),
     );
 
 ?>

+ 0 - 34
hmc/php/frontend/uninstall/yumCleanupHttpdStop.php

@@ -1,34 +0,0 @@
-<?php
-
-include_once '../util/Logger.php';
-include_once '../conf/Config.inc';
-include_once 'localDirs.php';
-include_once "../util/lock.php";
-include_once '../db/HMCDBAccessor.php';
-include_once './uninstall/uninstallUtil.php';
-
-$logger = new HMCLogger("YumCleanupAndHttpdStop");
-$dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
-
-function getCommandLine() {
-  $cmdLine = "yum erase -y  hadoop-conf-pseudo* hdp_mon_dashboard* ganglia* rrd* gweb* hdp_* nagios*; yum erase -y  hbase* ; service httpd stop; ";
-  $cmdLine = $cmdLine . 'sleep $[ $RANDOM % 5 ]; ';
-  return $cmdLine;
-}
-
-$clusterName = $argv[1];
-$deployUser = $argv[2];
-$rootTxnId = $argv[3];
-$mySubTxnId = $argv[4];
-$parentSubTxnId = $argv[5];
-$hostsStr = $argv[6];
-// stage name should match corr. stage in stages.php
-$stageName = "YumCleanupAndHttpDStop";
-
-$cmdLine = getCommandLine();
-
-handleUninstallTransaction($clusterName, $deployUser, $rootTxnId,
-  $mySubTxnId, $parentSubTxnId, $hostsStr,
-  $stageName, $cmdLine, $dbAccessor, $logger);
-
-?>

+ 26 - 14
hmc/php/frontend/uninstallCleanup.php

@@ -19,7 +19,7 @@ $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
 // status of the completed state
 function deBootStrap ($clusterName, $deployUser, $stageInfo)
 {
-  global $logger, $dbAccessor;
+  global $logger, $dbAccessor, $stagesInfo;
 
   /////// launch the stages in the background.
   $stagesFile = "./uninstall/stages.php";
@@ -56,7 +56,6 @@ function deBootStrap ($clusterName, $deployUser, $stageInfo)
 
   $allDone = false;
   while ($allDone == false) {
-    sleep(2);
     // use the txn id for finding the status to pass back to the user
     // the orchestrator txn id could potentially return an error because
     // there is a potential race condition before the orchestrator txnId has
@@ -69,8 +68,11 @@ function deBootStrap ($clusterName, $deployUser, $stageInfo)
         json_encode($orchestratorTxnId));
       // Check if this should return error FIXME
       // $jsonOutput['encounteredError'] = true;
-      return ($jsonOutput);
+      return (array('result' => 1, 'error' => $orchestratorTxnId['error']));
     }
+    // as soon as DB is read, sleep for 2 seconds because we want to 
+    // avoid continuous polling of the db
+    sleep(2);
 
     //$logger->log_error(" ==== subTxns info is  " . json_encode($orchestratorTxnId));
     $keys = array_keys($orchestratorTxnId['subTxns']);
@@ -95,24 +97,34 @@ function deBootStrap ($clusterName, $deployUser, $stageInfo)
       return ($jsonOutput);
     }
 
-    $jsonOutput['currentProgressStateIndex'] = count($allSubTxns['subTxns']) - 1;
-    if ($jsonOutput['currentProgressStateIndex'] < 0) {
-      $jsonOutput['currentProgressStateIndex'] = 0;
+    $logger->log_debug("allsubtxn count is ".json_encode(count($allSubTxns['subTxns'])));
+    $logger->log_debug("stages count is ".json_encode(count($stagesInfo)));
+    $logger->log_debug("subtxns ".json_encode($allSubTxns));
+    // allDone must be set once the processes launched have completed running
+    if ((count($allSubTxns['subTxns']) == count($stagesInfo))) {
+      $lastTxn = end($allSubTxns['subTxns']);
+      if (($lastTxn['opStatus'] == "SUCCESS")) {
+        $allDone = true;
+        $result = 0;
+        $error = "";
+        // remove the following 2 lines FIXME
+        $error = "Not a failure! LOL";
+        $result = 1;
+      } else if (($lastTxn['opStatus'] == "FAILED") || 
+          ($lastTxn['opStatus'] == "TOTALFAILURE")) {
+        $logger->log_debug("");
+        $allDone = true;
+        $error = json_encode($lastTxn['state']);
+        $result = 1;
+      }
     }
-    $jsonOutput['stateInfo'] = $allSubTxns;
-    // Decode log information store as part of state.
-    foreach ($jsonOutput['stateInfo']['subTxns'] as $subTxnId => $subTxnInfo) {
-      $jsonOutput['stateInfo']['subTxns'][$subTxnId]['state'] = json_decode($jsonOutput['stateInfo']['subTxns'][$subTxnId]['state']);
-    }
-
-    $allDone = true;
   }
   /////// done monitoring return back to the uninstall
   
   // need to cleanup db for this cluster
   $dbAccessor->deleteCluster($clusterName);
   
-  return array('result' => 0);
+  return array('result' => $result, 'error' => $error);
 }
 
 ?>