Skip to content

Commit

Permalink
show current deploy stage (#1360)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntascii authored Dec 7, 2023
1 parent 629dfda commit 659ff48
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions deploy-agent/deployd/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def first_run(self):

def _send_deploy_status_stats(self, deploy_report):
if not self._response.deployGoal or not deploy_report:
return
return

tags = {'first_run': self.first_run}
if self._response.deployGoal.deployStage:
tags['deploy_stage'] = self._response.deployGoal.deployStage
Expand All @@ -112,10 +112,10 @@ def _send_deploy_status_stats(self, deploy_report):
tags['stage_name'] = self._response.deployGoal.stageName
if deploy_report.status_code:
tags['status_code'] = deploy_report.status_code
if self._telefig_version:
tags['telefig_version'] = self._telefig_version
if self._telefig_version:
tags['telefig_version'] = self._telefig_version
create_sc_increment('deployd.stats.deploy.status.sum', tags=tags)

def serve_build(self):
"""This is the main function of the ``DeployAgent``.
"""
Expand Down Expand Up @@ -145,7 +145,7 @@ def serve_build(self):
if status.report.wait == None or status.report.wait > 5:
status.report.redeploy = 0
status.report.wait = 0
else:
else:
status.report.wait = status.report.wait + 1
else:
status.report.state = None
Expand All @@ -158,7 +158,7 @@ def serve_build(self):
self._env_status.dump_envs(self._envs)
# start to ping server to get the latest deploy goal
self._response = self._client.send_reports(self._envs)
# we only need to send RESET once in one deploy-agent run
# we only need to send RESET once in one deploy-agent run
if len(self._envs) > 0:
for status in self._envs.values():
if status.report.state == "RESET_BY_SYSTEM":
Expand Down Expand Up @@ -203,7 +203,7 @@ def serve_build(self):

if PingStatus.PING_FAILED == self.update_deploy_status(deploy_report):
return

if deploy_report.status_code in [AgentStatus.AGENT_FAILED,
AgentStatus.TOO_MANY_RETRY,
AgentStatus.SCRIPT_TIMEOUT]:
Expand Down Expand Up @@ -284,6 +284,7 @@ def process_deploy(self, response):
'''
# pause stat_time_elapsed_internal so that external actions are not counted
self.stat_time_elapsed_internal.pause()
log.info(f"The current deploy stage is: {curr_stage}")
if curr_stage == DeployStage.DOWNLOADING:
return self._executor.run_cmd(self.get_download_script(deploy_goal=deploy_goal))
elif curr_stage == DeployStage.STAGING:
Expand Down Expand Up @@ -522,9 +523,9 @@ def main():
is_serverless_mode = AgentRunMode.is_serverless(args.mode)
if args.daemon and is_serverless_mode:
raise ValueError("daemon and serverless mode is mutually exclusive.")

config = Config(filenames=args.config_file)

if IS_PINTEREST:
import pinlogger

Expand All @@ -535,10 +536,10 @@ def main():
logging.basicConfig(filename=log_filename, level=config.get_log_level(),
format='%(asctime)s %(name)s:%(lineno)d %(levelname)s %(message)s')

if not check_prereqs(config):
if not check_prereqs(config):
log.warning("Deploy agent cannot start because the prerequisites on puppet did not meet.")
sys.exit(0)

log.info("Start to run deploy-agent.")
# timing stats - agent start time
create_sc_timing('deployd.stats.internal.time_start_sec',
Expand Down

0 comments on commit 659ff48

Please sign in to comment.