Skip to content

[multi-asic] Add multi asic support for VRF and clear flowcnt-trap#4383

Open
DavidZagury wants to merge 5 commits into
sonic-net:masterfrom
DavidZagury:master_multi_asic_flow_vrf
Open

[multi-asic] Add multi asic support for VRF and clear flowcnt-trap#4383
DavidZagury wants to merge 5 commits into
sonic-net:masterfrom
DavidZagury:master_multi_asic_flow_vrf

Conversation

@DavidZagury

Copy link
Copy Markdown
Contributor

What I did

Added multi asic support for commands:

  • sonic-clear flowcnt-trap {-n asic#}
  • config vrf -n {ASIC#} add/del {...}

How I did it

Modified the vrf and clear flowcnt-trap commands to add muti-asic support

How to verify it

Verified the commands in a multi asic device using the namespace flag

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)

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Signed-off-by: david.zagury <davidza@nvidia.com>
@DavidZagury DavidZagury force-pushed the master_multi_asic_flow_vrf branch from 91eaf2b to 9852e41 Compare March 22, 2026 20:03
@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).

@DavidZagury DavidZagury force-pushed the master_multi_asic_flow_vrf branch from 86a62ef to d754747 Compare March 24, 2026 13:53
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Signed-off-by: david.zagury <davidza@nvidia.com>
@DavidZagury DavidZagury force-pushed the master_multi_asic_flow_vrf branch from d754747 to 14dc447 Compare March 24, 2026 14:32
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@liat-grozovik

Copy link
Copy Markdown
Collaborator

@DavidZagury i assume that these commands are on the command reference doc, should you update it with the updated CLI as well?

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

…ace support

Signed-off-by: david.zagury <davidza@nvidia.com>
@DavidZagury DavidZagury force-pushed the master_multi_asic_flow_vrf branch from 7c4ae2f to 61c00b0 Compare May 13, 2026 10:56
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@DavidZagury

Copy link
Copy Markdown
Contributor Author

@DavidZagury i assume that these commands are on the command reference doc, should you update it with the updated CLI as well?

Updated command reference

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 adds multi-ASIC namespace handling to VRF configuration and trap flow counter clearing commands in sonic-utilities.

Changes:

  • Adds -n/--namespace support to config vrf.
  • Adds -n/--namespace support to sonic-clear flowcnt-trap.
  • Updates tests and command reference documentation for the new namespace behavior.

Reviewed changes

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

Show a summary per file
File Description
config/main.py Adds namespace option and namespaced CONFIG_DB connection for config vrf.
clear/main.py Passes namespace through to flow_counters_stat for trap flow counter clears.
tests/vrf_test.py Adds VRF namespace behavior tests.
tests/clear_test.py Adds flowcnt-trap namespace tests.
doc/Command-Reference.md Documents namespace usage for VRF and flow counter clear commands.

Comment thread doc/Command-Reference.md Outdated
```

- Details:
- -n, --namespace: (Multi-ASIC) Namespace name (e.g. asic0). When omitted, the default namespace is targeted.
Comment thread tests/vrf_test.py Outdated
Comment thread tests/vrf_test.py Outdated
Comment thread clear/main.py
Comment thread config/main.py Outdated
Comment thread doc/Command-Reference.md Outdated
Comment thread doc/Command-Reference.md Outdated
Comment thread doc/Command-Reference.md Outdated
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@DavidZagury DavidZagury force-pushed the master_multi_asic_flow_vrf branch from bd11708 to 174e371 Compare June 4, 2026 18:29
@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).

The `config vrf` group now treats `-n/--namespace` as optional and
validates it per-subcommand: `add mgmt`/`del mgmt` reject `-n` and write
to the global CONFIG_DB, while data-VRF subcommands (`add Vrf-*`,
`del Vrf-*`, `add_vrf_vni_map`, `del_vrf_vni_map`) require `-n` on
multi-ASIC platforms. Doc updated to match.

Multi-ASIC vrf tests now use context-manager patches with the module
reload inside a try/finally so the patched multi-ASIC state can't leak
into later tests.

Signed-off-by: david.zagury <davidza@nvidia.com>
@DavidZagury DavidZagury force-pushed the master_multi_asic_flow_vrf branch from 3339459 to 2875a23 Compare June 4, 2026 19:16
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Signed-off-by: david.zagury <davidza@nvidia.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@Sourabh-Kumar7

Copy link
Copy Markdown
Member

@qiluo-msft could you please help review and approve the change?

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

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

Comment thread tests/clear_test.py
Comment on lines +341 to +342
@patch('clear.main.run_command')
@patch('utilities_common.multi_asic.multi_asic_ns_choices', MagicMock(return_value=['']))
Comment thread tests/clear_test.py
Comment on lines +350 to +353
@patch('clear.main.run_command')
@patch('utilities_common.multi_asic.multi_asic_ns_choices',
MagicMock(return_value=['asic0', 'asic1', 'asic2', 'asic3']))
@patch.object(click.Choice, 'convert', MagicMock(return_value='asic0'))
Comment thread clear/main.py
Comment on lines +686 to +688
@click.option('--namespace', '-n', 'namespace', default=None,
type=click.Choice(multi_asic_util.multi_asic_ns_choices()),
show_default=True, help='Namespace name')
@Sourabh-Kumar7

Copy link
Copy Markdown
Member

@saiarcot895 could you please review the change?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants