Skip to content

docs(config): document frontend rule order and reload limits - #1681

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
docs/frontend-rule-order
Sep 29, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
docs/frontend-rule-order

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Documents how rules are ordered within a frontend position, answering #952, and states two limits of the current reload/worker behaviour. Docs only, no behaviour change.

  • doc/configure.md: new "Rule order within PRE and POST" section after "Catch-all hostname", plus a cross-reference from "When declaration order decides".
  • bin/config.toml: short summary under the position option.
  • CHANGELOG.md: docs entry under Unreleased / Changed.

Evidence (origin/main ebf4b70)

  • PRE < TREE < POST, first match wins inside PRE/POST. Router holds pre: Vec, tree, post: Vec (lib/src/router/mod.rs:85-89); Router::lookup scans pre and returns the first match (lib/src/router/mod.rs:141-154), then the trie (:156-196), then post (:198-211). add_pre_rule / add_post_rule push a new rule and refuse a duplicate (domain, path, method) (lib/src/router/mod.rs:622-705), dispatched from RulePosition at lib/src/router/mod.rs:317-322.
  • TREE follows specificity. Exact name, then regex segments in declaration order, then * (lib/src/router/mod.rs:157-159); path selection in select_tree_rule (lib/src/router/mod.rs:845), whose declaration-order cases are already in "When declaration order decides".
  • Reload does not re-apply existing frontends. ReloadConfiguration calls load_static_config (bin/src/command/requests.rs:389-391, :935), which re-dispatches every generated request with no removal step; ConfigState::diff (command/src/state.rs:2076) is not on this path. add_frontend_to (command/src/state.rs:1141) returns StateError::Exists for an existing key, and the entry is skipped before scatter_on (bin/src/command/requests.rs:1048). The key is address;hostname;{P|R|=}path[;method] (command/src/request.rs:263) and carries neither position nor cluster_id.
  • New workers receive frontends sorted by key. http_fronts / https_fronts are BTreeMap<String, HttpFrontend> (command/src/state.rs:169, :171); generate_requests iterates them in key order (command/src/state.rs:1919, :1936) and feeds produce_initial_state (command/src/state.rs:2971), written to the forked worker by fork_main_into_worker (bin/src/worker.rs:272, :291), called from bin/src/command/server.rs:1309.

The reload and worker-replay behaviour described here is documented as it is today, not endorsed; #952 stays open for the reload fix.

Validation

  • python3 .github/scripts/check_doc_citations.py --self-test -> exit 0
  • python3 .github/scripts/check_doc_citations.py --root . -> exit 0 (OK: all 48 ... citations ... resolve to a non-blank line.)
  • python3 .github/scripts/check_doc_citations.py --base origin/main -> exit 0
  • python3 .github/scripts/check_doc_citations.py --audit --root . -> exit 0, no finding on the changed files

Refs #952

Document how rules are ordered within a frontend position: PRE rules,
then the routing trie, then POST rules; inside PRE or POST the first
matching rule wins in the order the worker received the rules, while
the trie follows hostname and path specificity.

Also document two limits of the current behaviour: a configuration
reload refuses every frontend whose address, hostname, path and method
already exist, so reordering the file or changing only the position or
cluster of an existing frontend has no effect, and a frontend deleted
from the file is not removed; a new or upgraded worker receives the
frontends sorted by that key rather than in insertion order.

No behaviour change.

Refs #952

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit e55c8bd into main Sep 29, 2026
28 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the docs/frontend-rule-order branch September 29, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant