From 53b9e4661561c85aabe802d098e79c1c099e6bec Mon Sep 17 00:00:00 2001 From: SidneyAn Date: Mon, 18 Feb 2019 22:03:57 +0800 Subject: [PATCH] retry func iconfig_update_file when host personality is None when we run "system dns-modify" command, the command will response after sysinv-db was updated, and file "/etc/resolv.conf" will be updated asynchronously by another process "sysinv-agent". Once the attr "_ihost_personality" of agent is None(initial value), it will not update file "/etc/resolv.conf" and will not inform sysinv client also, which will lead command dns-modify failed silently. This patch will retry function iconfig_update_file by which sysinv-agent update file "/etc/resolv.conf" when attr "_ihost_personality" is None. Closes-bug: 1812269 Change-Id: I3a0437750a53607c04932c1b9b818e83903bb28b Signed-off-by: SidneyAn --- sysinv/sysinv/sysinv/sysinv/agent/manager.py | 11 +++++++++++ sysinv/sysinv/sysinv/sysinv/common/exception.py | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/sysinv/sysinv/sysinv/sysinv/agent/manager.py b/sysinv/sysinv/sysinv/sysinv/agent/manager.py index 6ee010f05c..08f1d6b640 100644 --- a/sysinv/sysinv/sysinv/sysinv/agent/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/agent/manager.py @@ -1291,6 +1291,12 @@ class AgentManager(service.PeriodicService): fileinput.close() os.rename(temp_platform_conf_file, tsc.PLATFORM_CONF_FILE) + def _retry_on_personality_is_none(ex): + LOG.info('Caught exception. Retrying... Exception: {}'.format(ex)) + return isinstance(ex, exception.LocalManagementPersonalityNotFound) + + @retrying.retry(wait_fixed=10 * 1000, stop_max_delay=300 * 1000, + retry_on_exception=_retry_on_personality_is_none) @utils.synchronized(LOCK_AGENT_ACTION, external=False) def iconfig_update_file(self, context, iconfig_uuid, iconfig_dict): """Configure the iiconfig_uuid, by updating file based upon @@ -1314,6 +1320,11 @@ class AgentManager(service.PeriodicService): if not permissions: permissions = constants.CONFIG_FILE_PERMISSION_DEFAULT + if not self._ihost_personality: + raise exception.LocalManagementPersonalityNotFound( + config_uuid=iconfig_uuid, config_dict=iconfig_dict, + host_personality=self._ihost_personality) + if self._ihost_personality in iconfig_dict['personalities']: file_content = iconfig_dict['file_content'] diff --git a/sysinv/sysinv/sysinv/sysinv/common/exception.py b/sysinv/sysinv/sysinv/sysinv/common/exception.py index 3b96cb78b6..dd9f0d4527 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/exception.py +++ b/sysinv/sysinv/sysinv/sysinv/common/exception.py @@ -1298,6 +1298,12 @@ class InvalidHelmNamespace(Invalid): message = _("Invalid helm overrides namespace (%(namespace)s) for chart %(chart)s.") +class LocalManagementPersonalityNotFound(NotFound): + message = _("Local management personality is None: " + "config_uuid=%(config_uuid)s, config_dict=%(config_dict)s, " + "host_personality=%(host_personality)s") + + class LocalManagementIpNotFound(NotFound): message = _("Local management IP not found: " "config_uuid=%(config_uuid)s, config_dict=%(config_dict)s, "