Skip to content

Commit a86dd89

Browse files
Store reboot_cause history files with json extension. Fix for #22072 (#603)
* Fix for #22072 store reboot_cause history files wiht json extension * storing the prev_reboot_time.txt file under module-dir instead of module/history-dir so that there is not change required in sonic-host-services for #22072
1 parent 6dfb552 commit a86dd89

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

sonic-chassisd/scripts/chassisd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,15 +878,15 @@ class SmartSwitchModuleUpdater(ModuleUpdater):
878878
def persist_dpu_reboot_time(self, module):
879879
"""Persist the current reboot time to a file."""
880880
time_str = self._get_current_time_str()
881-
path = self._get_history_path(module, "prev_reboot_time.txt")
881+
path = os.path.join(MODULE_REBOOT_CAUSE_DIR, module.lower(), "prev_reboot_time.txt")
882882

883883
os.makedirs(os.path.dirname(path), exist_ok=True)
884884
with open(path, 'w') as f:
885885
f.write(time_str)
886886

887887
def retrieve_dpu_reboot_time(self, module):
888888
"""Retrieve the persisted reboot time from a file."""
889-
path = self._get_history_path(module, "prev_reboot_time.txt")
889+
path = os.path.join(MODULE_REBOOT_CAUSE_DIR, module.lower(), "prev_reboot_time.txt")
890890

891891
try:
892892
with open(path, 'r') as f:
@@ -912,8 +912,8 @@ class SmartSwitchModuleUpdater(ModuleUpdater):
912912
if prev_reboot_time is None:
913913
prev_reboot_time = self._get_current_time_str()
914914

915-
file_name = f"{prev_reboot_time}_reboot_cause.txt"
916-
prev_reboot_path = self._get_history_path(module, "prev_reboot_time.txt")
915+
file_name = f"{prev_reboot_time}_reboot_cause.json"
916+
prev_reboot_path = os.path.join(MODULE_REBOOT_CAUSE_DIR, module.lower(), "prev_reboot_time.txt")
917917

918918
if os.path.exists(prev_reboot_path):
919919
os.remove(prev_reboot_path)
@@ -982,7 +982,7 @@ class SmartSwitchModuleUpdater(ModuleUpdater):
982982
self.chassis_state_db.delete(key)
983983

984984
# Fetch the list of reboot cause history files
985-
history_path = f"/host/reboot-cause/module/{module.lower()}/history/*_reboot_cause.txt"
985+
history_path = f"/host/reboot-cause/module/{module.lower()}/history/*_reboot_cause.json"
986986
reboot_cause_files = glob.glob(history_path)
987987

988988
if not reboot_cause_files:

0 commit comments

Comments
 (0)