Skip to content

Commit

Permalink
Added fix for issue:21371 update cp and dp states when midplane goes …
Browse files Browse the repository at this point in the history
…down (#584)
  • Loading branch information
rameshraghupathy authored Feb 7, 2025
1 parent 585541f commit a2c4bc9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions sonic-chassisd/scripts/chassisd
Original file line number Diff line number Diff line change
Expand Up @@ -775,28 +775,22 @@ class SmartSwitchModuleUpdater(ModuleUpdater):

def update_dpu_state(self, key, state):
"""
Update DPU state in chassisStateDB using the given key.
Update specific DPU state fields in chassisStateDB using the given key.
"""
try:
# Connect to the CHASSIS_STATE_DB using daemon_base
if not self.chassis_state_db:
self.chassis_state_db = daemon_base.db_connect("CHASSIS_STATE_DB")

# Fetch the current data for the given key and convert it to a dict
current_data = self._convert_to_dict(self.chassis_state_db.hgetall(key))

if current_data:
self.chassis_state_db.delete(key)

# Prepare the updated data
# Prepare the fields to update
updates = {
"dpu_midplane_link_state": state,
"dpu_midplane_link_reason": "",
"dpu_midplane_link_time": get_formatted_time(),
}
current_data.update(updates)

for field, value in current_data.items():
# Update each field directly
for field, value in updates.items():
self.chassis_state_db.hset(key, field, value)

except Exception as e:
Expand Down

0 comments on commit a2c4bc9

Please sign in to comment.