Skip to content

[Nexthop][fboss2-dev] Show only the user change in config session diff - #1991

Open
saty-nexthop wants to merge 1 commit into
meta:mainfrom
nexthop-ai:fboss2-session-diff-user-change
Open

saty-nexthop wants to merge 1 commit into
meta:mainfrom
nexthop-ai:fboss2-session-diff-user-change

Conversation

@saty-nexthop

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

fboss2-dev config session diff shows thousands of changed lines for one small change. saveConfig() writes the session file through the thrift struct, with sorted keys and default values. The live file has neither.

  • New ConfigSession::normalizedConfigJson() writes the agent or BGP config text as saveConfig() does. Text that does not parse stays raw, with a warning.
  • config session diff normalizes both texts before diff -u, in each mode, and adds (normalized) to the label. No file on disk changes.
  • One WARNING line names each key that the schema does not know and whose raw value differs, because the normalized diff cannot show it.

Test Plan

  • With the normalization removed, 10 CLI unit tests fail.
  • On a switch, one BGP hold-time change with no commit: the old CLI shows 54351 changed lines. This change shows 6 lines and no warning.
  • A live file with an unknown key: "No differences" and no warning. With the hold-time change: 6 lines and the warning.
  • pre-commit passes. Local cmake build (fake SAI, main at e7ab695, with my other open fixes): fboss2_cmd_config_test 1279 of 1279, including 25 CmdConfigSessionDiff* tests.
  • Not verified: a commit after the diff, and a known key with a null value.

@saty-nexthop
saty-nexthop requested a review from a team as a code owner November 16, 2026 08:25
@github-actions github-actions Bot added nexthop project:fboss2-dev FBOSS project: fboss2-dev labels Nov 16, 2026
@meta-cla meta-cla Bot added the CLA Signed label Nov 16, 2026
"fboss2-dev config session diff" showed thousands of changed lines for
one small change. saveConfig() writes the session file through the
thrift struct, so the file has sorted keys and default values. The live
file does not.

- New ConfigSession::normalizedConfigJson() returns a config text in
  the form that saveConfig() writes, for the agent and BGP configs. Text
  that does not parse stays raw, with a warning on stderr.
- The diff command normalizes both texts before "diff -u", in each
  mode. No file on disk changes. A normalized text gets the label
  suffix " (normalized)".
- The normalized diff cannot show a key that the schema does not know.
  One warning line names each such key whose value differs between the
  two raw texts.
@saty-nexthop
saty-nexthop force-pushed the fboss2-session-diff-user-change branch from 814f50b to eaf361e Compare November 16, 2026 10:30

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants