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

[AS4625-54P/T] sync log to SSD before OTP shutdown #85

Merged

Conversation

roger530-ho
Copy link
Collaborator

@roger530-ho roger530-ho commented Jul 16, 2024

Why I did it

The shutdown message will be lost during OTP shutdown.

How I did it

sync log to SSD before OTP shutdown

How to verify it

Setup Test Environment

  1. Modify /usr/local/lib/python3.9/dist-packages/sonic_platform/thermal.py:{}init{}(...)
    self.hwmon_path = "/home/admin/"
  2. Add following to /etc/rc.local
    echo 31000 > /home/admin/temp1_input
    exit 0 
    
  3. Reboot

Before Modification

  1. Produce fake temperature data
    admin@as4625-54t-1:~$ sudo su
    root@as4625-54t-1:/home/admin# cat /dev/null > /var/log/syslog
    root@as4625-54t-1:/home/admin#
    root@as4625-54t-1:/home/admin# echo 85000 > temp1_input
    root@as4625-54t-1:/home/admin#
    
  2. Power Cycling
    Log :
    AS4625-54T_Before_Modification.log
    AS4625-54P_Before_Modification.log

After Modification

  1. Add the following code to /usr/local/bin/accton_as4625_54t_monitor.py:manage_fans()
......
    import subprocess
    import sonic_platform.platform
            ......
        if self.shutdown is True:
            # critical case*/
            logging.critical(
                'Alarm-Critical for temperature critical is detected, trigger thermal shutdown')
            ## Sync log buffer to disk
            cmd_str="sync"
            status, output = subprocess.getstatusoutput(cmd_str)
            cmd_str="/sbin/fstrim -av"
            status, output = subprocess.getstatusoutput(cmd_str)
            time.sleep(3)
 
            path = I2C_PATH.format('0', '64') + 'thermal_shutdown'
            time.sleep(2)
            self._api_helper.write_txt_file(path, 1)
 
            logging.critical(
                'Alarm-Critical for temperature critical is detected, shutdown DUT')
            ## Sync log buffer to disk
            cmd_str="sync"
            status, output = subprocess.getstatusoutput(cmd_str)
            cmd_str="/sbin/fstrim -av"
            status, output = subprocess.getstatusoutput(cmd_str)
            time.sleep(3)
 
            path = I2C_PATH.format('0', '64') + 'pwr_enable_mb'
            time.sleep(2)
            self._api_helper.write_txt_file(path, 0)
  1. Produce fake temperature data
    root@as4625-54t-1:/home/admin# systemctl restart as4625-54t-platform-monitor.service
    root@as4625-54t-1:/home/admin# cat /dev/null > /var/log/syslog
    root@as4625-54t-1:/home/admin# echo 85000 > temp1_input
    root@as4625-54t-1:/home/admin# 
    root@as4625-54t-1:/home/admin# 
    
  2. Power Cycling
    Log :
    AS4625-54T_After_Modification.log
    AS4625-54P_After_Modification.log

Which release branch to backport (provide reason below if selected)

Description for the changelog

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@bryan1978 bryan1978 merged commit b166a86 into edge-core:202311.0 Jul 17, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants