Skip to content

Comments

[Nexthop] Create FBOSS command wrappers in PATH #950

Open
travisb-nexthop wants to merge 13 commits intofacebook:mainfrom
nexthop-ai:distro_cmds_in_path
Open

[Nexthop] Create FBOSS command wrappers in PATH #950
travisb-nexthop wants to merge 13 commits intofacebook:mainfrom
nexthop-ai:distro_cmds_in_path

Conversation

@travisb-nexthop
Copy link
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

There exist a handful of FBOSS commands which we would like to have in
$PATH, for example fboss2.

We can't simply put /opt/fboss/bin into $PATH for two reasons:

  1. /opt/fboss/bin also contains the daemon binaries which we won't want cluttering up tab completion or being executed by accident
  2. When the Platform Stack or Forwarding Stack components are updated without rebuilding the entire image, they will not be installed into /opt/fboss, but instead somewhere else. It's too difficult to update the $PATH of all existing shells when this happens.

Instead we introduce wrappers in /usr/local/bin for each of these commands which will later find the latest installation of the matching component and executes that copy of the command. For now they only execute from the default install path /opt/fboss/bin.

Test Plan

Manual testing:

[root@fboss103 ~]# which fboss2-dev
/usr/local/bin/fboss2-dev
[root@fboss103 ~]# fboss2-dev --help
FBOSS CLI
Usage: /opt/fboss/bin/fboss2-dev [OPTIONS] SUBCOMMAND

Options:
  -h,--help                   Print this help message and exit
  -H,--host TEXT ...          Hostname(s) to query
  -l,--loglevel TEXT          Debug log level
  --file TEXT:FILE            filename, queries every host in the file
  --fmt TEXT:{tabular,json}   Output format (tabular, json)
  --agent-port INT:POSITIVE   Agent thrift port to connect to
  --qsfp-port INT:POSITIVE    QsfpService thrift port to connect to
  --color TEXT                color (no, yes => yes for tty and no for pipe)
  --filter TEXT               filter expression. expression must be of the form TERM1&&TERM2||TERM3||TERM4... where each TERMi is of the form <key op value> See specific commands for list of available filters. Please note the specific whitespace requirements for the command
  --aggregate TEXT            Aggregation operation. Must be of the form OPERATOR(column)
  --aggregate-hosts BOOLEAN   whether to perform aggregation across all hosts or not

Subcommands:
  bounce                      Disable/Enable object
  clear                       Clear object info
  config                      Configuration commands
  create                      Create object
  debug                       Debug object
  delete                      Delete object
  get                         Get object
  reload                      Reload object
  set                         Set object
  show                        Show object info
  start                       Start event
  stop                        Stop event
  stream                      Continuously stream

raghav-nexthop and others added 13 commits February 5, 2026 01:12
This commit updates the FBOSS-OSS Kernel files to remove Nexthop-specific
references that were inadvertently included in the initial merge:

- Remove sccache distributed build references from build_kernel.sh
- Remove nhfboss-common.sh sourcing
- Update kernel.spec copyright header to Meta/Facebook format
- Fix import ordering in Python scripts to match upstream style
- Simplify kernel build process to use standard gcc without sccache wrapper

These changes ensure the kernel build system is clean and suitable for
upstream FBOSS without Nexthop-specific dependencies.
Integrate distro_cli Python unit tests into the FBOSS CMake build system to enable automated testing in CI/CD pipelines.

- Add FbossImageDistroCliTests.cmake to discover and register Python unit tests
- Configure test discovery for distro_cli modules (builder, cmds, lib, tools)
- Update root CMakeLists.txt to include distro_cli test suite
- Enable distro_cli tests in GitHub Actions workflow
- Update distro_cli README with build and test instructions

The CMake configuration automatically discovers all *_test.py files and registers them as CTest targets, allowing tests to run via 'ctest' or 'make test'.
Provide basic tools and utiulities for the distro_cli build system.

- Add custom exception classes for structured error handling
- Define shared constants for Docker configuration and build settings
- Implement path resolution utilities for components
- Define test data fixture for image manifest validation

These core utilities provide the base infrastructure required by all downstream components including Docker integration, artifact handling, and build orchestration.
Add Docker container and image management capabilities.

