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

[xcvrd] Handle platfom_chassis None scenario to protect xcvrd from crash #411

Conversation

tshalvi
Copy link
Contributor

@tshalvi tshalvi commented Dec 7, 2023

Description

 Added functionality to media_settings_parser to handle the case where platform_chassis is None and added corresponding logs.

Motivation and Context

 xcvrd crashes were identified in some cases where platform_chassis was None.

How Has This Been Tested?

 I ensured that xcvrd does not crash in the relevant scenario, ports manage to go up, and relevant logs are printed.

@keboliu keboliu force-pushed the master_media_settings_parser_missing_platform_chassis_fix branch from 4014a6e to 7719fb8 Compare December 11, 2023 06:20
@keboliu
Copy link
Collaborator

keboliu commented Dec 13, 2023

Hi @prgeor , this is a bug fix PR for the previous merged CMIS mgmt code. would you please help to review?

media_compliance_dict = ast.literal_eval(media_compliance_dict_str)
if sup_compliance_str in media_compliance_dict:
media_compliance_code = media_compliance_dict[sup_compliance_str]
helper_logger.log_error("Unable to derive media_key.media_compliance_code because platform_chassis is None")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tshalvi when can this happen? How does it recover later?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scenario was observed only once, when trying to delete a table as part of another PR, which has since been reverted and is no longer relevant. Nevertheless, I still recommend implementing this fix as a precautionary measure to mitigate any unforeseen issues.
Regarding the recovery process, the key for the lookup in media_settings.json will simply include an empty string for the specification_compliance component, resulting in empty data for the JSON lookup. Instead of experiencing a crash in such a scenario, xcvrd will just end up not posting anything to APP_DB in notify_media_settings().

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tshalvi i think we need to understand the issue better. i don't see platform_chassis to be None since platforms have transition to using chassis APIs
platform_chassis = sonic_platform.platform.Platform().get_chassis()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tshalvi All platforms are supposed to use API 2.0. The wrapper needs to be clean up. Xcvrd should not run if platform_chassis is None

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.

5 participants