You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vi...@apache.org on 2012/06/07 03:03:10 UTC

svn commit: r1347242 - in /incubator/ambari/branches/ambari-186: CHANGES.txt hmc/php/puppet/PuppetInvoker.php

Author: vikram
Date: Thu Jun  7 01:03:09 2012
New Revision: 1347242

URL: http://svn.apache.org/viewvc?rev=1347242&view=rev
Log:
AMBARI-438. Add retry if kick fails immediately. (Contributed by Jitendra)

Modified:
    incubator/ambari/branches/ambari-186/CHANGES.txt
    incubator/ambari/branches/ambari-186/hmc/php/puppet/PuppetInvoker.php

Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1347242&r1=1347241&r2=1347242&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Thu Jun  7 01:03:09 2012
@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-438. Add retry if kick fails immediately. (Jitendra via Vikram)
+
   AMBARI-437. Update router to handle resuming uninstall progress and uninstall failed pages (Yusaku via Vikram)
 
   AMBARI-436. Support Resume For Uninstall (Varun via Vikram)

Modified: incubator/ambari/branches/ambari-186/hmc/php/puppet/PuppetInvoker.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/puppet/PuppetInvoker.php?rev=1347242&r1=1347241&r2=1347242&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/puppet/PuppetInvoker.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/puppet/PuppetInvoker.php Thu Jun  7 01:03:09 2012
@@ -55,15 +55,15 @@
           $p = count($nodes);
         }
         $cmd = $cmd . " --parallel " . $p;
-        $this->logger->log_trace("Kick command: " . $cmd);
+        $this->logger->log_debug("Kick command: " . $cmd);
         $output = $this->executeAndGetOutput($cmd);
-        $this->logger->log_trace("Kick response begins ===========");
-        $this->logger->log_trace($output);
-        $this->logger->log_trace("Kick response ends ===========");
+        $this->logger->log_debug("Kick response begins ===========");
+        $this->logger->log_debug($output);
+        $this->logger->log_debug("Kick response ends ===========");
       }
       foreach ($nodes as $kNode) {
         if (isset($doneNodes[$kNode])) {
-          $this->logger->log_debug($kNode . "previous kick has returned, no need to kick again");
+          $this->logger->log_debug($kNode . " previous kick has returned, no need to kick again");
           //Mark as previous kick running, reports will be discovered in waitForResults.
           $prevKickRunningNodes[] = $kNode;
           continue;
@@ -82,6 +82,24 @@
       }
     }
 
+    private function sendKickWithRetry($nodes, $txnId, &$failedNodes,
+        &$successNodes, &$prevKickRunningNodes) {
+      $kickFailedNodes = array();
+      $this->sendKick($nodes, $txnId, $kickFailedNodes,
+          $successNodes, $prevKickRunningNodes);
+      if (!empty($kickFailedNodes)) {
+        $this->logger->log_warn("Retrying kick after 10 seconds on " . print_r($kickFailedNodes, TRUE));
+        sleep(10);
+        $nodesToKick = $kickFailedNodes;
+        $kickFailedNodes = array();
+        $this->sendKick($nodesToKick, $txnId, $kickFailedNodes,
+            $successNodes, $prevKickRunningNodes);
+      }
+      foreach ($kickFailedNodes as $fn) {
+        $failedNodes[] = $fn;
+      }
+    }
+
     private function kickPuppetAsync($nodes, $txnId, &$kickFailedNodes, &$kickSuccessNodes, 
         &$prevKickRunningNodes) {
       $nodeListToKick = array();
@@ -91,7 +109,7 @@
           $nodeListToKick[] = $n;
           $index++;
         } else {
-          $this->sendKick($nodeListToKick, $txnId, $kickFailedNodes,
+          $this->sendKickWithRetry($nodeListToKick, $txnId, $kickFailedNodes,
               $kickSuccessNodes, $prevKickRunningNodes);
           $nodeListToKick = array();
           $nodeListToKick[] = $n;
@@ -99,7 +117,7 @@
         }
       }
       if ($index > 0) {
-          $this->sendKick($nodeListToKick, $txnId, $kickFailedNodes,
+          $this->sendKickWithRetry($nodeListToKick, $txnId, $kickFailedNodes,
             $kickSuccessNodes, $prevKickRunningNodes);
       }
     }