From: Kiefer Chang Date: Thu, 23 Apr 2020 10:09:15 +0000 (+0800) Subject: mgr/dashboard: fixing RBD purge error in backend X-Git-Tag: v14.2.10~80^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=88661f044eaa8ab6f42a77ef30b06600004261fa;p=ceph.git mgr/dashboard: fixing RBD purge error in backend 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 (cherry picked from commit 00881adf55cac6116887bfffc506444473f0ee82) Conflicts: src/pybind/mgr/dashboard/controllers/rbd.py - Namespace is not supported nautilus. - Use logger instance from mgr. --- diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index 24c068a7e5f..8555a35ea12 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd.py +++ b/src/pybind/mgr/dashboard/controllers/rbd.py @@ -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)