From cacbc8f1b183db6bac23e704e293d006157cf18c Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Thu, 4 Jul 2024 21:58:03 +0000 Subject: [PATCH] Fix for issue: https://github.com/sonic-net/sonic-buildimage/issues/18818 Basically handle any exception when calling API get_device_runtime_metadata() and go for retry. Signed-off-by: Abhishek Dosi --- .../health_checker/sysmonitor.py | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/system-health/health_checker/sysmonitor.py b/src/system-health/health_checker/sysmonitor.py index 115dbfbe9ea0..c07b58b5489b 100755 --- a/src/system-health/health_checker/sysmonitor.py +++ b/src/system-health/health_checker/sysmonitor.py @@ -204,20 +204,23 @@ def get_service_from_feature_table(self, dir_list): while max_retry > 0: success = True - feature_table = self.config_db.get_table("FEATURE") - device_config = {} - device_config['DEVICE_METADATA'] = self.config_db.get_table('DEVICE_METADATA') - device_config.update(device_info.get_device_runtime_metadata()) - for srv, fields in feature_table.items(): - if 'state' not in fields: - success = False - logger.log_warning("FEATURE table is not fully ready: {}, retrying".format(feature_table)) - break - state = self.get_render_value_for_field(fields["state"], device_config, ['enabled', 'disabled', 'always_enabled', 'always_disabled']) - if state not in ["disabled", "always_disabled"]: - srvext = srv + ".service" - if srvext not in dir_list: - dir_list.append(srvext) + try: + feature_table = self.config_db.get_table("FEATURE") + device_config = {} + device_config['DEVICE_METADATA'] = self.config_db.get_table('DEVICE_METADATA') + device_config.update(device_info.get_device_runtime_metadata()) + for srv, fields in feature_table.items(): + if 'state' not in fields: + success = False + logger.log_warning("FEATURE table is not fully ready: {}, retrying".format(feature_table)) + break + state = self.get_render_value_for_field(fields["state"], device_config, ['enabled', 'disabled', 'always_enabled', 'always_disabled']) + if state not in ["disabled", "always_disabled"]: + srvext = srv + ".service" + if srvext not in dir_list: + dir_list.append(srvext) + except: + success = False if not success: max_retry -= 1 time.sleep(retry_delay)