From 5e6e2c827d4b937c06d3c31f85c22b99f50d0d5c Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Tue, 7 Feb 2023 23:56:06 +0800 Subject: [PATCH] Fix issue: ERR healthd: Get unit status determine-reboot-cause-'LoadState' (#13697) - Why I did it Fix issue: ERR healthd: Get unit status determine-reboot-cause-'LoadState'. The error log is only seen on shutdown flow such as fast-reboot/warm-reboot. In shutdown flow, 'LoadState' might not be available in systemctl status output, using [] might cause a KeyError. - How I did it Use dict.get instead of [] - How to verify it Manual test --- src/system-health/health_checker/sysmonitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system-health/health_checker/sysmonitor.py b/src/system-health/health_checker/sysmonitor.py index dde0b73d1bce..b3f43e447f7b 100755 --- a/src/system-health/health_checker/sysmonitor.py +++ b/src/system-health/health_checker/sysmonitor.py @@ -273,7 +273,7 @@ def get_unit_status(self, event): sysctl_show = self.run_systemctl_show(event) - load_state = sysctl_show['LoadState'] + load_state = sysctl_show.get('LoadState') if load_state == "loaded": status = sysctl_show['UnitFileState'] fail_reason = sysctl_show['Result']