Skip to content

Commit

Permalink
[healthd] Added change to handle Feature Table exception (#19480)
Browse files Browse the repository at this point in the history
*Fix: #18818

Handle any exception in API get_service_from_feature_table() gracefully .

---------

Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
  • Loading branch information
abdosi authored and mssonicbld committed Aug 3, 2024
1 parent 5e633aa commit 27b7bea
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 27b7bea

Please sign in to comment.