Skip to content

[show interfaces] "show interfaces flap" command does not support multi-ASIC platforms#4316

Open
pnakka28 wants to merge 4 commits intosonic-net:masterfrom
pnakka28:support_multiasic_flap
Open

[show interfaces] "show interfaces flap" command does not support multi-ASIC platforms#4316
pnakka28 wants to merge 4 commits intosonic-net:masterfrom
pnakka28:support_multiasic_flap

Conversation

@pnakka28
Copy link

What I did

Added multi-ASIC platform support for show interfaces flap command

How I did it

  • Added multi_asic_click_options decorator to support -n/--namespace and -d/--display options
  • Updated the command to iterate across all namespaces and aggregate flap data from each ASIC's APP_DB
  • Added flap mock data to multi-ASIC mock tables (asic0/appl_db.json, asic1/appl_db.json)
  • Added multi-ASIC test file tests/flap_test.py

How to verify it

# Run multi-ASIC tests
pytest tests/flap_test.py -v

# On a multi-ASIC device
show interfaces flap
show interfaces flap -n asic0

Previous command output (if the output of a command-line utility has changed)

admin@sonic:~$ show interfaces flap
Interface    Flap Count    Admin    Oper     Link Down TimeStamp(UTC)    Link Up TimeStamp(UTC)
-----------  ------------  -------  -------  --------------------------  ------------------------
etp1         Never         Unknown  Unknown  Never                       Never
etp2         Never         Unknown  Unknown  Never                       Never
etp3         Never         Unknown  Unknown  Never                       Never
etp4         Never         Unknown  Unknown  Never                       Never
...

admin@sonic:~$ show interfaces flap -n asic0
Usage: show interfaces flap [OPTIONS] [INTERFACENAME]
Try "show interfaces flap -h" for help.

Error: no such option: -n

New command output (if the output of a command-line utility has changed)

admin@sonic:~$ show interfaces flap
Interface      Flap Count  Admin    Oper    Link Down TimeStamp(UTC)    Link Up TimeStamp(UTC)
-----------  ------------  -------  ------  --------------------------  ------------------------
Ethernet0            4097  Up       Up      Sat Feb 21 11:00:41 2026    Sat Feb 21 11:00:59 2026
Ethernet8            4035  Up       Up      Sat Feb 21 11:00:41 2026    Sat Feb 21 11:00:59 2026
Ethernet16           4015  Up       Up      Sat Feb 21 11:01:23 2026    Sat Feb 21 11:01:41 2026
Ethernet24           4019  Up       Up      Sat Feb 21 11:01:23 2026    Sat Feb 21 11:01:41 2026
...

admin@sonic:~$ show interfaces flap -n asic0
Interface      Flap Count  Admin    Oper    Link Down TimeStamp(UTC)    Link Up TimeStamp(UTC)
-----------  ------------  -------  ------  --------------------------  ------------------------
Ethernet0            4097  Up       Up      Sat Feb 21 11:00:41 2026    Sat Feb 21 11:00:59 2026
Ethernet8            4035  Up       Up      Sat Feb 21 11:00:41 2026    Sat Feb 21 11:00:59 2026
Ethernet16           4015  Up       Up      Sat Feb 21 11:01:23 2026    Sat Feb 21 11:01:41 2026
Ethernet24           4019  Up       Up      Sat Feb 21 11:01:23 2026    Sat Feb 21 11:01:41 2026
...

…ti-ASIC platforms

- Added multi-ASIC support for namespace and display filtering
- Added multi-ASIC tests in tests/flap_test.py

Signed-off-by: Pavan Kalyan Nakka <pnakka@microsoft.com>
Copilot AI review requested due to automatic review settings February 27, 2026 22:39
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

Copilot AI left a 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 updates the SONiC show interfaces flap CLI to work on multi-ASIC systems by adding standard multi-ASIC options and aggregating flap data across namespaces, along with new multi-ASIC-focused unit tests and mock DB data.

Changes:

  • Add -n/--namespace and -d/--display support to show interfaces flap using multi_asic_click_options.
  • Update the command implementation to iterate namespaces and collect flap data from each ASIC’s APPL_DB.
  • Add multi-ASIC flap mock data and introduce a new multi-ASIC unit test file.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
show/interfaces/init.py Adds multi-ASIC options to flap and aggregates flap data across namespaces/APP_DB instances.
tests/flap_test.py Adds new unit tests for multi-ASIC show interfaces flap behavior.
tests/mock_tables/asic0/appl_db.json Adds flap fields to asic0 PORT_TABLE mock data.
tests/mock_tables/asic1/appl_db.json Adds flap fields to asic1 PORT_TABLE mock data.

Signed-off-by: Pavan Kalyan Nakka <pnakka@microsoft.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 4316 in repo sonic-net/sonic-utilities

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Pavan Kalyan Nakka <pnakka@microsoft.com>
@pnakka28 pnakka28 force-pushed the support_multiasic_flap branch from c135e0e to 7e7f4f2 Compare March 3, 2026 17:21
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Ethernet8 4035 Up Up Sat Feb 21 11:00:41 2026 Sat Feb 21 11:00:59 2026
Ethernet16 4015 Up Up Sat Feb 21 11:01:23 2026 Sat Feb 21 11:01:41 2026
```
- Example (to only display flap count for interface Ethernet0):
Copy link
Contributor

Choose a reason for hiding this comment

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

@pnakka28 please change comment to " display on mult-asic platform."

Copy link
Author

Choose a reason for hiding this comment

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

@prgeor changed the comment

Signed-off-by: Pavan Kalyan Nakka <pnakka@microsoft.com>
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).


# Display the formatted table
click.echo(tabulate(body, header))

Copy link
Contributor

Choose a reason for hiding this comment

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

@pnakka28 db connection does not need to be closed at the end?

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.

4 participants