From: Ricardo Marques Date: Mon, 10 Jun 2019 21:47:10 +0000 (+0100) Subject: mgr/dashboard: RGW rest client instances cache eviction X-Git-Tag: v14.2.3~62^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=21aff48d33cebd3d639caa8212a1619a5c9182ed;p=ceph.git mgr/dashboard: RGW rest client instances cache eviction Fixes: https://tracker.ceph.com/issues/40252 Signed-off-by: Ricardo Marques (cherry picked from commit 76fe070d6cf7006b7e245b9da49b83dd786bb49a) --- diff --git a/src/pybind/mgr/dashboard/services/rgw_client.py b/src/pybind/mgr/dashboard/services/rgw_client.py index d148235c538f..1351c6259229 100644 --- a/src/pybind/mgr/dashboard/services/rgw_client.py +++ b/src/pybind/mgr/dashboard/services/rgw_client.py @@ -196,6 +196,7 @@ class RgwClient(RestClient): _port = None _ssl = None _user_instances = {} + _rgw_settings_snapshot = None @staticmethod def _load_settings(): @@ -230,8 +231,24 @@ class RgwClient(RestClient): # Append the instance to the internal map. RgwClient._user_instances[RgwClient._SYSTEM_USERID] = instance + @staticmethod + def _rgw_settings(): + return (Settings.RGW_API_HOST, + Settings.RGW_API_PORT, + Settings.RGW_API_ACCESS_KEY, + Settings.RGW_API_SECRET_KEY, + Settings.RGW_API_ADMIN_RESOURCE, + Settings.RGW_API_SCHEME, + Settings.RGW_API_USER_ID, + Settings.RGW_API_SSL_VERIFY) + @staticmethod def instance(userid): + # Discard all cached instances if any rgw setting has changed + if RgwClient._rgw_settings_snapshot != RgwClient._rgw_settings(): + RgwClient._rgw_settings_snapshot = RgwClient._rgw_settings() + RgwClient._user_instances.clear() + if not RgwClient._user_instances: RgwClient._load_settings()