Correctly handle the timezone in batch job logs (#4604)

This commit is contained in:
Chih-Hsuan Yen 2021-11-20 18:38:48 +08:00 committed by GitHub
parent 88e1aef254
commit c7a9dc32e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -583,7 +583,11 @@ class Job(threading.Thread, BaseModel, DockerModel):
logs = []
for line in logs_stdout + logs_stderr:
date, line = line.split(" ", 1)
date_obj = dateutil.parser.parse(date, ignoretz=True)
date_obj = (
dateutil.parser.parse(date)
.astimezone(datetime.timezone.utc)
.replace(tzinfo=None)
)
date = unix_time_millis(date_obj)
logs.append({"timestamp": date, "message": line.strip()})