]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fixing RBD purge error in backend
authorKiefer Chang <kiefer.chang@suse.com>
Thu, 23 Apr 2020 10:09:15 +0000 (18:09 +0800)
committerKiefer Chang <kiefer.chang@suse.com>
Thu, 30 Apr 2020 03:12:35 +0000 (11:12 +0800)
Current UTC datetime should be used as `now`, otherwise the expiration
comparison might fail on machines with non-UTC localtime.

Fixes: https://tracker.ceph.com/issues/45149
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
(cherry picked from commit 00881adf55cac6116887bfffc506444473f0ee82)

Conflicts:
src/pybind/mgr/dashboard/controllers/rbd.py
- Namespace is not supported nautilus.
- Use logger instance from mgr.

src/pybind/mgr/dashboard/controllers/rbd.py

index 24c068a7e5f672de72c926f73997585eb9bff128..8555a35ea12542d807a76815d6a725709f76b2b6 100644 (file)
@@ -13,7 +13,7 @@ import rbd
 
 from . import ApiController, RESTController, Task, UpdatePermission, \
               DeletePermission, CreatePermission, ReadPermission
-from .. import mgr
+from .. import mgr, logger
 from ..security import Scope
 from ..services.ceph_service import CephService
 from ..services.rbd import RbdConfiguration, format_bitmask, format_features
@@ -485,12 +485,14 @@ class RbdTrash(RESTController):
     @DeletePermission
     def purge(self, pool_name=None):
         """Remove all expired images from trash."""
-        now = "{}Z".format(datetime.now().isoformat())
+        now = "{}Z".format(datetime.utcnow().isoformat())
         pools = self._trash_list(pool_name)
 
         for pool in pools:
             for image in pool['value']:
                 if image['deferment_end_time'] < now:
+                    logger.info('Removing trash image %s (pool=%s, name=%s)',
+                                image['id'], pool['pool_name'], image['name'])
                     _rbd_call(pool['pool_name'], self.rbd_inst.trash_remove, image['id'], 0)
 
     @RbdTask('trash/restore', ['{pool_name}', '{image_id}', '{new_image_name}'], 2.0)