-
Notifications
You must be signed in to change notification settings - Fork 191
[Port-breakout] Fix Unable to find key NPU_SI_SETTINGS_SYNC_STATUS ERR #622
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
base: master
Are you sure you want to change the base?
[Port-breakout] Fix Unable to find key NPU_SI_SETTINGS_SYNC_STATUS ERR #622
Conversation
…slog error What is the Issue: For newly created breakout ports, the NPU_SI_SETTINGS_SYNC_STATUS value is not getting set in the STATE_DB's PORT_TABLE. This is normally done during xcvrd init for all the port present in system using initialize_port_init_control_fields_in_port_table(). Due to this during SI setting programming for DPB ports, the code fails to locate the NPU_SI_SETTINGS_SYNC_STATUS key in the STATE_DB, resulting in an below syslog error. sonic ERR pmon#chassis: Get value by key from STATE_DB: Unable to find key NPU_SI_SETTINGS_SYNC_STATUS state_port_table_fvs_dict {'host_tx_ready': 'false', 'state': 'ok', 'netdev_oper_status': 'down', 'admin_status': 'down', 'mtu': '9100', 'supported_speeds': '50000,100000', 'supported_fecs': 'rs'} for lport Ethernet448 Fix: Set the NPU_SI_SETTINGS_SYNC_STATUS to NPU_SI_SETTINGS_DEFAULT_VALUE value in State DB on the event of "port_event_helper.PortChangeEvent.PORT_ADD" in on_add_logical_port() which get trigged for newly added DPB ports. Signed-off-by: Keshav Gupta <[email protected]>
59578f8
to
bdcf95a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses an issue with breakout ports where the NPU_SI_SETTINGS_SYNC_STATUS field was missing in the STATE_DB PORT_TABLE, causing errors during SI setting programming. Key changes include adding initialization of NPU_SI_SETTINGS_SYNC_STATUS in the xcvrd on_add_logical_port() function and updating tests to mock the state port table.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
sonic-xcvrd/xcvrd/xcvrd.py | Added logic to initialize NPU_SI_SETTINGS_SYNC_STATUS for new logical ports |
sonic-xcvrd/tests/test_xcvrd.py | Updated tests to include the state port table mock setup |
Comments suppressed due to low confidence (1)
sonic-xcvrd/tests/test_xcvrd.py:3600
- Consider adding explicit assertions to verify that NPU_SI_SETTINGS_SYNC_STATUS is correctly set in the state DB during the logical port addition. This would help ensure the new behavior for DPB ports is properly tested.
mock_table_helper.get_state_port_tbl = MagicMock(return_value=mock_table)
found, state_port_table_fvs = state_port_table.get(port_change_event.port_name) | ||
if not found: | ||
helper_logger.log_notice("Add logical port: Creating STATE_DB PORT_TABLE as unable to find for lport {}".format(port_change_event.port_name)) | ||
state_port_table_fvs = [] |
Copilot
AI
Jun 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider verifying the conversion of state_port_table_fvs to a dictionary when it may be an empty list. Adding a clarifying comment on the expected structure of state_port_table_fvs could improve maintainability.
state_port_table_fvs = [] | |
state_port_table_fvs = [] | |
# Verify the structure of state_port_table_fvs and clarify its expected format. | |
# Expected: A list of key-value pairs (e.g., [(key1, value1), (key2, value2)]) or an empty list. | |
if not isinstance(state_port_table_fvs, list) or not all(isinstance(item, tuple) and len(item) == 2 for item in state_port_table_fvs): | |
helper_logger.log_error("Invalid structure for state_port_table_fvs: {}".format(state_port_table_fvs)) | |
state_port_table_fvs = [] |
Copilot uses AI. Check for mistakes.
/azpw run |
Only PR owner can use /azpw run |
/azp run |
Commenter does not have sufficient privileges for PR 622 in repo sonic-net/sonic-platform-daemons |
@Keshavg-marvell Where is the below log defined? Asking since I couldn't find it in xcvrd
|
this logs get printed in below code. |
@Keshavg-marvell Wondering why are we seeing |
@mihirpat1 I believe this chassis is appended from common syslog infra used by xcvrd. if changes looks good. Can you please review and merge this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. However, not sure why the PR checkers have not yet triggered for this PR.
/azpw run Azure.sonic-platform-daemons |
/AzurePipelines run Azure.sonic-platform-daemons |
Azure Pipelines successfully started running 1 pipeline(s). |
Thanks @mihirpat1 for the review. I have retrigged the pipelines, and now all checks are passing. Can you please merge this PR now? |
@prgeor Can you please review and merge this PR? |
state_port_table = self.xcvr_table_helper.get_state_port_tbl(port_change_event.asic_id) | ||
found, state_port_table_fvs = state_port_table.get(port_change_event.port_name) | ||
if not found: | ||
helper_logger.log_notice("Add logical port: Creating STATE_DB PORT_TABLE as unable to find for lport {}".format(port_change_event.port_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Keshavg-marvell can we make it debug log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @prgeor for the review. Same log level is there in normal port add during xcvrd init at below place. Do we change there as well to be consistent for both the cases?
sonic-platform-daemons/sonic-xcvrd/xcvrd/xcvrd.py
Line 2079 in 700ccd4
self.log_notice("Port init control: Creating STATE_DB PORT_TABLE as unable to find for lport {}".format(lport)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Keshavg-marvell @mihirpat1 can we call initialize_port_init_control_fields_in_port_table()
in on_add_logical_port()
instead of calling it in daemon init()
function? This way we dont have to handle breakout scenario differently?
if NPU_SI_SETTINGS_SYNC_STATUS_KEY not in dict(state_port_table_fvs): | ||
state_port_table.set(port_change_event.port_name, [(NPU_SI_SETTINGS_SYNC_STATUS_KEY, | ||
NPU_SI_SETTINGS_DEFAULT_VALUE)]) | ||
helper_logger.log_notice("Add logical port: Initialized NPU_SI_SETTINGS_SYNC_STATUS for lport {}".format(port_change_event.port_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Keshavg-marvell debug instaed of notice log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @prgeor for the review. Same log level is there in normal port add during xcvrd init at below place. Do we change there as well to be consistent for both the cases?
sonic-platform-daemons/sonic-xcvrd/xcvrd/xcvrd.py
Line 2085 in 700ccd4
self.log_notice("Port init control: Initialized NPU_SI_SETTINGS_SYNC_STATUS for lport {}".format(lport)) |
Description
What is the Issue:
For newly created breakout ports, the NPU_SI_SETTINGS_SYNC_STATUS value is not getting set in the STATE_DB's PORT_TABLE. This is normally done during xcvrd init for all the port present in system using initialize_port_init_control_fields_in_port_table(). Due to this during SI setting programming for DPB ports, the code fails to locate the NPU_SI_SETTINGS_SYNC_STATUS key in the STATE_DB, resulting in an below syslog error.
Fix:
Set the NPU_SI_SETTINGS_SYNC_STATUS to NPU_SI_SETTINGS_DEFAULT_VALUE value in State DB on the event of "port_event_helper.PortChangeEvent.PORT_ADD" in on_add_logical_port() which get trigged for newly added DPB ports.
This PR fixes below issue:
#621
Motivation and Context
To fix error seen in syslog during port breakout
How Has This Been Tested?
Verified that syslog ERR is not seen with breakout CLI
sudo config interface breakout Ethernet448 "8x100G[50G,25G]" -y -f
Back port request
Additional Information (Optional)