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

Add script to periodically update oper status of management interface #21245

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

SuvarnaMeenakshi
Copy link
Contributor

Why I did it

Issue to be fix: Currently operational status of mgmt interface is not present or correct for multi-asic devices.
Root cause: Operational status of mgmt interface is updated by portsyncd in swss docker. In case of multi-asic platform, swss service is started only in asic namespace context. Since portsyncd is running in a specific network namespace context, it is not aware of mgmt interface present in the host namespace of multi-asic platform. Therefore there is no way for portsyncd to find the operational status of mgmt interface and update in STATE_DB MGMT_PORT_TABLE.
Use case: SNMP interface MIB reads MGMT_PORT_TABLE in STATE_DB to retrieve oper status of mgmt interface periodically. In case of multi-asic platform, currently this is returning the oper status of 'eth0' interface which is the virtual interface that is present inside asic namespace which gets created as a part of database docker and is not the actual management interface.

Work item tracking
  • Microsoft ADO 30279044:

How I did it

  1. Remove update of mgmt oper status from sonic-swss
  2. Use monit script to periodically update oper status of mgmt interface.

How to verify it

  1. verified on single-asic platform and multi-asic Chassis platfrom.

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

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

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

@SuvarnaMeenakshi SuvarnaMeenakshi changed the title Mgmt if status Add script to periodically update oper status of management interface Dec 20, 2024
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

for port in mgmt_ports:
state_db_key = "MGMT_PORT_TABLE|{}".format(port)
# Reset status of mgmt port before updating with latest status
db.set(db.STATE_DB, state_db_key, 'oper_status', 'unknown')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we do a read first and only when there is a change of oper state, the log there is a change whether it be from UP to Down or Down to UP transition.
Let's not reset it to unknown as we want to avoid making any changes unless there is a need to do so (state change detected). For the state cahnge from UP to Down, let.s make it as a warning. For state change from down to up let's make it as a INFO level syslog.

Signed-off-by: Suvarna Meenakshi <[email protected]>
Signed-off-by: Suvarna Meenakshi <[email protected]>
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

current_oper_status = subprocess.run(['cat', port_operstate_path], capture_output=True, text=True)
if current_oper_status.stdout.strip() != prev_oper_status:
db.set(db.STATE_DB, state_db_key, 'oper_status', current_oper_status.stdout.strip())
syslog.syslog(syslog.LOG_INFO, "mgmt_oper_status_check: {}".format(current_oper_status.stdout.strip()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you make syslog WARNING for down case and keep INFO for up case?

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.

3 participants