Skip to content

Add isolate reason, isolated link count, and -nz filtering for fabric cli commands#4641

Open
saksarav-nokia wants to merge 3 commits into
sonic-net:masterfrom
saksarav-nokia:saksarav-nokia-fabric-isolate
Open

Add isolate reason, isolated link count, and -nz filtering for fabric cli commands#4641
saksarav-nokia wants to merge 3 commits into
sonic-net:masterfrom
saksarav-nokia:saksarav-nokia-fabric-isolate

Conversation

@saksarav-nokia

@saksarav-nokia saksarav-nokia commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What I did

Made the following changes in fabric cli commands . The corresponding sonic-swss PR sonic-net/sonic-swss#4704
Display ISOLATE_REASON from STATE_DB in fabric isolation output.
show isolated_links in fabric capacity alongside operating/total links, matching new FabricPortsOrch telemetry.
Add -nz/--nonzero to fabricstat and show fabric for port, queue, rate, and isolation views to hide rows with zero counter deltas or rates.
Extend fabricstat unit tests and mock STATE_DB/COUNTERS_DB fixtures for the new fields and nonzero filtering.

sonic-mgmt PR: sonic-net/sonic-mgmt#25637

How I did it

Modified "show fabric isolation" command out

Modified "show fabric monitor capacity" output.

Added -nz or --nonzero option to all "show fabric" commands

How to verify it

Added unit tests
Also modifying existing sonic-mgmt tests.

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

image image image image

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

image image

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@saksarav-nokia

Copy link
Copy Markdown
Contributor Author

@vmittal-msft @ysmanman @kenneth-arista , Please review.
This is a minor enhancement to the fabric isolation and fabric monitor feature for better debugging. With these changes, the "show fabric monitor capacity" and 'show fabric isolation' commands tell us what is exact reason for the isolated ports Instead of checking multiple cli commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 SONiC’s fabric CLI surface area (both the show fabric ... Click commands and the underlying fabricstat script) to expose additional fabric isolation/capacity telemetry and to add optional “non-zero only” filtering to reduce noise in command outputs.

Changes:

  • Add ISOLATE_REASON display to fabric isolation output and introduce -nz/--nonzero filtering for isolation, port, queue, and rate views.
  • Extend fabric capacity output to include isolated_links alongside operating/total links.
  • Update unit tests and mock STATE_DB/COUNTERS_DB fixtures to cover the new columns and nonzero filtering behavior (primarily for fabricstat).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/mock_tables/state_db.json Adds isolated_links to fabric capacity fixture data.
tests/mock_tables/counters_db.json Adjusts a counter fixture value to align with new nonzero filtering expectations.
tests/mock_tables/asic1/state_db.json Adds isolation flags/reason fields and isolated_links for multi-ASIC fixture coverage.
tests/mock_tables/asic1/counters_db.json Adjusts FEC uncorrectable counters to support nonzero-delta filtering tests.
tests/mock_tables/asic0/state_db.json Adds isolation flags/reason fields and isolated_links for asic0 fixture coverage.
tests/mock_tables/asic0/counters_db.json Adjusts a counter fixture value to align with nonzero filtering expectations.
tests/fabricstat_test.py Expands expected outputs and adds new test cases for fabricstat -nz modes.
show/fabric.py Adds -nz/--nonzero options to show fabric commands and forwards to fabricstat.
scripts/fabricstat Implements isolate reason display, isolated link count in capacity output, and nonzero filtering logic.

Comment thread show/fabric.py
Comment thread scripts/fabricstat Outdated

@vmittal-msft vmittal-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the change — I went through the full diff. Overall it looks good and the logic is consistent. A few notes below: one bug-fix call-out, agreement with the two automated comments, and a few items those didn't cover.

Nice catch / bug fix

Moving the rxRate/txRate/rxData/txData/time/local_time initialization inside the per-port loop in FabricRate.rate_print fixes a real state-leak — ports missing rate fields previously inherited the prior port's values. Confirmed against the mock data (ports 1/3/5 have no OLD_*_RATE_AVG, and the old expected output was asserting those leaked values). Good fix.

