Skip to content

Commit

Permalink
Fix for issue: sonic-net#18818
Browse files Browse the repository at this point in the history
Basically handle any exception when calling API
get_device_runtime_metadata() and go for retry.

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
  • Loading branch information
abdosi committed Jul 4, 2024
1 parent 06c45b7 commit cacbc8f
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/system-health/health_checker/sysmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cacbc8f

Please sign in to comment.