AMBARI-19037. Clean up logs for the usage of taskId for easy lookup of command progress and status (smohanty)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/707f07f6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/707f07f6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/707f07f6 Branch: refs/heads/branch-feature-AMBARI-18901 Commit: 707f07f637db30b5b9cf26f165fcaaeb51ef0fce Parents: c578a37 Author: Sumit Mohanty <smoha...@hortonworks.com> Authored: Wed Nov 30 14:45:40 2016 -0800 Committer: Sumit Mohanty <smoha...@hortonworks.com> Committed: Wed Nov 30 14:46:12 2016 -0800 ---------------------------------------------------------------------- ambari-agent/src/main/python/ambari_agent/ActionQueue.py | 10 +++++----- .../main/python/ambari_agent/CustomServiceOrchestrator.py | 4 ++-- .../org/apache/ambari/server/agent/HeartBeatHandler.java | 2 +- .../apache/ambari/server/agent/HeartbeatProcessor.java | 2 +- .../server/state/services/RetryUpgradeActionService.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/707f07f6/ambari-agent/src/main/python/ambari_agent/ActionQueue.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py index f104939..3ec0621 100644 --- a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py +++ b/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({ http://git-wip-us.apache.org/repos/asf/ambari/blob/707f07f6/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py index ebd3506..7d61611 100644 --- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py +++ b/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): """ http://git-wip-us.apache.org/repos/asf/ambari/blob/707f07f6/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java index a25b875..75bef30 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java +++ b/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) { http://git-wip-us.apache.org/repos/asf/ambari/blob/707f07f6/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java index 2448c99..8f4782e 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java +++ b/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)); http://git-wip-us.apache.org/repos/asf/ambari/blob/707f07f6/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java b/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java index 72b8ab7..1ea5558 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java +++ b/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); /*