Skip to content

Commit

Permalink
If system health configuration file not exist, healthd should exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Junchao-Mellanox committed Sep 7, 2020
1 parent 8812061 commit 8ea2ab5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/system-health/health_checker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def __init__(self):
self.ignore_devices = None
self.user_defined_checkers = None

def config_file_exists(self):
return os.path.exists(self._config_file)

def load_config(self):
"""
Load the configuration file from disk.
Expand All @@ -53,7 +56,7 @@ def load_config(self):
3. If there is any format issues in configuration file, current config entries will reset to default value
:return:
"""
if not os.path.exists(self._config_file):
if not self.config_file_exists():
if self._last_mtime is not None:
self._reset()
return
Expand Down
3 changes: 3 additions & 0 deletions src/system-health/scripts/healthd
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class HealthDaemon(DaemonBase):
import sonic_platform.platform
chassis = sonic_platform.platform.Platform().get_chassis()
manager = HealthCheckerManager()
if not manager.config.config_file_exists():
logger.log_warning("System health configuration file not found, exit...")
return
while 1:
state, stat = manager.check(chassis)
if state == HealthCheckerManager.STATE_RUNNING:
Expand Down

0 comments on commit 8ea2ab5

Please sign in to comment.