]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr/devicehealth: fix missing timezone from time delta calculation 45287/head
authorYaarit Hatuka <yaarit@redhat.com>
Mon, 4 Oct 2021 18:50:01 +0000 (18:50 +0000)
committerYaarit Hatuka <yaarit@redhat.com>
Mon, 7 Mar 2022 23:11:13 +0000 (23:11 +0000)
commitfb1c1bfd5fc42ab28ae13e993dc2563e736755a2
tree1c4f4e9bff5f1ce252b06d6731c62d8eec83a1b9
parent2791c920d2f69181e3775d3bcd01f037bae90873
mgr/devicehealth: fix missing timezone from time delta calculation

An error occurs when subtracting a datetime object that is offset-naive
(i.e. unaware of timezone) from a datetime object which is offset-aware.

datetime.utcnow() is missing timezone info, e.g.:
'2021-09-22 13:18:45.021712',
while life_expectancy_max is in the format of:
'2021-09-28 00:00:00.000000+00:00',
hence we need to add timezone info to the former when calculating
their time delta.

Please note that we calculate time delta using `datetime.utcnow()` in
`serve()` in this module, but there we refer to the delta in seconds,
which works fine.

Fixes: https://tracker.ceph.com/issues/52327
Signed-off-by: Yaarit Hatuka <yaarit@redhat.com>
(cherry picked from commit 05902d943bba4a64abbd943270b56cbdd1650e62)

Conflicts:
src/pybind/mgr/devicehealth/module.py
The import typing line needed to be removed
src/pybind/mgr/devicehealth/module.py