Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback plugin: use utc timezone for now() #186

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions ara/plugins/callback/ara_default.py
Expand Up @@ -271,7 +271,7 @@ def v2_playbook_on_start(self, playbook):
arguments=cli_options,
status="running",
path=path,
started=datetime.datetime.now().isoformat(),
started=datetime.datetime.now(datetime.timezone.utc).isoformat(),
)

# Record the playbook file
Expand Down Expand Up @@ -314,7 +314,7 @@ def v2_playbook_on_play_start(self, play):
status="running",
uuid=play._uuid,
playbook=self.playbook["id"],
started=datetime.datetime.now().isoformat(),
started=datetime.datetime.now(datetime.timezone.utc).isoformat(),
)

return self.play
Expand Down Expand Up @@ -352,14 +352,14 @@ def v2_playbook_on_task_start(self, task, is_conditional, handler=False):
tags=task.tags,
lineno=lineno,
handler=handler,
started=datetime.datetime.now().isoformat(),
started=datetime.datetime.now(datetime.timezone.utc).isoformat(),
)

return self.task

def v2_runner_on_start(self, host, task):
# v2_runner_on_start was added in 2.8 so this doesn't get run for Ansible 2.7 and below.
self.result_started[host.get_name()] = datetime.datetime.now().isoformat()
self.result_started[host.get_name()] = datetime.datetime.now(datetime.timezone.utc).isoformat()

def v2_runner_on_ok(self, result, **kwargs):
self.task_threads.submit(self._load_result, result, "ok", **kwargs)
Expand All @@ -386,7 +386,7 @@ def _end_task(self):
self.client.patch,
"/api/v1/tasks/%s" % self.task["id"],
status="completed",
ended=datetime.datetime.now().isoformat(),
ended=datetime.datetime.now(datetime.timezone.utc).isoformat(),
)
# Flush threads before moving on to next task to make sure all results are saved
self.log.debug("waiting for task threads...")
Expand All @@ -400,7 +400,7 @@ def _end_play(self):
self.client.patch,
"/api/v1/plays/%s" % self.play["id"],
status="completed",
ended=datetime.datetime.now().isoformat(),
ended=datetime.datetime.now(datetime.timezone.utc).isoformat(),
)
self.play = None

Expand All @@ -415,7 +415,7 @@ def _end_playbook(self, stats):
self.client.patch,
"/api/v1/playbooks/%s" % self.playbook["id"],
status=status,
ended=datetime.datetime.now().isoformat(),
ended=datetime.datetime.now(datetime.timezone.utc).isoformat(),
)
self.log.debug("waiting for global threads...")
self.global_threads.shutdown(wait=True)
Expand Down Expand Up @@ -466,7 +466,7 @@ def _load_result(self, result, status, **kwargs):
database.
"""
hostname = result._host.get_name()
self.result_ended[hostname] = datetime.datetime.now().isoformat()
self.result_ended[hostname] = datetime.datetime.now(datetime.timezone.utc).isoformat()

# Retrieve the host so we can associate the result to the host id
host = self._get_or_create_host(hostname)
Expand Down