From 76fe070d6cf7006b7e245b9da49b83dd786bb49a Mon Sep 17 00:00:00 2001 From: Ricardo Marques Date: Mon, 10 Jun 2019 22:47:10 +0100 Subject: [PATCH] mgr/dashboard: RGW rest client instances cache eviction Fixes: https://tracker.ceph.com/issues/40252 Signed-off-by: Ricardo Marques --- src/pybind/mgr/dashboard/services/rgw_client.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pybind/mgr/dashboard/services/rgw_client.py b/src/pybind/mgr/dashboard/services/rgw_client.py index 6d47526a7163..4d7ed2c77ec6 100644 --- a/src/pybind/mgr/dashboard/services/rgw_client.py +++ b/src/pybind/mgr/dashboard/services/rgw_client.py @@ -200,6 +200,7 @@ class RgwClient(RestClient): _port = None _ssl = None _user_instances = {} + _rgw_settings_snapshot = None @staticmethod def _load_settings(): @@ -234,8 +235,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() -- 2.47.3