On the two automated review comments — both valid

  1. Missing click-layer tests for -nz. fabricstat_test.py exercises the script directly via subprocess, so the show fabric ... click forwarding (if nonzero: cmd += ['-nz']) for port/queue/rate/isolation is untested. tests/show_test.py::TestShowFabric already covers port/queue — worth adding -nz variants there.
  2. N/A treated as non-zero. _fabric_port_row_has_nonzero_counter returns True for None (N/A), so N/A rows are always shown while the help text says "non-zero". Reasonable behavior, but the help could call it out.

A few additional items

  • Line length: scripts/fabricstat ~line 394 (the wrapped table_cnt.append(...)) is 123 chars, over the repo's --max-line-length=120. It was added in the first commit, so the diff-based pre-commit hook won't flag it, but a full flake8 run will.
  • Inconsistent empty-table behavior under -nz: rate_print returns and prints nothing when the filtered body is empty, while isolation/port/queue still print a header with no rows. Minor, but worth making uniform.
  • -nz semantics differ by view: for the full port/queue views the delta is computed vs. saved/cleared stats, so without a prior -C the delta equals the absolute counter and nearly every active link shows — it's most meaningful after a clear there (isolation/rate reflect current state regardless). Might be worth a doc note.
  • -nz is silently ignored with -c (capacity) and reachability — fine, just undocumented.

I also confirmed -nz does not collide with -n/namespace in either argparse or click (exact registered option strings win), so no problem there.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@saksarav-nokia

Copy link
Copy Markdown
Contributor Author

/azpw run

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1152028:

✅Stage Build:

  • Job Python3: retried.

@saksarav-nokia

Copy link
Copy Markdown
Contributor Author

Thanks for the change — I went through the full diff. Overall it looks good and the logic is consistent. A few notes below: one bug-fix call-out, agreement with the two automated comments, and a few items those didn't cover.

Nice catch / bug fix

Moving the rxRate/txRate/rxData/txData/time/local_time initialization inside the per-port loop in FabricRate.rate_print fixes a real state-leak — ports missing rate fields previously inherited the prior port's values. Confirmed against the mock data (ports 1/3/5 have no OLD_*_RATE_AVG, and the old expected output was asserting those leaked values). Good fix.

On the two automated review comments — both valid

  1. Missing click-layer tests for -nz. fabricstat_test.py exercises the script directly via subprocess, so the show fabric ... click forwarding (if nonzero: cmd += ['-nz']) for port/queue/rate/isolation is untested. tests/show_test.py::TestShowFabric already covers port/queue — worth adding -nz variants there.
  2. N/A treated as non-zero. _fabric_port_row_has_nonzero_counter returns True for None (N/A), so N/A rows are always shown while the help text says "non-zero". Reasonable behavior, but the help could call it out.

A few additional items

  • Line length: scripts/fabricstat ~line 394 (the wrapped table_cnt.append(...)) is 123 chars, over the repo's --max-line-length=120. It was added in the first commit, so the diff-based pre-commit hook won't flag it, but a full flake8 run will.
  • Inconsistent empty-table behavior under -nz: rate_print returns and prints nothing when the filtered body is empty, while isolation/port/queue still print a header with no rows. Minor, but worth making uniform.
  • -nz semantics differ by view: for the full port/queue views the delta is computed vs. saved/cleared stats, so without a prior -C the delta equals the absolute counter and nearly every active link shows — it's most meaningful after a clear there (isolation/rate reflect current state regardless). Might be worth a doc note.
  • -nz is silently ignored with -c (capacity) and reachability — fine, just undocumented.

I also confirmed -nz does not collide with -n/namespace in either argparse or click (exact registered option strings win), so no problem there.

Addressed these review comments

@saksarav-nokia

saksarav-nokia commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

/azpw run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

… cli commands

Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
@saksarav-nokia saksarav-nokia force-pushed the saksarav-nokia-fabric-isolate branch from 3ea8230 to 959a3a9 Compare July 6, 2026 13:52
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants