From 03a0e8a371d24ac0607af3d744c657d8243d5912 Mon Sep 17 00:00:00 2001 From: Jianquan Ye Date: Wed, 18 Dec 2024 02:51:14 +1000 Subject: [PATCH] [chassis][psud] Move the PSU parent information generation to the loop run function from the initialization function (#576) Description Move the PSU parent information generation to the loop run function from the initialization function Motivation and Context Fixes #575 How Has This Been Tested? Tested on Cisco chassis, the PHYSICAL_ENTITY_INFO|PSU * can be re-inserted after thermalctld restart. And monitored the stated db for memory for hours, works well: --- sonic-psud/scripts/psud | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sonic-psud/scripts/psud b/sonic-psud/scripts/psud index e3f56be78..f8f7b8240 100644 --- a/sonic-psud/scripts/psud +++ b/sonic-psud/scripts/psud @@ -405,9 +405,6 @@ class DaemonPsud(daemon_base.DaemonBase): fvs = swsscommon.FieldValuePairs([(CHASSIS_INFO_PSU_NUM_FIELD, str(self.num_psus))]) self.chassis_tbl.set(CHASSIS_INFO_KEY, fvs) - # Update predefined position_in_parent and parent_name for PSU - self._update_psu_entity_info() - def __del__(self): # Delete all the information from DB and then exit for psu_index in range(1, self.num_psus + 1): @@ -438,6 +435,13 @@ class DaemonPsud(daemon_base.DaemonBase): # We received a fatal signal return False + # Update predefined position_in_parent and parent_name for PSU + # it was in the __init__ function which means will be run only once + # But there's chance that the keys(PHYSICAL_ENTITY_INFO|*) got removed by other processes, + # like the exit function during the restart of thermalctld, + # hence move it to the iteration run, so the key will be filled again after removed. + self._update_psu_entity_info() + self.update_psu_data() self._update_led_color()