[device]: Fix a bug that psuutil cannot access gpio sysfs to get PSU status #1789
Conversation
| except Exception as error: | ||
| logging.error("Unable to export gpio ", pinnum) | ||
| logging.error("Unable to export gpio ", str(gpio_base+pinnum)) | ||
| sys.exit(0) |
There was a problem hiding this comment.
why exit 0 here? the plugin should not do exit
| retval = fd.read() | ||
| except Exception as error: | ||
| logging.error("Unable to open ", gpio_file, "file !") | ||
| sys.exit(0) |
There was a problem hiding this comment.
the plugin should not do exit.
| fd.write(str(gpio_base+pinnum)) | ||
| except Exception as error: | ||
| logging.error("Unable to export gpio ", pinnum) | ||
| logging.error("Unable to export gpio ", str(gpio_base+pinnum)) |
There was a problem hiding this comment.
This is invalid syntax. Please change to
logging.error("Unable to export gpio " + str(gpio_base+pinnum))
There was a problem hiding this comment.
OK, I will change it.
| logging.error("Unable to get gpio base") | ||
|
|
||
|
|
||
| def init_psu_gpio(self, pinnum): |
There was a problem hiding this comment.
this init_psu_gpio should move to your driver, we should not do init psu gpio on-the-fly.
There was a problem hiding this comment.
@jleveque, We will update init_psu_gpio after we updated our driver
There was a problem hiding this comment.
@pphuchar Please add this to our platform driver
| retval = fd.read() | ||
| except Exception as error: | ||
| logging.error("Unable to open ", gpio_file, "file !") | ||
| logging.error("Unable to open " + gpio_file + "file !") |
There was a problem hiding this comment.
we should further raise in the plugin, retval = 'ERR' is not the convention to convene error to the caller.
There was a problem hiding this comment.
OK , I will add raise statement to report the error
| @@ -53,7 +63,7 @@ def read_psu_statuses(self, pinnum): | |||
| with open(gpio_file, 'r') as fd: | |||
| retval = fd.read() | |||
| except Exception as error: | |||
There was a problem hiding this comment.
we should not catch general exception here, we should only catch exception we can handle in this case the io or file exception.
There was a problem hiding this comment.
OK, I will change it
jleveque
left a comment
There was a problem hiding this comment.
As per Guohan's comments above.
…get PSU status (sonic-net#1789)" This reverts commit 310c3f9.
f54b7d0b [Dynamic Buffer Calc][202012]Bug fix: Don't create lossless buffer profile for active ports without speed configured (sonic-net#1820) ac7f5cff Td2: Reclaim buffer from unused ports (sonic-net#1830) 04105a4b [debugcounterorch] check if counter type is supported before querying (sonic-net#1789) a67d8af6 [202012][portsorch] fix errors when moving port from one lag to another. (sonic-net#1819) Signed-off-by: Stephen Sun <stephens@nvidia.com>
* d240291 Update port_rates & rif_rates lua scripts to convert poll_interval to MS (sonic-net#1855) * a71a5d3 [acl mirror action] Mirror session ref count fix at acl rule attachment (sonic-net#1761) * 197f427 Fix vs test failure in test_buffer_traditional (sonic-net#1881) * 8471f42 Revert "[debugcounterorch] check if counter type is supported before querying… (sonic-net#1789)" (sonic-net#1884) Signed-off-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
* d240291 Update port_rates & rif_rates lua scripts to convert poll_interval to MS (#1855) * a71a5d3 [acl mirror action] Mirror session ref count fix at acl rule attachment (#1761) * 197f427 Fix vs test failure in test_buffer_traditional (#1881) * 8471f42 Revert "[debugcounterorch] check if counter type is supported before querying… (#1789)" (#1884) Signed-off-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
* d03ba4f [202012] [portstat, intfstat] added rates and utilization (sonic-net#1812) * 499ad3f [config reload] Fix config reload failure due to sonic.target job cancellation (sonic-net#1814) * 96d658c [202012][sonic installer] Add swap setup support (sonic-net#1815) * a9c6970 platform pre-check for reboot in 202012 branch (sonic-net#1788) * 0e0478b Unify the number format in the ourput of portstat and pfcstat in all cases (sonic-net#1795) * 2d1e00e [ecnconfig] Fix exception seen during display and add unit tests (sonic-net#1784) (sonic-net#1789) Signed-off-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com> d03ba4fa [202012] [portstat, intfstat] added rates and utilization (sonic-net#1812) 499ad3f4 [config reload] Fix config reload failure due to sonic.target job cancellation (sonic-net#1814) 96d658c2 [202012][sonic installer] Add swap setup support (sonic-net#1815) a9c69702 platform pre-check for reboot in 202012 branch (sonic-net#1788) 0e0478ba Unify the number format in the ourput of portstat and pfcstat in all cases (sonic-net#1795) 2d1e00ed [ecnconfig] Fix exception seen during display and add unit tests (sonic-net#1784) (sonic-net#1789)
* d03ba4f [202012] [portstat, intfstat] added rates and utilization (#1812) * 499ad3f [config reload] Fix config reload failure due to sonic.target job cancellation (#1814) * 96d658c [202012][sonic installer] Add swap setup support (#1815) * a9c6970 platform pre-check for reboot in 202012 branch (#1788) * 0e0478b Unify the number format in the ourput of portstat and pfcstat in all cases (#1795) * 2d1e00e [ecnconfig] Fix exception seen during display and add unit tests (#1784) (#1789) Signed-off-by: Volodymyr Samotiy <volodymyrs@nvidia.com>
sonic-net#1789) * [debugcounterorch] check if counter type is supported before querying object availability count Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
… image Add SAI_STATS_EXT_SWITCH_SUPPORTED=0 to sai.profile for Arista 7060cx (BCM56960/Tomahawk-1) to disable sai_get_stats_ext for switch objects. The legacy SAI binary crashes when FlexCounter calls sai_get_stats_ext on switch objects during polling. The runtime guard is implemented in sonic-sairedis PR sonic-net#1789. Signed-off-by: Liping Xu <xuliping@microsoft.com>
… image Add SAI_STATS_EXT_SWITCH_SUPPORTED=0 to sai.profile for Arista 7060cx (BCM56960/Tomahawk-1) to disable sai_get_stats_ext for switch objects. The legacy SAI binary crashes when FlexCounter calls sai_get_stats_ext on switch objects during polling. The runtime guard is implemented in sonic-sairedis PR sonic-net#1789. Signed-off-by: Liping Xu <xuliping@microsoft.com>
… image (#26014) * BROADCOM_LEGACY_SAI_COMPAT: Fix sai_get_stats_ext crash on TH1 legacy image Add SAI_STATS_EXT_SWITCH_SUPPORTED=0 to sai.profile for Arista 7060cx (BCM56960/Tomahawk-1) to disable sai_get_stats_ext for switch objects. The legacy SAI binary crashes when FlexCounter calls sai_get_stats_ext on switch objects during polling. The runtime guard is implemented in sonic-sairedis PR #1789. Signed-off-by: Liping Xu <xuliping@microsoft.com> * BROADCOM_LEGACY_SAI_COMPAT: Add missing Q32 HWSKU sai.profile.j2 keys for TH1 Arista-7060CX-32S-Q32 uses a Jinja2 template (sai.profile.j2) rather than a static sai.profile. Add SAI_STATS_ST_CAPABILITY_SUPPORTED=0 and SAI_STATS_EXT_SWITCH_SUPPORTED=0 to cover Q32 as well as the other Arista-7060CX-32S HWSKUs. Signed-off-by: Liping Xu <xuliping@microsoft.com> * BROADCOM_LEGACY_SAI_COMPAT: Fix Q32 sai.profile.j2 - restore single quotes, keep SAI keys Restore original Jinja2 single-quote style (changed unintentionally in the previous commit). Only intended change is adding SAI_STATS_ST_CAPABILITY_SUPPORTED=0 and SAI_STATS_EXT_SWITCH_SUPPORTED=0 for TH1/BCM56960. Signed-off-by: Liping Xu <xuliping@microsoft.com> --------- Signed-off-by: Liping Xu <xuliping@microsoft.com>
… image #### Why I did it On Arista 7060cx (BCM56960/Tomahawk-1) running the broadcom-legacy image, syncd crashes inside `sai_get_stats_ext` during FlexCounter polling for switch objects. The legacy SAI binary does not support `sai_get_stats_ext` for switch objects on TH1. Root cause: sonic-sairedis PR sonic-net#1775 set `use_sai_stats_ext = true` for `COUNTER_TYPE_SWITCH` in `FlexCounter::createCounterContext()`. This is needed for TH5 but causes a crash on TH1 with the legacy SAI binary. ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it Add `SAI_STATS_EXT_SWITCH_SUPPORTED=0` to `sai.profile` for all Arista 7060cx HWSKUs (BCM56960/Tomahawk-1). The runtime guard in syncd (sonic-sairedis PR sonic-net#1789) reads this key and sets `use_sai_stats_ext = false` for switch counter contexts on this platform. Files changed: - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S/sai.profile` - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-C32/sai.profile` - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-D48C8/sai.profile` - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-Q24C8/sai.profile` - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-T96C8/sai.profile` #### How to verify it 1. Build a broadcom-legacy SONiC image for Arista 7060cx 2. Boot the device and enable FlexCounter for switch objects 3. Confirm syncd does not crash during FlexCounter polling 4. Confirm switch counter stats are still collected (via non-ext path) #### Which release branch to backport (provide reason below if selected) These are bug fixes for broadcom-legacy platform (TH1). The crashes are present in 202511. - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 - [x] 202511 #### Tested branch (Please provide the tested image version) - [x] <!-- image version 1 --> 20251110.15 (broadcom-legacy, Arista 7060cx) #### Description for the changelog BROADCOM_LEGACY_SAI_COMPAT: Add sai.profile key to disable sai_get_stats_ext for switch objects on Arista 7060cx (TH1) to prevent syncd crash during FlexCounter polling on broadcom-legacy image. #### Link to config_db schema for YANG module changes N/A — sai.profile change only, no config_db schema impact. #### A picture of a cute animal (not mandatory but encouraged) 🐧 Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
…tically (#26221) #### Why I did it src/sonic-sairedis ``` * 4758c3cc - (HEAD -> master, origin/master, origin/HEAD) BROADCOM_LEGACY_SAI_COMPAT: Fix sai_get_stats_ext crash on Tomahawk-1 (BCM56960) legacy platforms (#1789) (20 hours ago) [Liping Xu] * 78470325 - BROADCOM_LEGACY_SAI_COMPAT: Fix sai_query_stats_st_capability crash on Tomahawk-1 (BCM56960) legacy platforms (#1788) (23 hours ago) [Liping Xu] ``` #### How I did it #### How to verify it #### Description for the changelog
… image (#26217) #### Why I did it On Arista 7060cx (BCM56960/Tomahawk-1) running the broadcom-legacy image, syncd crashes inside `sai_get_stats_ext` during FlexCounter polling for switch objects. The legacy SAI binary does not support `sai_get_stats_ext` for switch objects on TH1. Root cause: sonic-sairedis PR #1775 set `use_sai_stats_ext = true` for `COUNTER_TYPE_SWITCH` in `FlexCounter::createCounterContext()`. This is needed for TH5 but causes a crash on TH1 with the legacy SAI binary. ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it Add `SAI_STATS_EXT_SWITCH_SUPPORTED=0` to `sai.profile` for all Arista 7060cx HWSKUs (BCM56960/Tomahawk-1). The runtime guard in syncd (sonic-sairedis PR #1789) reads this key and sets `use_sai_stats_ext = false` for switch counter contexts on this platform. Files changed: - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S/sai.profile` - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-C32/sai.profile` - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-D48C8/sai.profile` - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-Q24C8/sai.profile` - `device/arista/x86_64-arista_7060_cx32s/Arista-7060CX-32S-T96C8/sai.profile` #### How to verify it 1. Build a broadcom-legacy SONiC image for Arista 7060cx 2. Boot the device and enable FlexCounter for switch objects 3. Confirm syncd does not crash during FlexCounter polling 4. Confirm switch counter stats are still collected (via non-ext path) #### Which release branch to backport (provide reason below if selected) These are bug fixes for broadcom-legacy platform (TH1). The crashes are present in 202511. - [ ] 202305 - [ ] 202311 - [ ] 202405 - [ ] 202411 - [ ] 202505 - [x] 202511 #### Tested branch (Please provide the tested image version) - [x] <!-- image version 1 --> 20251110.15 (broadcom-legacy, Arista 7060cx) #### Description for the changelog BROADCOM_LEGACY_SAI_COMPAT: Add sai.profile key to disable sai_get_stats_ext for switch objects on Arista 7060cx (TH1) to prevent syncd crash during FlexCounter polling on broadcom-legacy image. #### Link to config_db schema for YANG module changes N/A — sai.profile change only, no config_db schema impact. #### A picture of a cute animal (not mandatory but encouraged) 🐧 Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
- What I did
Fix bug that found on #1781
- How I did it
Update code to support dynamic sysfs gpio base.
- How to verify it
In SONiC run psuutil cli to test the following case:
PSU1: Absence
PSU1: Presence, no-power
PSU2: Absence
PSU1: Presence, no-power