[Nexthop][fboss2-dev] Save the config commands to CLI metadata and in session commit.#809
Closed
benoit-nexthop wants to merge 2 commits intofacebook:mainfrom
Closed
[Nexthop][fboss2-dev] Save the config commands to CLI metadata and in session commit.#809benoit-nexthop wants to merge 2 commits intofacebook:mainfrom
benoit-nexthop wants to merge 2 commits intofacebook:mainfrom
Conversation
2 tasks
42fe595 to
58cf5a1
Compare
2 tasks
e88c524 to
0304b7c
Compare
0304b7c to
31eb904
Compare
meta-codesync bot
pushed a commit
that referenced
this pull request
Feb 18, 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` A recent merge introduced a duplicate command by mistake (bad merge on my part) and this escaped because of lack of test coverage. Also make sure we keep `cmake/CliFboss2Test.cmake` sorted. Note: this change is part of a series, the previous one is #791, the next one is #809. Pull Request resolved: #805 Test Plan: New regression unit test. Reviewed By: AarjunC Differential Revision: D93523408 Pulled By: joseph5wu fbshipit-source-id: 87c4920c1fa1730631eafbf0a31e8c179145dc0d
d3095ec to
aaed4ff
Compare
|
@joseph5wu has imported this pull request. If you are a Meta employee, you can view this in D93669865. |
joseph5wu
requested changes
Feb 19, 2026
Contributor
joseph5wu
left a comment
There was a problem hiding this comment.
Please address the unit test failure from the github action
https://github.com/facebook/fboss/actions/runs/22161929622/job/64082894482
| fs::create_directories(sessionDir); | ||
| std::ofstream metaFile(metadataFile); | ||
| metaFile << R"({ | ||
| "action": {"WEDGE_AGENT": "HITLESS"}, |
Contributor
There was a problem hiding this comment.
"WEDGE_AGENT" -> "AGENT"
|
|
||
| // Setup mock agent server | ||
| setupMockedAgentServer(); | ||
| EXPECT_CALL(getMockAgent(), reloadConfig()).Times(1); |
Contributor
There was a problem hiding this comment.
Our internal run failed on this unit test:
❯❯❯ buck test //fboss/cli/fboss2/test:cmd_test
File changed: fbcode//fboss/cli/fboss2/test/CmdConfigSessionTest.cpp
✗ Fail: fbcode//fboss/cli/fboss2/test:cmd_test - ConfigSessionTestFixture.commitOnNewlyInitializedSession (3.9s)
Note: Google Test filter = ConfigSessionTestFixture.commitOnNewlyInitializedSession
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ConfigSessionTestFixture
[ RUN ] ConfigSessionTestFixture.commitOnNewlyInitializedSession
fbcode/fboss/cli/fboss2/test/CmdConfigSessionTest.cpp:284: Failure
Actual function call count doesn't match EXPECT_CALL(getMockAgent(), reloadConfig())...
Expected: to be called once
Actual: never called - unsatisfied and active
[ FAILED ] ConfigSessionTestFixture.commitOnNewlyInitializedSession (3921 ms)
Now every config command is saved in the CLI session metadata so we can easily tell what commands were used in a given session. The metadata is now also saved along the config when we commit the session. A future commit will make rollback also rely on this metadata to decide whether or not to restart the agent.
aaed4ff to
17e16c5
Compare
Contributor
|
@benoit-nexthop has updated the pull request. You must reimport the pull request before landing. |
|
@joseph5wu merged this pull request in 9816430. |
meta-codesync bot
pushed a commit
that referenced
this pull request
Mar 3, 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` Replace the basic file-based configuration versioning mechanism with Git-based versioning for the CLI config session. Key changes: - Add new `Git` class providing a simple interface for Git operations: init, commit, log, show, etc - Use `folly::Subprocess` with full path `/usr/bin/git` for all Git commands - Replace revision files (`agent-rN.conf` + symlink) with atomic writes to agent.conf tracked in a local Git repository - Use Git commit SHAs as revision identifiers instead of rN format - Update RevisionList validation to accept Git SHAs (7+ hex chars) Repository initialization: - Automatically initialize Git repo if it doesn't exist - Automatically create initial commit if repo has no commits but config file exists - Use `--shared=group` flag and umask 0002 to ensure `.git` directory is group-writable when `/etc/coop` is group-writable Commands updated: - config history: Shows Git commit log with SHA, author, timestamp, message - config session diff: Uses git show to compare commits - config session commit: Creates Git commits with username as author - config rollback: Reads config from Git history and creates new commit Note: this change is part of a series, the previous one is #809, the next one is #832. Pull Request resolved: #825 Test Plan: Test updates: - Update all CLI config tests to use Git-based setup - Initialize Git repo and create initial commit in test fixtures - Added new unit tests for the Git layer ## Sample usage Simple change and session commit: ``` [admin@fboss101 benoit]$ ./fboss2-dev show interface eth1/1/1 +-----------+--------+-------+------+------+------------------------------+-------------+ | Interface | Status | Speed | VLAN | MTU | Addresses | Description | ----------------------------------------------------------------------------------------- | eth1/1/1 | down | 800G | 2001 | 9000 | 10.0.0.0/24 | demo | | | | | | | 2400::/64 | | | | | | | | fe80::b4db:91ff:fe95:ff07/64 | | ----------------------------------------------------------------------------------------- [admin@fboss101 benoit]$ ./fboss2-dev config interface eth1/1/1 description hello Successfully set description for interface(s) eth1/1/1 [admin@fboss101 benoit]$ ./fboss2-dev config session diff --- current live config +++ session config @@ -2200,7 +2200,7 @@ "ports": [ { "conditionalEntropyRehash": false, - "description": "demo", + "description": "hello", "drainState": 0, "expectedLLDPValues": { "2": "eth1/5/1" [admin@fboss101 benoit]$ ./fboss2-dev config session commit Config session committed successfully as b8245b4 and config reloaded. [admin@fboss101 benoit]$ ./fboss2-dev config history | head Commit Author Commit Time Message ------------------------------------------------------------------------ b8245b40 admin 2026-01-21 11:13:57 Config commit by admin 7241abad admin 2026-01-21 11:12:51 Config commit by admin 02fe511c admin 2026-01-21 10:51:36 Config commit by admin e5650a98 admin 2026-01-21 10:51:35 Config commit by admin ad07138f admin 2026-01-21 10:51:35 Config commit by admin 1845e710 admin 2026-01-21 10:51:35 Config commit by admin ede5a527 admin 2026-01-20 14:28:10 Config commit by admin e900ef88 admin 2026-01-20 14:23:25 Config commit by admin [admin@fboss101 benoit]$ cd /etc/coop [admin@fboss101 coop]$ git -c safe.directory=/etc/coop show commit b8245b40b2b3c8797cbeed2fb91161e5440b7fd9 (HEAD -> main) Author: admin <fboss-cli@localhost> Date: Wed Jan 21 11:13:57 2026 -0800 Config commit by admin diff --git a/cli/agent.conf b/cli/agent.conf index 406b341..f61516f 100644 --- a/cli/agent.conf +++ b/cli/agent.conf @@ -2200,7 +2200,7 @@ "ports": [ { "conditionalEntropyRehash": false, - "description": "demo", + "description": "hello", "drainState": 0, "expectedLLDPValues": { "2": "eth1/5/1" diff --git a/cli/cli_metadata.json b/cli/cli_metadata.json index 68f340a..6c6a925 100644 --- a/cli/cli_metadata.json +++ b/cli/cli_metadata.json @@ -1,6 +1,6 @@ { "action": {}, "commands": [ - "config interface eth1/1/1 description demo" + "config interface eth1/1/1 description hello" ] } \ No newline at end of file ``` Rollback flow: ``` [admin@fboss101 benoit]$ ./fboss2-dev config interface eth1/1/1 description hello2 Successfully set description for interface(s) eth1/1/1 [admin@fboss101 benoit]$ ./fboss2-dev config session commit Config session committed successfully as 476f9ee and config reloaded. [admin@fboss101 benoit]$ ./fboss2-dev config history | head Commit Author Commit Time Message ------------------------------------------------------------------------ 476f9ee4 admin 2026-01-21 11:15:23 Config commit by admin b8245b40 admin 2026-01-21 11:13:57 Config commit by admin 7241abad admin 2026-01-21 11:12:51 Config commit by admin <-- we're going to rollback to here 02fe511c admin 2026-01-21 10:51:36 Config commit by admin e5650a98 admin 2026-01-21 10:51:35 Config commit by admin ad07138f admin 2026-01-21 10:51:35 Config commit by admin 1845e710 admin 2026-01-21 10:51:35 Config commit by admin ede5a527 admin 2026-01-20 14:28:10 Config commit by admin [admin@fboss101 benoit]$ ./fboss2-dev config rollback 7241abad Successfully rolled back. New commit: 8be163e7. Config reloaded. [admin@fboss101 benoit]$ ./fboss2-dev show interface eth1/1/1 +-----------+--------+-------+------+------+------------------------------+-------------+ | Interface | Status | Speed | VLAN | MTU | Addresses | Description | ----------------------------------------------------------------------------------------- | eth1/1/1 | down | 800G | 2001 | 9000 | 10.0.0.0/24 | demo | | | | | | | 2400::/64 | | | | | | | | fe80::b4db:91ff:fe95:ff07/64 | | ----------------------------------------------------------------------------------------- [admin@fboss101 benoit]$ ./fboss2-dev config history | head Commit Author Commit Time Message --------------------------------------------------------------------------- 8be163e7 admin 2026-01-21 11:17:26 Rollback to 7241abad by admin 476f9ee4 admin 2026-01-21 11:15:23 Config commit by admin b8245b40 admin 2026-01-21 11:13:57 Config commit by admin 7241abad admin 2026-01-21 11:12:51 Config commit by admin 02fe511c admin 2026-01-21 10:51:36 Config commit by admin e5650a98 admin 2026-01-21 10:51:35 Config commit by admin ad07138f admin 2026-01-21 10:51:35 Config commit by admin 1845e710 admin 2026-01-21 10:51:35 Config commit by admin [admin@fboss101 benoit]$ cd /etc/coop [admin@fboss101 coop]$ git -c safe.directory=/etc/coop show commit 8be163e7cd60574278dc7201b157e4238fa55380 (HEAD -> main) Author: admin <fboss-cli@localhost> Date: Wed Jan 21 11:17:26 2026 -0800 Rollback to 7241abad by admin diff --git a/cli/agent.conf b/cli/agent.conf index d918bae..406b341 100644 --- a/cli/agent.conf +++ b/cli/agent.conf @@ -2200,7 +2200,7 @@ "ports": [ { "conditionalEntropyRehash": false, - "description": "hello2", + "description": "demo", "drainState": 0, "expectedLLDPValues": { "2": "eth1/5/1" diff --git a/cli/cli_metadata.json b/cli/cli_metadata.json index 5435c54..68f340a 100644 --- a/cli/cli_metadata.json +++ b/cli/cli_metadata.json @@ -1,6 +1,6 @@ { "action": {}, "commands": [ - "config interface eth1/1/1 description hello2" + "config interface eth1/1/1 description demo" ] } \ No newline at end of file ``` Reviewed By: srikrishnagopu Differential Revision: D94975358 Pulled By: joseph5wu fbshipit-source-id: 197bc68feed6f5fe9443ad91d24999546ebbb0e7
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
Now every config command is saved in the CLI session metadata so we can
easily tell what commands were used in a given session. The metadata is
now also saved along the config when we commit the session. A future
commit will make rollback also rely on this metadata to decide whether
or not to restart the agent.
Note: this change is part of a series, the previous one is #805, the next one is #825.
Test Plan
New unit tests added.
Sample usage