Selaa lähdekoodia

AMBARI-377. Uninstall does not handle component dependencies. (Contributed by Jitendra)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1347144 13f79535-47bb-0310-9956-ffa450edef68
Vikram Dixit K 13 vuotta sitten
vanhempi
commit
6eb2a76756

+ 2 - 0
CHANGES.txt

@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-377. Uninstall does not handle component dependencies. (Jitendra via Vikram)
+
   AMBARI-380. Clean up messages for Add Nodes and Deploy progress result (Yusaku via Vikram)
 
   AMBARI-379. Remove puppet start stub on uninstall. (Mahadev via Vikram)

+ 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 = " killall puppet ; rm -rf /var/lib/puppet/ssl ; ";
+  $cmdLine = " killall puppet ; ";
   return $cmdLine;
 }
 

+ 39 - 0
hmc/php/puppet/genmanifest/PuppetClassDependencies.php

@@ -45,6 +45,11 @@ class PuppetClassDependencies {
     $this->addDependency("hdp-hbase::master", SERVICE_STATE_RUNNING, "hdp-hadoop::client",
         array("service_state" => SERVICE_STATE_NO_OP));
 
+    $this->addDependency("hdp-hbase::master", SERVICE_STATE_UNINSTALLED, "hdp-zookeeper::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+    $this->addDependency("hdp-hbase::master", SERVICE_STATE_UNINSTALLED, "hdp-hadoop::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+
     $this->addDependency("hdp-hbase::regionserver", SERVICE_STATE_INSTALLED_AND_CONFIGURED, "hdp-zookeeper::client",
         array("service_state" => SERVICE_STATE_INSTALLED_AND_CONFIGURED));
     $this->addDependency("hdp-hbase::regionserver", SERVICE_STATE_INSTALLED_AND_CONFIGURED, "hdp-hadoop::client",
@@ -55,19 +60,31 @@ class PuppetClassDependencies {
     $this->addDependency("hdp-hbase::regionserver", SERVICE_STATE_RUNNING, "hdp-hadoop::client",
         array("service_state" => SERVICE_STATE_NO_OP));
 
+    $this->addDependency("hdp-hbase::regionserver", SERVICE_STATE_UNINSTALLED, "hdp-zookeeper::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+    $this->addDependency("hdp-hbase::regionserver", SERVICE_STATE_UNINSTALLED, "hdp-hadoop::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+
     //Oozie
     $this->addDependency("hdp-oozie::server", SERVICE_STATE_INSTALLED_AND_CONFIGURED, "hdp-hadoop::client",
         array("service_state" => SERVICE_STATE_INSTALLED_AND_CONFIGURED));
     $this->addDependency("hdp-oozie::server", SERVICE_STATE_RUNNING, "hdp-hadoop::client",
         array("service_state" => SERVICE_STATE_NO_OP));
+    $this->addDependency("hdp-oozie::server", SERVICE_STATE_UNINSTALLED, "hdp-hadoop::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
 
     //Hive depends on Hcat
     $this->addDependency("hdp-hive::server", SERVICE_STATE_INSTALLED_AND_CONFIGURED, "hdp-hcat",
         array("service_state" => SERVICE_STATE_INSTALLED_AND_CONFIGURED));
     $this->addDependency("hdp-hive::server", SERVICE_STATE_RUNNING, "hdp-hcat",
         array("service_state" => SERVICE_STATE_NO_OP));
+    $this->addDependency("hdp-hive::server", SERVICE_STATE_UNINSTALLED, "hdp-hcat",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+
     $this->addDependency("hdp-hive::client", SERVICE_STATE_INSTALLED_AND_CONFIGURED, "hdp-hcat",
         array("service_state" => SERVICE_STATE_INSTALLED_AND_CONFIGURED));
+    $this->addDependency("hdp-hive::client", SERVICE_STATE_UNINSTALLED, "hdp-hcat",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
 
     //Hive Service Check
     $this->addDependency("hdp-hive::hive::service_check", SERVICE_STATE_NOT_APPLICABLE, 
@@ -77,10 +94,16 @@ class PuppetClassDependencies {
     $this->addDependency("hdp-pig", SERVICE_STATE_INSTALLED_AND_CONFIGURED, "hdp-hadoop::client",
         array("service_state" => SERVICE_STATE_INSTALLED_AND_CONFIGURED));
 
+    $this->addDependency("hdp-pig", SERVICE_STATE_UNINSTALLED, "hdp-hadoop::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+
     //Sqoop
     $this->addDependency("hdp-sqoop", SERVICE_STATE_INSTALLED_AND_CONFIGURED, "hdp-hadoop::client",
         array("service_state" => SERVICE_STATE_INSTALLED_AND_CONFIGURED));
 
+    $this->addDependency("hdp-sqoop", SERVICE_STATE_UNINSTALLED, "hdp-hadoop::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+
     //Templeton
     $this->addDependency("hdp-templeton::server", SERVICE_STATE_INSTALLED_AND_CONFIGURED, "hdp-zookeeper::client",
         array("service_state" => SERVICE_STATE_INSTALLED_AND_CONFIGURED));
@@ -100,6 +123,15 @@ class PuppetClassDependencies {
     $this->addDependency("hdp-templeton::server", SERVICE_STATE_RUNNING, "hdp-hcat",
         array("service_state" => SERVICE_STATE_NO_OP));
 
+    $this->addDependency("hdp-templeton::server", SERVICE_STATE_UNINSTALLED, "hdp-zookeeper::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+    $this->addDependency("hdp-templeton::server", SERVICE_STATE_UNINSTALLED, "hdp-hadoop::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+    $this->addDependency("hdp-templeton::server", SERVICE_STATE_UNINSTALLED, "hdp-pig",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+    $this->addDependency("hdp-templeton::server", SERVICE_STATE_UNINSTALLED, "hdp-hcat",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+
     //Ganglia
     $this->addDependency("hdp-ganglia::monitor", SERVICE_STATE_RUNNING, "hdp-ganglia::hdp-gmond::service_check", array());
     $this->addDependency("hdp-ganglia::monitor_and_server", SERVICE_STATE_RUNNING, "hdp-ganglia::hdp-gmond::service_check", array());
@@ -121,6 +153,13 @@ class PuppetClassDependencies {
     $this->addDependency("hdp-nagios::server", SERVICE_STATE_RUNNING, "hdp-hive::client",
         array("service_state" => SERVICE_STATE_NO_OP));
 
+    $this->addDependency("hdp-nagios::server", SERVICE_STATE_UNINSTALLED, "hdp-oozie::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+    $this->addDependency("hdp-nagios::server", SERVICE_STATE_UNINSTALLED, "hdp-hcat",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+    $this->addDependency("hdp-nagios::server", SERVICE_STATE_UNINSTALLED, "hdp-hive::client",
+        array("service_state" => SERVICE_STATE_UNINSTALLED));
+
     $this->addDependency("hdp-nagios::server", SERVICE_STATE_RUNNING, "hdp-nagios::nagios::service_check", array());
     $this->addDependency("hdp-nagios::server", SERVICE_STATE_RUNNING, "hdp-monitor-webserver", array());
 

+ 43 - 7
hmc/php/puppet/genmanifest/generateManifest.php

@@ -41,10 +41,9 @@ include "RoleDependencies.php";
                  $serviceState);
          foreach ($hostLevelDependencies as $depRole => $rstates) {
            $roleList[] = $depRole;
-           foreach ($rstates as $k => $v) {
-             //Assuming no conflicting states
-             $rolesStates[$depRole][$k] = $v;
-           }
+           //The state could be conflicting, pick the appropriate state
+           //e.g. a dependency shows up with two different service states
+           ManifestGenerator::resolveDepRoleStates($depRole, $rstates, $rolesStates);
          }
        }
        $roleList = array_unique($roleList);
@@ -67,7 +66,44 @@ include "RoleDependencies.php";
      fclose($fh);
    }
 
-   static function optimizePackageInstall($node, &$manifestObj, $rolesStatesDs, 
+   private static function priorityState($u, $v) {
+     $order = array (
+       SERVICE_STATE_NOT_APPLICABLE => 0,
+       SERVICE_STATE_UNINSTALLED => 1,
+       SERVICE_STATE_STOPPED => 2,
+       SERVICE_STATE_NO_OP => 3,
+       SERVICE_STATE_INSTALLED_AND_CONFIGURED => 4,
+       SERVICE_STATE_RUNNING => 5
+     );
+
+     if (!isset($v)) {
+       return $u;
+     } else if (!isset($u)) {
+       return $v;
+     } else if ($order[$u] > $order[$v]) {
+       return $u;
+     } else {
+       return $v;
+     }
+   }
+
+   private static function resolveDepRoleStates($depRole, $rstates, &$rolesStates) {
+     foreach ($rstates as $k => $v) {
+       if ($k == SERVICE_STATE_KEY) {
+         $alreadySetSvcState = NULL;
+         if (isset($rolesStates[$depRole][$k])) {
+           $alreadySetSvcState = $rolesStates[$depRole][$k]; 
+         }
+         $rolesStates[$depRole][$k] = 
+             ManifestGenerator::priorityState($v, $alreadySetSvcState);
+       } else {
+         //Assume no conflicts for this key
+         $rolesStates[$depRole][$k] = $v;
+       }
+     }
+   }
+
+   private static function optimizePackageInstall($node, &$manifestObj, $rolesStatesDs, 
        $configInfo, $roleStages) {
      //Figure out the state
      $serviceState = SERVICE_STATE_INSTALLED_AND_CONFIGURED;
@@ -171,8 +207,8 @@ include "RoleDependencies.php";
      "hdp-hadoop::client" => "hadoop hadoop-libhdfs.i386 hadoop-native.i386 hadoop-pipes.i386 hadoop-sbin.i386",
      "hdp-hadoop::datanode" => "hadoop hadoop-libhdfs.i386 hadoop-native.i386 hadoop-pipes.i386 hadoop-sbin.i386",
      "hdp-hadoop::tasktracker" => "hadoop hadoop-libhdfs.i386 hadoop-native.i386 hadoop-pipes.i386 hadoop-sbin.i386",
-     "hdp-hadoop::zookeeper" => "zookeeper",
-     "hdp-hadoop::zookeeper::client" => "zookeeper",
+     "hdp-zookeeper" => "zookeeper",
+     "hdp-zookeeper::client" => "zookeeper",
      "hdp-hbase::master" => "hbase",
      "hdp-hbase::regionserver" => "hbase",
      "hdp-hbase::client" => "hbase",