[Nexthop][fboss2-dev] Add fboss2-dev config hostname CLI#1343
Closed
vybhav-nexthop wants to merge 1 commit into
Closed
[Nexthop][fboss2-dev] Add fboss2-dev config hostname CLI#1343vybhav-nexthop wants to merge 1 commit into
vybhav-nexthop wants to merge 1 commit into
Conversation
9fb36c7 to
1f79a62
Compare
joseph5wu
requested changes
Jun 30, 2026
joseph5wu
left a comment
Contributor
There was a problem hiding this comment.
Consider to use CmdConfigSwitch to manage individual Switch Settings
7e359f0 to
2e00edd
Compare
Adds:
fboss2-dev config switch hostname <name>
Sets SwitchConfig::hostname in the agent running config via a HITLESS
config session (applied by ThriftConfigApplier::updateSwitchSettings, no
agent restart required). Input validated as RFC 952/1123 compliant.
Nested under the existing `config switch` command group (introduced by the
admin-distance command) rather than at the top level, grouping
switch-level settings that do not belong to a specific network object.
Files:
- commands/config/switch/hostname/CmdConfigHostname.{h,cpp} new handler
- test/config/CmdConfigHostnameTest.cpp unit tests
- test/integration_test/ConfigHostnameTest.cpp integration test
- CmdListConfig.cpp: register hostname as a subcommand of config switch
- CmdConfigSwitch.cpp: list hostname in the subcommand help string
- BUCK / cmake wiring
Signed-off-by: Vybhav <vybhav@nexthop.ai>
2e00edd to
d8c99af
Compare
Contributor
|
@joseph5wu has imported this pull request. If you are a Meta employee, you can view this in D110790091. |
Contributor
|
@joseph5wu merged this pull request in 3aed671. |
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
Adds
fboss2-dev config switch hostname <name>, which sets the optionalsw.hostnamefield in the agent switch config.The command is nested under the
config switchcommand group (introduced bythe admin-distance command) rather than at the top level, grouping
switch-level settings that do not belong to a specific network object.
ThriftConfigApplier::updateSwitchSettings(newSwitchSettings->setHostname);no SAI
ChangeProhibitedguard.hostnameis already set to the requested value, thecommand is a no-op.
using RE2 (alphanumeric plus hyphens, max 63 chars per label, total max
253 chars).
switch_config.thrift:SwitchConfig.hostname(optional string) —"Overrides the system hostname, useful in ICMP responses." When unset, the
agent falls back to the OS hostname at config-apply time
(
getLocalHostname()), so the value is always populated in switch state.Test Plan
Unit tests (
CmdConfigHostname{,Absent}TestFixture)9 tests, all passing in CI: argument validation (valid, FQDN, empty args,
empty string, too-many args, invalid format), set-new hostname, already-set
no-op, and set-when-field-absent.
Integration test (
ConfigHostnameTest) — on DUT gold407The integration test reads the current hostname from switch state
(
getSwitchSettingsField, always populated) inside a try/catch that returns""if absent, sets a test value, verifies it via the switch-state thriftpath, and restores the original hostname in
TearDown. It does not read theoptional config field directly, so it does not need any
getSwConfigFielddefault-value helper —
Fboss2IntegrationTest.his unchanged from upstream.Results from the internal CLI Integration Test (DUT) run on 2026-07-03
(device gold407):
Ran as part of the 25-test fboss2 CLI integration suite; all 25 passed
(total 50.5 s).
Review Findings
Pre-publication review (single-pass automated reviewer). One item raised —
unchecked
*config.sw()dereference inCmdConfigHostname.cpp— reviewedand dismissed: it is the established pattern across all
fboss2 configcommands (e.g.
CmdConfigArp.cpp,CmdConfigCopp.cpp);swis reliablypresent for a loaded agent config. No issues above threshold.
Presubmission Checks
--style=file --dry-run --Werror): pass on all added/modified C++ sources.