Skip to content

Commit a2c4bc9

Browse files
Added fix for issue:21371 update cp and dp states when midplane goes down (#584)
1 parent 585541f commit a2c4bc9

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

sonic-chassisd/scripts/chassisd

+4-10
Original file line numberDiff line numberDiff line change
@@ -775,28 +775,22 @@ class SmartSwitchModuleUpdater(ModuleUpdater):
775775

776776
def update_dpu_state(self, key, state):
777777
"""
778-
Update DPU state in chassisStateDB using the given key.
778+
Update specific DPU state fields in chassisStateDB using the given key.
779779
"""
780780
try:
781781
# Connect to the CHASSIS_STATE_DB using daemon_base
782782
if not self.chassis_state_db:
783783
self.chassis_state_db = daemon_base.db_connect("CHASSIS_STATE_DB")
784784

785-
# Fetch the current data for the given key and convert it to a dict
786-
current_data = self._convert_to_dict(self.chassis_state_db.hgetall(key))
787-
788-
if current_data:
789-
self.chassis_state_db.delete(key)
790-
791-
# Prepare the updated data
785+
# Prepare the fields to update
792786
updates = {
793787
"dpu_midplane_link_state": state,
794788
"dpu_midplane_link_reason": "",
795789
"dpu_midplane_link_time": get_formatted_time(),
796790
}
797-
current_data.update(updates)
798791

799-
for field, value in current_data.items():
792+
# Update each field directly
793+
for field, value in updates.items():
800794
self.chassis_state_db.hset(key, field, value)
801795

802796
except Exception as e:

0 commit comments

Comments
 (0)