[agent][ssd] Fix == used instead of = in SSD health parsing (6 instances)#645
[agent][ssd] Fix == used instead of = in SSD health parsing (6 instances)#645rustiqly wants to merge 2 commits intosonic-net:masterfrom
Conversation
…ces) Lines 247, 253, 299, 306 use comparison operator == where assignment = is intended. The == evaluates to True/False with no side effect, leaving disk_io_reads and disk_io_writes with stale values instead of being set to NOT_AVAILABLE. Affects Innodisk and Virtium parsers. Fixes: sonic-net#643 Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes SSD health parsing in sonic-platform-common by replacing unintended == (comparison) with = (assignment) when setting Innodisk/Virtium disk I/O metrics to NOT_AVAILABLE, preventing no-op statements in the parsing paths.
Changes:
- Replace
self.disk_io_reads == NOT_AVAILABLEwithself.disk_io_reads = NOT_AVAILABLEin Innodisk and Virtium parsing. - Replace
self.disk_io_writes == NOT_AVAILABLEwithself.disk_io_writes = NOT_AVAILABLEin Innodisk and Virtium parsing.
| if self.disk_io_reads == NOT_AVAILABLE: | ||
| io_reads_raw = self.parse_id_number("[{}]".format(hex(INNODISK_IO_READS_ID)[2:]).upper(), self.vendor_ssd_info) | ||
| if io_reads_raw == NOT_AVAILABLE: | ||
| self.disk_io_reads == NOT_AVAILABLE | ||
| self.disk_io_reads = NOT_AVAILABLE | ||
| else: |
There was a problem hiding this comment.
This PR/issue description indicates all unintended == usages were fixed, but ssd.py still contains standalone no-op comparisons (self.reserved_blocks == NOT_AVAILABLE) in both parse_innodisk_info and parse_virtium_info (currently around lines 259 and 313). Consider updating those to assignments as well so the fix is complete and the description/count matches the code.
There was a problem hiding this comment.
@judyjoseph Thanks for flagging — the current commit (e9eaac0) already includes all 6 fixes, covering both parse_innodisk_info and parse_virtium_info in addition to the original ones. I'll update the PR title to reflect the correct count (6 instances, not 4).
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Re: the Copilot suggestion about |
Address review feedback: fix 2 additional no-op comparison statements (self.reserved_blocks == NOT_AVAILABLE) on lines 259 and 313 that should be assignments (=), matching the 4 instances already fixed in this PR. Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com>
|
Good catch @judyjoseph — pushed incremental commit e9eaac0 fixing the 2 remaining |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
What I did
Fix 4 instances where
==(comparison) was used instead of=(assignment) in SSD health parsing code for Innodisk and Virtium drives.How I did it
Changed
==to=on lines 247, 253, 299, 306 ofsonic_platform_base/sonic_storage/ssd.py.How to verify it
Which release branch to backport
master
Description for the changelog
Fix silent data corruption in SSD disk I/O health metrics where comparison operator was used instead of assignment.
Fixes: #643