From 69f08ab470a0d1d1d4676b41ad29a9c19ce28648 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Wed, 7 Jul 2021 09:34:17 +1200 Subject: Fix getting config option value for database Change-Id: If2d3022a59ba535e1361a3ba9bc9dd983ca25256 Story: 2009051 Task: 42821 --- trove/guestagent/common/configuration.py | 6 +++++- trove/guestagent/datastore/mysql_common/manager.py | 9 ++++++--- trove/guestagent/datastore/mysql_common/service.py | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'trove') diff --git a/trove/guestagent/common/configuration.py b/trove/guestagent/common/configuration.py index b3165080..2edfa0da 100644 --- a/trove/guestagent/common/configuration.py +++ b/trove/guestagent/common/configuration.py @@ -104,12 +104,15 @@ class ConfigurationManager(object): self._override_strategy.configure( base_config_path, owner, group, codec, requires_root) - def get_value(self, key, default=None): + def get_value(self, key, section=None, default=None): """Return the current value at a given key or 'default'. """ if self._value_cache is None: self.refresh_cache() + if section: + return self._value_cache.get(section, {}).get(key, default) + return self._value_cache.get(key, default) def parse_configuration(self): @@ -417,6 +420,7 @@ class ImportOverrideStrategy(ConfigurationOverrideStrategy): as_root=self._requires_root) guestagent_utils.update_dict(options, parsed_options) + LOG.debug(f"Parsed overrides options: {parsed_options}") return parsed_options @property diff --git a/trove/guestagent/datastore/mysql_common/manager.py b/trove/guestagent/datastore/mysql_common/manager.py index 538c29e1..cd6546a1 100644 --- a/trove/guestagent/datastore/mysql_common/manager.py +++ b/trove/guestagent/datastore/mysql_common/manager.py @@ -173,11 +173,14 @@ class MySqlManager(manager.Manager): def is_log_enabled(self, logname): if logname == self.GUEST_LOG_DEFS_GENERAL_LABEL: - value = self.configuration_manager.get_value('general_log', 'off') + value = self.configuration_manager.get_value( + 'general_log', section='mysqld', default='off') + LOG.debug(f"The config value of general_log is {value}") return value == 'on' elif logname == self.GUEST_LOG_DEFS_SLOW_QUERY_LABEL: - value = self.configuration_manager.get_value('slow_query_log', - 'off') + value = self.configuration_manager.get_value( + 'slow_query_log', section='mysqld', default='off') + LOG.debug(f"The config value of slow_query_log is {value}") return value == 'on' return False diff --git a/trove/guestagent/datastore/mysql_common/service.py b/trove/guestagent/datastore/mysql_common/service.py index 4efa091c..a110d222 100644 --- a/trove/guestagent/datastore/mysql_common/service.py +++ b/trove/guestagent/datastore/mysql_common/service.py @@ -463,7 +463,7 @@ class BaseMySqlApp(service.BaseDbApp): @classmethod def get_data_dir(cls): return cls.configuration_manager.get_value( - MySQLConfParser.SERVER_CONF_SECTION).get('datadir') + 'datadir', section=MySQLConfParser.SERVER_CONF_SECTION) @classmethod def set_data_dir(cls, value): -- cgit v1.2.1