Add _reload directive support for config reload framework.#13110
Open
brbzull0 wants to merge 3 commits intoapache:masterfrom
Open
Add _reload directive support for config reload framework.#13110brbzull0 wants to merge 3 commits intoapache:masterfrom
_reload directive support for config reload framework.#13110brbzull0 wants to merge 3 commits intoapache:masterfrom
Conversation
added 2 commits
April 21, 2026 14:02
Config handlers need a way to receive operational parameters (e.g. scoping a reload to a single entry) without conflating them with config content. This adds a reserved _reload key inside the configs YAML node that the framework extracts before invoking handlers. Framework: ConfigContext gains reload_directives() getter; the _reload node is extracted in ConfigRegistry::execute_reload() and stripped from supplied_yaml(). Fixes stale _passed_configs entries not being erased after consumption. CLI: traffic_ctl config reload gains --directive (-D) flag using dot-notation (config_key.directive_key=value). Multiple directives are space-separated after a single -D. Tests: unit tests for parse_directive and ConfigContext directive propagation; autest coverage for directive RPC structure handling. Docs: developer guide and traffic_ctl reference updated.
Contributor
Author
|
[approve ci autest 1] |
_reload directive support for config reload framework.
Contributor
Author
|
[approve ci autest 1] |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the ATS config reload framework to support operational “reload directives” passed via a reserved _reload YAML key, enabling handlers to receive parameters (e.g. scoping by id) separately from config content.
Changes:
- Add
ConfigContext::reload_directives()and propagate directives into dependent contexts. - Extract
_reloadfrom RPC-supplied YAML inConfigRegistry::execute_reload()and consume_passed_configsentries to prevent replay. - Add
traffic_ctl config reload --directive/-Dparsing and update docs/tests accordingly.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
src/mgmt/config/ConfigRegistry.cc |
Consumes passed RPC configs and extracts _reload before handing content to handlers. |
include/mgmt/config/ConfigContext.h |
Adds reload_directives() API and private setter. |
src/mgmt/config/ConfigContext.cc |
Propagates directives to child contexts; implements new accessor/setter. |
src/traffic_ctl/traffic_ctl.cc |
Adds --directive/-D option to config reload. |
src/traffic_ctl/CtrlCommands.cc |
Implements directive parsing and injects into YAML request. |
doc/developer-guide/config-reload-framework.en.rst |
Documents _reload extraction and handler usage. |
doc/appendices/command-line/traffic_ctl.en.rst |
Documents -D CLI wire format and usage. |
tests/gold_tests/jsonrpc/config_reload_rpc.test.py |
Adds JSONRPC gold tests ensuring _reload payloads are handled/rejected appropriately. |
src/records/unit_tests/test_ReloadDirectives.cc |
Adds unit tests for directive parsing and extraction semantics. |
src/records/CMakeLists.txt |
Registers the new unit test in the test target. |
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.
Add
_reloaddirective support to config reload frameworkTL;DR
Adds a generic way to pass operational parameters to config reload handlers.
Instead of per-config flags added to traffic_ctl, handlers now receive directives
via a reserved
_reloadkey that the framework extracts automatically.Handlers read directives with
ctx.reload_directives()["id"], whilectx.supplied_yaml()stays clean (content only, no directives). Also fixes a bugwhere stale RPC-supplied config data could replay on subsequent file-based reloads.
Summary
Config handlers sometimes need operational parameters that modify how a reload
is performed — for example, scoping a reload to a single entry by ID, or some other key to pass.
Currently there's no standard way to pass these parameters;
PR #13108 (virtualhost) works around this by adding a per-config
--virtualhostflagto
traffic_ctl.This PR adds a generic reload directive mechanism:
_reloadkey inside each config's YAML node carries directives_reloadbefore invoking the handlertraffic_ctlgains a--directive(-D) flag with dot-notation syntaxConfigContext::reload_directives()Motivation
The virtualhost PR (#13108) needs to tell the handler which virtualhost to reload
from file. Without a generic mechanism, every config that needs parameters would require
its own
traffic_ctlflag and custom parsing — leading to flag proliferation andduplicated code.
The
_reloaddirective solves this once for all handlers.Usage
traffic_ctlCLIWire format
-D virtualhost.id=myhostproduces:{ "configs": { "my_config": { "_reload": { "id": "myhost" } "param1":{} } } }Handler API
Key behavior:
reload_directives()returns the extracted_reloadYAML mapsupplied_yaml()is clean — never contains_reloadkeys_reloadis not a YAML map, a warning is logged and directives are ignoredChanges
Framework (
src/mgmt/config/)ConfigContext: Addedreload_directives()getter,set_reload_directives()setter, and propagation to child contexts via
add_dependent_ctx()ConfigRegistry::execute_reload(): Extracts_reloadfrom the config's YAMLnode before passing content to the handler. Also fixes a bug where
_passed_configsentries were not erased after consumption, causing stale RPC data to replay on
subsequent file-based reloads
CLI (
src/traffic_ctl/)traffic_ctl.cc: Added--directive(-D) option toconfig reloadCtrlCommands.cc: Addedparse_directive()helper that parsesconfig_key.directive_key=valueand injects intoconfigs[key]["_reload"][dir] = val