Skip to content

[Nexthop][fboss2-dev] Add fboss2-dev delete load-balancing subcommands - #1494

Open
vybhav-nexthop wants to merge 2 commits into
facebook:mainfrom
nexthop-ai:delete-lb-subtree
Open

[Nexthop][fboss2-dev] Add fboss2-dev delete load-balancing subcommands#1494
vybhav-nexthop wants to merge 2 commits into
facebook:mainfrom
nexthop-ai:delete-lb-subtree

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 fboss2-dev delete load-balancing ecmp and delete load-balancing lag, removing the matching LoadBalancer entry from sw.loadBalancers. Errors out if the entry is not configured.

Why: The config side (config load-balancing ecmp|lag <attr> <value>) can create and mutate load-balancer entries but nothing can remove one; an empty loadBalancers list is the valid unconfigured state.

How: New CmdDeleteLoadBalancing parent + ecmp/lag leaf handlers sharing a removeLoadBalancer() helper. Removal commits hitlessly — SaiSwitch dispatches LoadBalancersDelta removals to SaiSwitchManager::removeLoadBalancer

The integration test covers ecmp delete + restore end-to-end. LAG delete shares the same implementation and is covered by unit tests

Test Plan

Unit (6 new for CmdDeleteLoadBalancing, full suite green):

[==========] 719 tests from 59 test suites ran. (50555 ms total)
[  PASSED  ] 719 tests.

Integration on a Nexthop device (delete → verify gone → restore via config CLI → verify match, all hitless):

[ RUN      ] DeleteLoadBalancingTest.DeleteThenRestoreEcmp
[       OK ] DeleteLoadBalancingTest.DeleteThenRestoreEcmp (236 ms)
[  PASSED  ] 1 test.

Sample usage on the device:

$ fboss2-dev delete load-balancing ecmp
Deleted ecmp load-balancer
$ fboss2-dev config session diff
--- current live config
+++ session config
@@ -955,26 +955,6 @@
-      {
-        "algorithm": 1,
-        "fieldSelection": { ... },
-        "id": 1
-      }
$ fboss2-dev config session commit
Config session committed successfully as dbb1b8e and config reloaded for fboss_sw_agent.
$ fboss2-dev delete load-balancing ecmp
localhost: Invalid argument: No ecmp load-balancer configured

Review Findings

Pre-publication review (11-reviewer sweep + verifier, confidence >= 0.7). Two findings, both fixed in this PR before publication:

File Severity Issue Resolution
DeleteLoadBalancingTest.cpp HIGH The delete was committed before the restore ran, and every restore step was a fatal ASSERT_TRUE. A mid-restore failure left the device with no ECMP load-balancer, since the failure path only discards the uncommitted session. Restore logic extracted into stageEcmpRestore(); the test arms a pending restore before the delete commit and clears it after the restore commits, with a TearDown() that puts the entry back if the test aborted in between.
LoadBalancingTestUtils.h MEDIUM Reverse mappings switched on raw integer literals for thrift enum values that have names. Switched to cfg::HashingAlgorithm / cfg::IPv4Field / cfg::IPv6Field / cfg::TransportField / cfg::MPLSField. This also splits the ipv4/ipv6 handling, which previously shared a branch that could return flow-label for an ipv4 field.

delete load-balancing ecmp|lag removes the matching LoadBalancer entry
from sw.loadBalancers. Removal is applied hitlessly: SaiSwitch dispatches
LoadBalancersDelta removals to SaiSwitchManager::removeLoadBalancer with
no ChangeProhibited guard, the same delta path the config load-balancing
subcommands use.
@vybhav-nexthop
vybhav-nexthop requested review from a team as code owners August 10, 2026 07:39
@meta-cla meta-cla Bot added the CLA Signed label Aug 10, 2026
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