[Nexthop][fboss2-dev] Add delete qos policy subcommands - #1497
Open
vybhav-nexthop wants to merge 3 commits into
Open
[Nexthop][fboss2-dev] Add delete qos policy subcommands#1497vybhav-nexthop wants to merge 3 commits into
vybhav-nexthop wants to merge 3 commits into
Conversation
vybhav-nexthop
force-pushed
the
delete-qos-policy
branch
from
August 13, 2026 12:42
00833f3 to
3b12032
Compare
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.
vybhav-nexthop
force-pushed
the
delete-qos-policy
branch
from
August 13, 2026 13:08
3b12032 to
b0c361d
Compare
The config command writes all seven QosMap types but only dscp and tc-to-queue were deletable, leaving the other five as one-way doors: settable via CLI with no CLI way back. Adds mpls-exp, dot1p, pfc-pri-to-queue, tc-to-pg and pfc-pri-to-pg using the same tokens as the config command. List maps (dscp/exp/pcp) share one erase helper: the codepoint is removed from whichever entry's ingress list carries it, and entries left with no codepoints and no egress rewrite are dropped. Optional simple maps are reset once their last key is erased, returning the field to its unset default.
Contributor
Author
|
Extended the map delete to every QosMap type the config command writes (mpls-exp, dot1p, pfc-pri-to-queue, tc-to-pg, pfc-pri-to-pg) — the remaining types were settable via CLI with no CLI way back. Same tokens as the config command; unit tests cover each kind plus the emptied-optional reset behavior. |
Missing-entry and missing-policy errors are unit-tested; the DUT run sticks to the positive flow: create, dismantle entry by entry, remove.
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
What. Adds the delete counterpart to the existing
config qos policyfamily:Why. The QoS policy object and its mappings could be added but never taken
away. The map delete covers every QosMap type
CmdConfigQosPolicyMapwrites —anything less leaves one-way doors: settable via CLI with no CLI way back.
How.
Whole-policy delete refuses when the policy is still named by
dataPlaneTrafficPolicyorcpuTrafficPolicy.trafficPolicy, through eitherdefaultQosPolicyorportIdToQosPolicy, and reports the exact referringfield. 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.
The three list maps (
dscpMaps,expMaps,pcpMaps) are structurallyidentical — groups keyed by
internalTrafficClass, not flat maps — so theyshare one erase helper: the codepoint is removed from the group that lists it.
A group left with no ingress codepoints and no egress rewrite carries no
information and is dropped; a group that still has the rewrite is kept — the
two halves are independent.
The four simple maps (
trafficClassToQueueId,pfcPriorityToQueueId,trafficClassToPgId,pfcPriorityToPgId) are plain key erases. The optionalones are reset once their last key goes, returning the field to its unset
default rather than leaving an empty map behind.
The policy-by-name scan moves into a shared
utils::findQosPolicy(
commands/config/qos/QosPolicyUtils.h, alongside the existingPortQueueConfigUtils), replacing three separate copies — one in each newdelete command and the hand-rolled loop in
CmdConfigQosPolicyMap. The nameargument reuses
QosPolicyNamefrom the config side for the same reason, theway
delete qos queuing-policyreusesQueuingPolicyName.Test Plan
24 unit tests in
CmdDeleteQosPolicyTest.cpp, seeded with one deletablepolicy carrying every map type and one policy referenced by
dataPlaneTrafficPolicy.defaultQosPolicy. Per-kind coverage: delete anexisting entry, delete a missing entry errors, the emptied-optional reset,
and value-range validation (dscp 0-63, everything else 3-bit).
Full
cmd_config_testsuite, unfiltered, no regressions:Integration test —
test/integration_test/DeleteQosPolicyTest.cpp, one test,self-cleaning and positive-flow only (missing-entry/missing-policy errors are
unit-tested): create a scratch policy carrying a dscp mapping and a
tc-to-queue mapping, delete the dscp entry and assert
trafficClassToQueueIdis untouched, delete the tc-to-queue entry, delete the policy.
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.