Skip to content

[Nexthop][fboss2-dev] Add delete qos policy subcommands - #1497

Open
vybhav-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:delete-qos-policy
Open

[Nexthop][fboss2-dev] Add delete qos policy subcommands#1497
vybhav-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:delete-qos-policy

Conversation

@vybhav-nexthop

@vybhav-nexthop vybhav-nexthop commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Pre-submission checklist

  • 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
  • pre-commit run

Summary

What. Adds the delete counterpart to the existing config qos policy family:

fboss2-dev delete qos policy <name>
fboss2-dev delete qos policy <name> map dscp <dscp-value>
fboss2-dev delete qos policy <name> map tc-to-queue <tc>

Why. The QoS
policy object itself, its DSCP-to-traffic-class mappings, and its
traffic-class-to-queue mappings needs the delete operation. You could add them and never take them away.

How.

Whole-policy delete refuses when the policy is still named by
dataPlaneTrafficPolicy or cpuTrafficPolicy.trafficPolicy, through either
defaultQosPolicy or portIdToQosPolicy, and reports the exact referring
field. These are plain strings in thrift, so nothing else stops a delete from
leaving a dangling reference. Refusing rather than cascading is deliberate->
clearing the referrer would change forwarding on ports the user did not name.

dscpMaps is a list of groups keyed by internalTrafficClass, not a flat map,
so removing a DSCP value erases it from the group that lists it. A group left
with no ingress codepoints and no fromTrafficClassToDscp rewrite carries no
information and is dropped; a group that still has the egress rewrite is kept —
the two halves are independent.

tc-to-queue is a plain map erase.

Only dscp and tc-to-queue are removable. The other map types
CmdConfigQosPolicyMap can write are rejected by name with the supported list
rather than silently accepted

The policy-by-name scan moves into a shared utils::findQosPolicy
(commands/config/qos/QosPolicyUtils.h, alongside the existing
PortQueueConfigUtils), replacing three separate copies — one in each new
delete command and the hand-rolled loop in CmdConfigQosPolicyMap. The name
argument reuses QosPolicyName from the config side for the same reason, the
way delete qos queuing-policy reuses QueuingPolicyName.

Test Plan

15 unit tests in CmdDeleteQosPolicyTest.cpp, seeded with one deletable
policy and one referenced by dataPlaneTrafficPolicy.defaultQosPolicy:

[       OK ] CmdDeleteQosPolicyTestFixture.policyNameArgValidation (41 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.mapEntryArgValidation (36 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.deleteUnreferencedPolicy (71 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.deleteReferencedPolicyRefused (68 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.deleteMissingPolicyFails (70 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.deleteDscpFromSharedEntry (89 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.deleteLastDscpDropsEntry (112 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.deleteDscpKeepsEntryWithEgressRewrite (83 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.deleteMissingDscpFails (56 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.deleteTcToQueue (76 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.deleteMissingTcToQueueFails (58 ms)
[       OK ] CmdDeleteQosPolicyTestFixture.mapDeleteOnMissingPolicyFails (56 ms)
[==========] 12 tests from 1 test suite ran. (823 ms total)
[  PASSED  ] 12 tests.

Full cmd_config_test suite, unfiltered, no regressions:

[==========] 734 tests from 59 test suites ran
[  PASSED  ] 734 tests.
//fboss/cli/fboss2/test/config:cmd_config_test    PASSED in 53.8s

Integration test — test/integration_test/DeleteQosPolicyTest.cpp, one test,
self-cleaning: create a scratch policy carrying a dscp mapping and a
tc-to-queue mapping, delete the dscp entry and assert trafficClassToQueueId
is untouched, assert the repeat delete errors, delete the tc-to-queue entry,
delete the policy, assert the repeat delete errors.

Review Findings

Pre-publication review (fboss-review) is clean after fixes: the three refusal
branches (portIdToQosPolicy, cpuTrafficPolicy, and the no-qosMap guard) gained
unit coverage, and the DSCP bounds and find-policy-or-throw were de-duplicated
into QosPolicyUtils.

Adds the delete counterpart to the existing `config qos policy` family:

  fboss2-dev delete qos policy <name>
  fboss2-dev delete qos policy <name> map dscp <dscp-value>
  fboss2-dev delete qos policy <name> map tc-to-queue <tc>

Whole-policy delete refuses when the policy is still named by
dataPlaneTrafficPolicy or cpuTrafficPolicy.trafficPolicy, via either
defaultQosPolicy or portIdToQosPolicy. The error reports the referring field
so the operator knows what to unset first. Cascading instead would change
forwarding on ports the user did not name.

dscpMaps groups codepoints under an internalTrafficClass, so removing a DSCP
value erases it from the group that lists it. A group left with no ingress
codepoints and no fromTrafficClassToDscp rewrite carries no information and is
dropped; one that still has the egress rewrite is kept.

tc-to-queue is a plain map erase. Only dscp and tc-to-queue are removable; the
other map types the config command writes are rejected by name.

The policy-by-name scan and the DSCP bounds are shared with the config side via
QosPolicyUtils, so both agree on what "the policy called X" means and on the
valid DSCP range.
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.

1 participant