From 88661f044eaa8ab6f42a77ef30b06600004261fa Mon Sep 17 00:00:00 2001 From: Kiefer Chang Date: Thu, 23 Apr 2020 18:09:15 +0800 Subject: [PATCH] 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. --- src/pybind/mgr/dashboard/controllers/rbd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index 24c068a7e5f67..8555a35ea1254 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) -- 2.39.5