Repository navigation
[Nexthop][fboss2-dev] Add QoS policy map configuration commands - #881
Closed
benoit-nexthop wants to merge 1 commit into
Closed
benoit-nexthop wants to merge 1 commit into
benoit-nexthop wants to merge 1 commit into
Conversation
2 tasks done
benoit-nexthop
force-pushed
the
fboss2-cli-prototype_part24
branch
2 times, most recently
from
February 3, 2026 03:05
0ef3ae8 to
b040a70
Compare
2 tasks done
meta-codesync Bot
pushed a commit
that referenced
this pull request
Mar 19, 2026
Summary: **Pre-submission checklist** - [x] I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running `pip install -r requirements-dev.txt && pre-commit install` - [x] `pre-commit run` This adds a new CLI command to assign a queuing policy (port queue configuration) to a physical interface: ``` fboss2 config interface <name> queuing-policy <policy-name> ``` The command validates that the specified policy exists in `portQueueConfigs` before setting the `portQueueConfigName` attribute on the port. Note: this change is part of a series, the previous one is #866, the next one is #881. Pull Request resolved: #867 Test Plan: End-to-end test output (expanded to include interface assignment): ``` [Step 2] Configuring queuing policy 'cli_e2e_test_queue_policy'... Configuring queue-id 2... [CLI] Running: config qos queuing-policy cli_e2e_test_queue_policy queue-id 2 scheduling SP weight 10 shared-bytes 83618832 [...] All queues configured Assigning queuing policy to interface 'eth1/1/1'... [CLI] Running: config interface eth1/1/1 queuing-policy cli_e2e_test_queue_policy [CLI] Completed in 0.07s: config interface eth1/1/1 queuing-policy cli_e2e_test_queue_policy Queuing policy assigned [Step 3] Committing configuration... [CLI] Running: config session commit [CLI] Completed in 16.09s: config session commit Configuration committed successfully [Step 4] Verifying configuration... Buffer pool 'cli_e2e_test_buffer_pool' verified Queuing policy 'cli_e2e_test_queue_policy' verified Interface 'eth1/1/1' queuing policy verified ====================================================================== TEST PASSED ====================================================================== ``` ## Sample usage ``` $ fboss2 config qos queuing-policy sample_policy queue-id 0 scheduling sp Successfully configured queuing-policy 'sample_policy' queue-id 0 $ fboss2 config interface eth1/1/1 queuing-policy sample_policy Successfully set queuing-policy 'sample_policy' for interface(s) eth1/1/1 $ fboss2 config session diff --- current live config +++ session config @@ -2197,7 +2197,15 @@ "maxNeighborProbes": 300, "mirrorOnDropReports": [], "mirrors": [], - "portQueueConfigs": {}, + "portQueueConfigs": { + "sample_policy": [ + { + "id": 0, + "scheduling": 1, + "streamType": 0 + } + ] + }, "ports": [ { "conditionalEntropyRehash": false, @@ -2219,6 +2227,7 @@ "rx": false, "tx": false }, + "portQueueConfigName": "sample_policy", "portType": 0, "profileID": 39, "queues_DEPRECATED": [], ``` Reviewed By: srikrishnagopu Differential Revision: D97239642 Pulled By: joseph5wu fbshipit-source-id: fd98a6b8b170c3fcb37a1b4d69d108dc03214f32
# Summary
Command syntax:
```
fboss2-dev config qos policy <name> map <map-type> <key> <value>
```
Where:
- `<name>` is the QoS policy name
- `<map-type>` is one of: `tc-to-queue`, `pfc-pri-to-queue`, `tc-to-pg`, `pfc-pri-to-pg`
- `<key>` and `<value>` are integers from 0-7
# Test Plan
New end to end test:
```
======================================================================
CLI E2E Test: QoS Policy Configuration
======================================================================
[Step 0] Cleaning up any existing test config...
Copying system config to session config...
Removing QoS policy test configs...
Updating metadata for AGENT_RESTART...
Committing cleanup...
Using CLI from FBOSS_CLI_PATH: ./fboss2-dev
[CLI] Running: config session commit
[CLI] Completed in 2.77s: config session commit
Cleanup complete
[Step 1] Configuring QoS policy 'cli_e2e_test_qos_policy'...
Configuring trafficClassToQueueId (tc-to-queue)...
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-queue 0 0
[CLI] Completed in 0.08s: config qos policy cli_e2e_test_qos_policy map tc-to-queue 0 0
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-queue 1 1
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map tc-to-queue 1 1
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-queue 2 2
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map tc-to-queue 2 2
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-queue 3 3
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map tc-to-queue 3 3
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-queue 4 4
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map tc-to-queue 4 4
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-queue 5 5
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map tc-to-queue 5 5
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-queue 6 6
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map tc-to-queue 6 6
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-queue 7 7
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map tc-to-queue 7 7
Configuring pfcPriorityToQueueId (pfc-pri-to-queue)...
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 0 0
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 0 0
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 1 1
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 1 1
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 2 2
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 2 2
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 3 3
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 3 3
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 4 4
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 4 4
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 5 5
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 5 5
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 6 6
[CLI] Completed in 0.05s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 6 6
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 7 7
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-queue 7 7
Configuring trafficClassToPgId (tc-to-pg)...
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-pg 0 0
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map tc-to-pg 0 0
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-pg 1 1
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map tc-to-pg 1 1
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-pg 2 2
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map tc-to-pg 2 2
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-pg 3 3
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map tc-to-pg 3 3
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-pg 4 4
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map tc-to-pg 4 4
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-pg 5 5
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map tc-to-pg 5 5
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-pg 6 6
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map tc-to-pg 6 6
[CLI] Running: config qos policy cli_e2e_test_qos_policy map tc-to-pg 7 7
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map tc-to-pg 7 7
Configuring pfcPriorityToPgId (pfc-pri-to-pg)...
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 0 0
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 0 0
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 1 1
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 1 1
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 2 2
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 2 2
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 3 3
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 3 3
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 4 4
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 4 4
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 5 5
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 5 5
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 6 6
[CLI] Completed in 0.06s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 6 6
[CLI] Running: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 7 7
[CLI] Completed in 0.07s: config qos policy cli_e2e_test_qos_policy map pfc-pri-to-pg 7 7
QoS policy configured
[Step 2] Committing configuration...
[CLI] Running: config session commit
[CLI] Completed in 10.59s: config session commit
Configuration committed successfully
[Step 3] Verifying configuration...
QoS policy 'cli_e2e_test_qos_policy' found
trafficClassToQueueId verified
pfcPriorityToQueueId verified
trafficClassToPgId verified
pfcPriorityToPgId verified
======================================================================
TEST PASSED
======================================================================
[Step 4] Cleaning up test config...
Copying system config to session config...
Removing QoS policy test configs...
Updating metadata for AGENT_RESTART...
Committing cleanup...
[CLI] Running: config session commit
[CLI] Completed in 6.50s: config session commit
Cleanup complete
```
## Sample usage
```
admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map tc-to-queue 0 0
Successfully set QoS policy 'test-policy' trafficClassToQueueId [0] = 0
admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map pfc-pri-to-queue 3 5
Successfully set QoS policy 'test-policy' pfcPriorityToQueueId [3] = 5
admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map tc-to-pg 2 2
Successfully set QoS policy 'test-policy' trafficClassToPgId [2] = 2
admin@fboss101:~/benoit$ ./fboss2-dev config qos policy test-policy map pfc-pri-to-pg 7 7
Successfully set QoS policy 'test-policy' pfcPriorityToPgId [7] = 7
admin@fboss101:~/benoit$ ./fboss2-dev config session diff
--- current live config
+++ session config
@@ -5871,7 +5871,28 @@
}
],
"proactiveArp": false,
- "qosPolicies": [],
+ "qosPolicies": [
+ {
+ "name": "test-policy",
+ "qosMap": {
+ "dscpMaps": [],
+ "expMaps": [],
+ "pfcPriorityToPgId": {
+ "7": 7
+ },
+ "pfcPriorityToQueueId": {
+ "3": 5
+ },
+ "trafficClassToPgId": {
+ "2": 2
+ },
+ "trafficClassToQueueId": {
+ "0": 0
+ }
+ },
+ "rules": []
+ }
+ ],
"sFlowCollectors": [],
"sdkVersion": {
"asicSdk": "sdk",
```
benoit-nexthop
force-pushed
the
fboss2-cli-prototype_part24
branch
from
March 19, 2026 09:46
b040a70 to
5585398
Compare
Contributor
|
@joseph5wu has imported this pull request. If you are a Meta employee, you can view this in D97308312. |
Contributor
|
@joseph5wu merged this pull request in b36bd06. |
meta-codesync Bot
pushed a commit
that referenced
this pull request
Mar 23, 2026
Summary: **Pre-submission checklist** - [x] I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running `pip install -r requirements-dev.txt && pre-commit install` - [x] `pre-commit run` This change enables running multiple CLI commands within a single process, which is required for C++ end-to-end tests. The first two end-to-end tests that were originally written in Python, along with helper functions, have been rewritten in C++, and can now run as a self-contained gtest binary, without depending on the fboss2-dev binary. Some fixes were necessary to make this work, so the CLI could be re-used as a library instead of being invoked as a subprocess: 1. Remove the `hasRun` static variable from `CmdHandler` - Previously, a static `hasRun` flag prevented commands from executing more than once per process - Now we wrap callbacks in `CmdSubcommands` to check `get_subcommands().empty()` to detect leaf commands, eliminating the need for static state 2. Throw exceptions instead of calling `exit(1)` in `CmdHandler` - `CmdHandler::run()` now rethrows exceptions instead of calling `exit(1)` - This allows tests to catch errors and verify exit codes - `Main.cpp` catches exceptions and returns exit code 1 3. Factor out `CLI::App` initialization into `CliAppInit.h` - Header-only `initApp()` function shared between `Main.cpp` and tests - Eliminates code duplication for CLI setup - This couldn't be packaged into a library of its own without going into circular dependency hell, hence why it's a header-only helper 4. Reset state in `ConfigSession::initializeSession()` - Clear `ConfigSession` attributes when creating a new session (when session file doesn't exist) - Allows re-using the same `ConfigSession` singleton after `commit()` 5. Update state in `ConfigSession::commit()` - Set `base_` to the new commit SHA after successful commit - Set `configLoaded_ = false` to force config reload on next access - Allows re-using the same `ConfigSession` singleton after `commit()` 6. Automatically initialize session in `ConfigSession::loadConfig()` - If session file doesn't exist (e.g., after commit deleted it), call `initializeSession()` to create a fresh session These changes allow the ConfigSession singleton to be properly reused across multiple CLI command invocations within the same process. Note: this change is part of a series, the previous one is #881, the next one is #896. Pull Request resolved: #893 Test Plan: Added new end-to-end tests in C++ that replace `test_config_interface_mtu.py` and `test_config_interface_description.py` (the Python scripts will be removed in a future PR soon). Sample output (simplified, without timestamps and other noise): ``` [==========] Running 2 tests from 2 test suites. [----------] 1 test from ConfigInterfaceDescriptionTest [ RUN ] ConfigInterfaceDescriptionTest.SetAndVerifyDescription [Step 1] Finding an interface to test... Using interface: eth1/1/1 (VLAN: 2001) [Step 2] Getting current description... Current description: 'CLI_E2E_TEST_DESCRIPTION_ALT' [Step 3] Setting description to 'CLI_E2E_TEST_DESCRIPTION'... Description set to 'CLI_E2E_TEST_DESCRIPTION' [Step 4] Verifying description via 'show interface'... Verified: Description is 'CLI_E2E_TEST_DESCRIPTION' [Step 5] Restoring original description ('CLI_E2E_TEST_DESCRIPTION_ALT')... Restored description to 'CLI_E2E_TEST_DESCRIPTION_ALT' TEST PASSED [ OK ] ConfigInterfaceDescriptionTest.SetAndVerifyDescription (412 ms) [----------] 1 test from ConfigInterfaceMtuTest [ RUN ] ConfigInterfaceMtuTest.SetAndVerifyMtu [Step 1] Finding an interface to test... Using interface: eth1/1/1 (VLAN: 2001) [Step 2] Getting current MTU... Current MTU: 9000 [Step 3] Setting MTU to 1500... MTU set to 1500 [Step 4] Verifying MTU via 'show interface'... Verified: MTU is 1500 [Step 5] Verifying kernel interface MTU... Verified: Kernel interface fboss2001 has MTU 1500 [Step 6] Restoring original MTU (9000)... Restored MTU to 9000 TEST PASSED [ OK ] ConfigInterfaceMtuTest.SetAndVerifyMtu (384 ms) [==========] 2 tests from 2 test suites ran. (797 ms total) [ PASSED ] 2 tests. ``` Reviewed By: KevinYakar Differential Revision: D97513684 Pulled By: joseph5wu fbshipit-source-id: d859acf8b875fb09bc215c22b49bac4e0a0321df
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runSummary
Command syntax:
Where:
<name>is the QoS policy name<map-type>is one of:tc-to-queue,pfc-pri-to-queue,tc-to-pg,pfc-pri-to-pg<key>and<value>are integers from 0-7Note: this change is part of a series, the previous one is #867, the next one is #893.
Test Plan
New end to end test:
Sample usage