- Implement Docker container wrapper with exec and run operations
- Implement Docker image wrapper with build, pull, and tag operations
- Add comprehensive unit tests for container and image functionality
- Include test helper utilities for unit test infrastructure
- Add build_docker.sh script for Docker build automation

Added unit tests for docker infrastructure and image building.
Add artifact storage and caching capabilities for build outputs.

- Implement artifact store for managing build artifacts
- Add artifact caching and retrieval functionality
- Include unit tests for artifact operations
- Update test helpers to support artifact testing

Added unit tests for artifact storage and caching.
Add file download capabilities for fetching build dependencies.

- Implement download module for HTTP/HTTPS file retrieval
- Add support for progress tracking during downloads
- Include comprehensive unit tests for download operations
Add command execution capabilities for running build operations.

- Implement execute module for running commands in Docker containers
- Add support for command execution with output capture
- Enable build operations to run in isolated container environments
Add abstract build component framework for managing build operations.

- Implement AbstractComponent base class for build components
- Add component lifecycle management (prepare, build, extract)
- Integrate with artifact store, download, and execute modules
- Enable extensible component-based build architecture

Tests utilizing the above infrastructure will be added when component build supports are included.
Add build entrypoint orchestration for component-based builds.

- Implement build entrypoint for coordinating component build workflows
- Add support for build configuration and execution management
- Include comprehensive unit tests for entrypoint functionality
Add ImageBuilder class for orchestrating component builds and image assembly.

- ImageBuilder: Main orchestration class for building FBOSS images
- Compression support for build artifacts (zstd)
- Component build coordination
- Test coverage for compression functionality
- Updated build_test.py to use ImageBuilder
Add scripts and build configuration for building FBOSS forwarding and platform stacks.

- CMakeLists.txt:  Defines build targets for forwarding stack
- package.py:   Script for packaging forwarding and platform stacks
- build_fboss_stack.sh:   Script for building forwarding and platform stacks
There exist a handful of FBOSS commands which we would like to have in
$PATH, for example fboss2.

We can't simply put /opt/fboss/bin into $PATH for two reasons:

1. /opt/fboss/bin also contains the daemon binaries which we won't want
   cluttering up tab completion or being executed by accident
2. When the Platform Stack or Forwarding Stack components are updated
   without rebuilding the entire image, they will not be installed
   into /opt/fboss, but instead somewhere else. It's too difficult to
   update the $PATH of all existing shells when this happens.

Instead we introduce wrappers in /usr/local/bin for each of these
commands which will later find the latest installation of the matching
component and executes that copy of the command. For now they only
execute from the default install path /opt/fboss/bin.

Manual testing:
```
[root@fboss103 ~]# which fboss2-dev
/usr/local/bin/fboss2-dev
[root@fboss103 ~]# fboss2-dev --help
FBOSS CLI
Usage: /opt/fboss/bin/fboss2-dev [OPTIONS] SUBCOMMAND

Options:
  -h,--help                   Print this help message and exit
  -H,--host TEXT ...          Hostname(s) to query
  -l,--loglevel TEXT          Debug log level
  --file TEXT:FILE            filename, queries every host in the file
  --fmt TEXT:{tabular,json}   Output format (tabular, json)
  --agent-port INT:POSITIVE   Agent thrift port to connect to
  --qsfp-port INT:POSITIVE    QsfpService thrift port to connect to
  --color TEXT                color (no, yes => yes for tty and no for pipe)
  --filter TEXT               filter expression. expression must be of the form TERM1&&TERM2||TERM3||TERM4... where each TERMi is of the form <key op value> See specific commands for list of available filters. Please note the specific whitespace requirements for the command
  --aggregate TEXT            Aggregation operation. Must be of the form OPERATOR(column)
  --aggregate-hosts BOOLEAN   whether to perform aggregation across all hosts or not

Subcommands:
  bounce                      Disable/Enable object
  clear                       Clear object info
  config                      Configuration commands
  create                      Create object
  debug                       Debug object
  delete                      Delete object
  get                         Get object
  reload                      Reload object
  set                         Set object
  show                        Show object info
  start                       Start event
  stop                        Stop event
  stream                      Continuously stream
```
@travisb-nexthop
Copy link
Contributor Author

This comes after #903

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