Skip to content

[Nexthop][fboss2-dev] Add a command to clear config sessions#935

Closed
benoit-nexthop wants to merge 1 commit intofacebook:mainfrom
nexthop-ai:fboss2-cli-prototype_part30
Closed

[Nexthop][fboss2-dev] Add a command to clear config sessions#935
benoit-nexthop wants to merge 1 commit intofacebook:mainfrom
nexthop-ai:fboss2-cli-prototype_part30

Conversation

@benoit-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

Implements a new CLI command fboss2-dev config session clear that removes the current config session files (~/.fboss2/agent.conf and ~/.fboss2/cli_metadata.json).

This command allows users to discard any pending config session changes without committing them, providing a clean way to abandon a session and start fresh.

Original change by @hillol-nexthop

Note: this change is part of a series, the previous one is #931.

Changes

  • Added CmdConfigSessionClear.h and CmdConfigSessionClear.cpp implementing the clear command
  • Registered the command in CmdListConfig.cpp under config session subcommands
  • Added unit tests in CmdConfigSessionTest.cpp covering:
  • Clearing an existing session removes both files
  • Clearing when no session exists (no-op)
  • Clearing with partial session state (only config file exists)
  • Added e2e test in ConfigSessionClearTest.cpp that creates a session and clears it
  • Added unit test in CmdConfigSessionClearTest.cpp

Test Plan

New E2E and unit tests.

Sample usage

[admin@fboss101 .fboss2]$ fboss2-dev config session clear
Config session cleared successfully.
[admin@fboss101 .fboss2]$ fboss2-dev config session clear
No config session exists. Nothing to clear.

@meta-cla meta-cla Bot added the CLA Signed label Feb 13, 2026
@hillol-nexthop hillol-nexthop force-pushed the fboss2-cli-prototype_part30 branch from 98a743b to 17ab4f8 Compare February 16, 2026 03:47
meta-codesync Bot pushed a commit that referenced this pull request Mar 27, 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`

Move explicit template instantiations from the monolithic `CmdHandlerImplConfig.cpp` file to individual command `.cpp` files. This is the first step in refactoring the CLI command registration system to avoid creating a monolithic include file.

The non-config commands will be done in a separate PR.

Changes:
- Created 11 new `.cpp` files for stub commands that were missing them
- Added template instantiations to 20 existing command `.cpp` files
- Updated `cmake/CliFboss2.cmake` and `fboss/cli/fboss2/BUCK` build files
- Deleted `fboss/cli/fboss2/CmdHandlerImplConfig.cpp`

Each command `.cpp` file now includes `CmdHandler.cpp` and has its own explicit template instantiation, following the pattern:
```c++
#include "fboss/cli/fboss2/CmdHandler.cpp"

template void CmdHandler<CmdClass, CmdClassTraits>::run();
```

Original change by manoharan-nexthop

Note: this change is part of a series, the previous one is #919, the next one is #935.

Pull Request resolved: #931

Test Plan: Ran all the unit tests.

Reviewed By: KevinYakar

Differential Revision: D98510944

Pulled By: joseph5wu

fbshipit-source-id: 18f33d1014eb81a81b264c65adb4bd5b78e824c4
# Summary

Implements a new CLI command fboss2-dev config session clear that
removes the current config session files (~/.fboss2/agent.conf and
~/.fboss2/cli_metadata.json).

This command allows users to discard any pending config session changes
without committing them, providing a clean way to abandon a session and
start fresh.

## Changes

- Added CmdConfigSessionClear.h and CmdConfigSessionClear.cpp
implementing the clear command
- Registered the command in CmdListConfig.cpp under config session
subcommands
- Added unit tests in CmdConfigSessionTest.cpp covering:
- Clearing an existing session removes both files
- Clearing when no session exists (no-op)
- Clearing with partial session state (only config file exists)
- Added e2e test in ConfigSessionClearTest.cpp that creates a session
and clears it

# Test Plan

New E2E and unit tests.

## Sample usage

```
[admin@fboss101 .fboss2]$ fboss2-dev config session clear
Config session cleared successfully.
[admin@fboss101 .fboss2]$ fboss2-dev config session clear
No config session exists. Nothing to clear.
```
@benoit-nexthop benoit-nexthop force-pushed the fboss2-cli-prototype_part30 branch from 17ab4f8 to d054221 Compare March 27, 2026 21:49
@benoit-nexthop benoit-nexthop requested review from a team as code owners March 27, 2026 21:49
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Mar 27, 2026

@joseph5wu has imported this pull request. If you are a Meta employee, you can view this in D98555036.

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Mar 28, 2026

@joseph5wu merged this pull request in d163773.

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.

2 participants