From da53148e48531097992974f7d8d0b20f71d188e3 Mon Sep 17 00:00:00 2001 From: chengyang Date: Wed, 22 Nov 2017 18:22:09 +0800 Subject: [PATCH] Fix create redis instance with new requirepass When create redis instance with a configuration which has requirepass value(not 'foobared'). Period task still use old password to poll instance's status, so instance create failed because authentication error. Applied requirepass at runtime and refresh admin client after apply_user_override to fix it. Change-Id: I27598a9031efcb74821f77c36710d224b3a9a0e6 Closes-bug: #1733815 --- .../datastore/experimental/redis/service.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/trove/guestagent/datastore/experimental/redis/service.py b/trove/guestagent/datastore/experimental/redis/service.py index 5e46112486..18e73fe45a 100644 --- a/trove/guestagent/datastore/experimental/redis/service.py +++ b/trove/guestagent/datastore/experimental/redis/service.py @@ -112,6 +112,11 @@ class RedisApp(object): return RedisAdmin(password=password, unix_socket_path=socket, config_cmd=cmd) + def _refresh_admin_client(self): + self.admin = self._build_admin_client() + self.status.set_client(self.admin) + return self.admin + def install_if_needed(self, packages): """ Install redis if needed do nothing if it is already installed. @@ -146,6 +151,10 @@ class RedisApp(object): def update_overrides(self, context, overrides, remove=False): if overrides: self.configuration_manager.apply_user_override(overrides) + # apply requirepass at runtime + if 'requirepass' in overrides: + self.admin.config_set('requirepass', overrides['requirepass']) + self._refresh_admin_client() def apply_overrides(self, client, overrides): """Use the 'CONFIG SET' command to apply configuration at runtime. @@ -167,10 +176,9 @@ class RedisApp(object): for prop_name, prop_args in overrides.items(): args_string = self._join_lists( self._value_converter.to_strings(prop_args), ' ') - client.config_set(prop_name, args_string) - self.admin = self._build_admin_client() - self.status = RedisAppStatus(self.admin) - client = self.admin + # requirepass applied at runtime during update_overrides + if prop_name != "requirepass": + client.config_set(prop_name, args_string) def _join_lists(self, items, sep): """Join list items (including items from sub-lists) into a string.