Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for dpu midplane state update affecting dpu control_plane/data_plane state :issue-21371 #584

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions sonic-chassisd/scripts/chassisd
Original file line number Diff line number Diff line change
Expand Up @@ -765,28 +765,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": datetime.now().strftime("%a %b %d %I:%M:%S %p UTC %Y"),
}
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
Loading