Bläddra i källkod

AMBARI-19037. Clean up logs for the usage of taskId for easy lookup of command progress and status (smohanty)

Sumit Mohanty 8 år sedan
förälder
incheckning
707f07f637

+ 5 - 5
ambari-agent/src/main/python/ambari_agent/ActionQueue.py

@@ -125,7 +125,7 @@ class ActionQueue(threading.Thread):
   def cancel(self, commands):
     for command in commands:
 
-      logger.info("Canceling command {tid}".format(tid = str(command['target_task_id'])))
+      logger.info("Canceling command with taskId = {tid}".format(tid = str(command['target_task_id'])))
       logger.debug(pprint.pformat(command))
 
       task_id = command['target_task_id']
@@ -321,7 +321,7 @@ class ActionQueue(threading.Thread):
         else:
           status = self.FAILED_STATUS
           if (commandresult['exitcode'] == -signal.SIGTERM) or (commandresult['exitcode'] == -signal.SIGKILL):
-            logger.info('Command {cid} was canceled!'.format(cid=taskId))
+            logger.info('Command with taskId = {cid} was canceled!'.format(cid=taskId))
             break
 
       if status != self.COMPLETED_STATUS and retryAble and retryDuration > 0:
@@ -330,17 +330,17 @@ class ActionQueue(threading.Thread):
           delay = retryDuration
         retryDuration -= delay  # allow one last attempt
         commandresult['stderr'] += "\n\nCommand failed. Retrying command execution ...\n\n"
-        logger.info("Retrying command id {cid} after a wait of {delay}".format(cid=taskId, delay=delay))
+        logger.info("Retrying command with taskId = {cid} after a wait of {delay}".format(cid=taskId, delay=delay))
         time.sleep(delay)
         continue
       else:
-        logger.info("Quit retrying for command id {cid}. Status: {status}, retryAble: {retryAble}, retryDuration (sec): {retryDuration}, last delay (sec): {delay}"
+        logger.info("Quit retrying for command with taskId = {cid}. Status: {status}, retryAble: {retryAble}, retryDuration (sec): {retryDuration}, last delay (sec): {delay}"
                     .format(cid=taskId, status=status, retryAble=retryAble, retryDuration=retryDuration, delay=delay))
         break
 
     # final result to stdout
     commandresult['stdout'] += '\n\nCommand completed successfully!\n' if status == self.COMPLETED_STATUS else '\n\nCommand failed after ' + str(numAttempts) + ' tries\n'
-    logger.info('Command {cid} completed successfully!'.format(cid=taskId) if status == self.COMPLETED_STATUS else 'Command {cid} failed after {attempts} tries'.format(cid=taskId, attempts=numAttempts))
+    logger.info('Command with taskId = {cid} completed successfully!'.format(cid=taskId) if status == self.COMPLETED_STATUS else 'Command with taskId = {cid} failed after {attempts} tries'.format(cid=taskId, attempts=numAttempts))
 
     roleResult = self.commandStatuses.generate_report_template(command)
     roleResult.update({

+ 2 - 2
ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py

@@ -97,12 +97,12 @@ class CustomServiceOrchestrator():
       if task_id in self.commands_in_progress.keys():
         pid = self.commands_in_progress.get(task_id)
         self.commands_in_progress[task_id] = reason
-        logger.info("Canceling command with task_id - {tid}, " \
+        logger.info("Canceling command with taskId = {tid}, " \
                     "reason - {reason} . Killing process {pid}"
                     .format(tid=str(task_id), reason=reason, pid=pid))
         shell.kill_process_with_children(pid)
       else: 
-        logger.warn("Unable to find pid by taskId = %s" % task_id)
+        logger.warn("Unable to find process associated with taskId = %s" % task_id)
 
   def get_py_executor(self, forced_command_name):
     """

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java

@@ -329,7 +329,7 @@ public class HeartBeatHandler {
           case BACKGROUND_EXECUTION_COMMAND:
           case EXECUTION_COMMAND: {
             ExecutionCommand ec = (ExecutionCommand)ac;
-            LOG.info("HeartBeatHandler.sendCommands: sending ExecutionCommand for host {}, role {}, roleCommand {}, and command ID {}, task ID {}",
+            LOG.info("HeartBeatHandler.sendCommands: sending ExecutionCommand for host {}, role {}, roleCommand {}, and command ID {}, taskId {}",
                      ec.getHostname(), ec.getRole(), ec.getRoleCommand(), ec.getCommandId(), ec.getTaskId());
             Map<String, String> hlp = ec.getHostLevelParams();
             if (hlp != null) {

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java

@@ -552,7 +552,7 @@ public class HeartbeatProcessor extends AbstractService{
             }
 
             LOG.error("Operation failed - may be retried. Service component host: "
-                + schName + ", host: " + hostname + " Action id " + report.getActionId() + " and Task id " + report.getTaskId());
+                + schName + ", host: " + hostname + " Action id " + report.getActionId() + " and taskId " + report.getTaskId());
             if (actionManager.isInProgressCommand(report)) {
               scHost.handleEvent(new ServiceComponentHostOpFailedEvent
                   (schName, hostname, now));

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java

@@ -199,7 +199,7 @@ public class RetryUpgradeActionService extends AbstractScheduledService {
     List<HostRoleCommandEntity> holdingCommands = m_hostRoleCommandDAO.findByRequestIdAndStatuses(requestId, HOLDING_STATUSES);
     if (holdingCommands.size() > 0) {
       for (HostRoleCommandEntity hrc : holdingCommands) {
-        LOG.debug("Comparing task id: {}, original start time: {}, now: {}",
+        LOG.debug("Comparing taskId: {}, original start time: {}, now: {}",
             hrc.getTaskId(), hrc.getOriginalStartTime(), now);
 
         /*