From e22edc5f02d7385fa619cfc4022653c7c90b3037 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Wed, 5 Jun 2024 08:36:12 +0200 Subject: [PATCH] pybind/rbd: parse access and modify timestamps in UTC It appears that commits 08cee16d0a4b ("pybind/rbd: always parse timestamps in UTC") and 809c5430c292 ("librbd: add image access/last modified timestamps") raced with each other and we ended up with two more timezone-dependent timestamps. Fixes: https://tracker.ceph.com/issues/66359 Signed-off-by: Ilya Dryomov (cherry picked from commit fafa911b51199f61d0c97bc6dfc71d4f65134db4) --- PendingReleaseNotes | 2 ++ src/pybind/rbd/rbd.pyx | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 1f0260b395fc4..0898697b2ed45 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -209,6 +209,8 @@ CephFS: Disallow delegating preallocated inode ranges to clients. Config * Monitoring: RGW S3 Analytics: A new Grafana dashboard is now available, enabling you to visualize per bucket and user analytics data, including total GETs, PUTs, Deletes, Copies, and list metrics. +* RBD: `Image::access_timestamp` and `Image::modify_timestamp` Python APIs now + return timestamps in UTC. * RBD: Support for cloning from non-user type snapshots is added. This is intended primarily as a building block for cloning new groups from group snapshots created with `rbd group snap create` command, but has also been diff --git a/src/pybind/rbd/rbd.pyx b/src/pybind/rbd/rbd.pyx index c261daf9ecc6e..2221cafca9ae6 100644 --- a/src/pybind/rbd/rbd.pyx +++ b/src/pybind/rbd/rbd.pyx @@ -4126,7 +4126,7 @@ written." % (self.name, ret, length)) ret = rbd_get_access_timestamp(self.image, ×tamp) if ret != 0: raise make_ex(ret, 'error getting access timestamp for image: %s' % (self.name)) - return datetime.fromtimestamp(timestamp.tv_sec) + return datetime.utcfromtimestamp(timestamp.tv_sec) @requires_not_closed def modify_timestamp(self): @@ -4139,7 +4139,7 @@ written." % (self.name, ret, length)) ret = rbd_get_modify_timestamp(self.image, ×tamp) if ret != 0: raise make_ex(ret, 'error getting modify timestamp for image: %s' % (self.name)) - return datetime.fromtimestamp(timestamp.tv_sec) + return datetime.utcfromtimestamp(timestamp.tv_sec) @requires_not_closed def flatten(self, on_progress=None): -- 2.39.5