-
Notifications
You must be signed in to change notification settings - Fork 672
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
[show][interface] Add changes for show interface errors command #3721
Conversation
Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
body.append([error.replace('_', ' '), count, timestamp]) | ||
|
||
# Sort the body for consistent display | ||
body.sort(key=lambda x: x[0]) |
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.
@vdahiya12 can you double check if there is enough space the columns as displayed in the CLI command document?
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.
checked with the sample test output, we should be good
show/interfaces/__init__.py
Outdated
db = SonicV2Connector(host=REDIS_HOSTIP) | ||
db.connect(db.STATE_DB) | ||
|
||
# Retrieve the errors data from the PORT_OPERR_TABLE | ||
port_operr_table = db.get_all(db.STATE_DB, 'PORT_OPERR_TABLE|{}'.format(interfacename)) | ||
db.close(db.STATE_DB) | ||
|
||
# Ensure port_operr_table is a dictionary | ||
port_operr_table = port_operr_table or {} | ||
|
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.
@vdahiya12 maybe we can capture this in a function get_all_port_errors()
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.
fixed
show/interfaces/__init__.py
Outdated
port_operr_table = db.get_all(db.STATE_DB, 'PORT_OPERR_TABLE|{}'.format(interfacename)) | ||
db.close(db.STATE_DB) | ||
|
||
# Ensure port_operr_table is a dictionary |
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.
@vdahiya12 not sure why we need this. The db value is always a key /value pari
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.
fixed
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
MSFT ADO 30169175
What I did
This pull request introduces a new subcommand to the show interfaces command, allowing users to view error statistics for network interfaces. The new errors subcommand displays a table of potential interface errors, including error types, counts, and the last timestamp (in UTC) when the error occurred. If an error has not been encountered, the count defaults to 0, and the timestamp is displayed as Never. This change helps users easily identify any issues with their network interfaces and track error occurrences.
How I did it
To implement the errors subcommand, added a new command handler to the show/interfaces/init.py file. The handler retrieves the error data for a specified interface from the PORT_OPERR_TABLE in the database. The error types are predefined in a list, and for each type, the count and timestamp are pulled from the table. The results are then formatted into a table using the tabulate library, sorted alphabetically by error type.
How to verify it
UT and running the changes on a testbed
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)