[Nexthop][fboss2-dev] Add fboss2-dev config hostname CLI#1343
[Nexthop][fboss2-dev] Add fboss2-dev config hostname CLI#1343vybhav-nexthop wants to merge 2 commits into
Conversation
Adds 'fboss2-dev config hostname <name>' command to set the switch hostname via the FBOSS agent thrift config session. Also refactors Fboss2IntegrationTest::getSwConfigField to delegate to a private getSwConfigFieldOpt<T> helper, and adds a two-argument overload getSwConfigField<T>(field, default) for optional config fields (used by ConfigHostnameTest to handle platforms where hostname is unset).
9fb36c7 to
1f79a62
Compare
joseph5wu
left a comment
There was a problem hiding this comment.
Consider to use CmdConfigSwitch to manage individual Switch Settings
| // hostname is an optional thrift field; on platforms (e.g. sim) where it is | ||
| // unset, it is omitted from the running config. Default to "" so SetUp's | ||
| // initial read does not throw before any hostname has been set. | ||
| return getSwConfigField<std::string>("hostname", ""); |
There was a problem hiding this comment.
Please consider to use switch_state to verify the config result:
https://github.com/facebook/fboss/blob/main/fboss/agent/switch_state.thrift#L478
fboss2_integration_test already has the following utility function:
https://github.com/facebook/fboss/blob/main/fboss/cli/fboss2/test/integration_test/Fboss2IntegrationTest.h#L131
There was a problem hiding this comment.
| std::string findIpv6OnIntf(int intfId) const; | ||
|
|
||
| private: | ||
| template <typename T> |
There was a problem hiding this comment.
Please use https://github.com/facebook/fboss/blob/main/fboss/cli/fboss2/test/integration_test/Fboss2IntegrationTest.h#L131 to verify rather than introducing the new getSwConfigFieldOpt() function
…state
- Introduce CmdConfigSwitch parent command (config switch)
- Move `config hostname <name>` → `config switch hostname <name>` as a
subcommand of CmdConfigSwitch, per reviewer's recommendation to use
CmdConfigSwitch for Switch Settings
- Integration test: verify hostname via getSwitchSettingsField/
verifySwitchSettingsField (switch_state) instead of getSwConfigField
(switch_config), as requested by reviewer
- Remove getSwConfigField{Opt}() helpers added to Fboss2IntegrationTest.h
— use the pre-existing getSwitchSettingsField instead
- Update BUCK to include CmdConfigSwitch.cpp / .h
vybhav-nexthop
left a comment
There was a problem hiding this comment.
Thanks for the review. Addressed all three points in the latest commit:
- CmdConfigSwitch: Introduced
CmdConfigSwitchas a new parent command and movedhostnameunder it asconfig switch hostname. - switch_state verification: Integration test now uses
getSwitchSettingsField/verifySwitchSettingsField(reading fromswitchSettingsMapin switch_state) instead of reading from switch_config. - Removed
getSwConfigFieldOpt: Dropped thegetSwConfigField{Opt}()helpers fromFboss2IntegrationTest.hentirely.
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runSummary
Adds
fboss2-dev config hostname <name>, which sets the optionalsw.hostnamefield in the agent switch config.ThriftConfigApplier::updateSwitchSettings(
newSwitchSettings->setHostname); no SAIChangeProhibitedguard.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."
Test Plan
CmdConfigHostnameTestFixture): argument validation (validsimple/FQDN, empty args, empty string, too-many args), set-new hostname,
already-set no-op.
ConfigHostnameTest) that sets, verifies,and restores the hostname. The integration test reads the initial
hostname with a
""default so setup tolerates platforms where theoptional hostname field is unset and therefore omitted from the running
config.
Unit tests (2026-06-15)
Full
cmd_config_testsuite (no regressions):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.