]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/rbd: parse access and modify timestamps in UTC
authorIlya Dryomov <idryomov@gmail.com>
Wed, 5 Jun 2024 06:36:12 +0000 (08:36 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 5 Jun 2024 06:50:40 +0000 (08:50 +0200)
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 <idryomov@gmail.com>
PendingReleaseNotes
src/pybind/rbd/rbd.pyx

index 45b43c12fb58b0fc7d5f6a8965927b70193bfb66..e07d02f334fe2f627e5a1e380c1b3132c0b2b9e5 100644 (file)
@@ -224,6 +224,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.
 
 >=18.0.0
 
index df176a410a940058cc5b95dab4280995ec2fe25e..7d1da388eb93b8ec1fa48fd106b746dcce023869 100644 (file)
@@ -4094,7 +4094,7 @@ written." % (self.name, ret, length))
             ret = rbd_get_access_timestamp(self.image, &timestamp)
         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):
@@ -4107,7 +4107,7 @@ written." % (self.name, ret, length))
             ret = rbd_get_modify_timestamp(self.image, &timestamp)
         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):