Skip to content

feat(gateway): merge drop-in config fragments over the base file - #5489

Open
elezar wants to merge 2 commits into
mainfrom
feat/5446-gateway-config-dropins/elezar
Open

elezar wants to merge 2 commits into
mainfrom
feat/5446-gateway-config-dropins/elezar

Conversation

@elezar

@elezar elezar commented Nov 11, 2026

Copy link
Copy Markdown
Member

Summary

The gateway now merges *.toml fragments from a drop-in directory over its base config file, so operators and test harnesses can customize a package-seeded gateway.toml without editing it. Test environments use the same mechanism instead of a merge script.

Related Issue

Closes #5446

Changes

  • Add load_layered in config_file.rs: load the base file and the fragments, merge them in lexical order, and validate the merged result once. Tables merge key by key; scalars and arrays replace. A fragment can omit [openshell] version; the merged result must declare it.
  • Attribute a validation error to the first fragment that causes it, and keep parse errors free of file contents.
  • Add --config-dir / OPENSHELL_GATEWAY_CONFIG_DIR. Without them, the gateway uses gateway.d/ next to the base file when it exists. An explicit directory must exist. --config and --config-dir compose rather than exclude each other, as in CRI-O and kubelet.
  • Make config preflight load the same merged result, list the files it merged, and fail on the same errors as startup. A legacy schema version still reports its version, not an unknown-field error.
  • Document the directory, order and merge rules in configuration.mdx, the RPM guide and the man page.
  • Install tmachine test overrides as gateway.d/90-test-overrides.toml and remove merge-gateway-toml.py and its tests.

Not covered: the Helm ConfigMap and Secret mapping from the issue's open questions, and the config preflight usage line in the man page, which does not yet list --config-dir. The e2e additional-CA overrides still edit the base file, because e2e/rust/tests/additional_ca.rs rewrites it in place.

Release Notes

Gateway configuration can be split across a base gateway.toml and *.toml fragments in gateway.d/. Later fragments override earlier ones, and config preflight reports the merged result.

Testing

  • Checks appropriate to the affected code and behavior pass: cargo clippy -p openshell-server --all-targets is clean and the openshell-server lib tests pass (2686 tests); the pre-commit lint hook passed.
  • Unit tests added/updated: fragment override, ordering, array replace, error attribution, redaction, secrets, version handling, and layered preflight.
  • E2E tests added/updated (if applicable): the tmachine Ansible changes were not run, only parsed as YAML.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

Load `*.toml` fragments from a drop-in directory and merge them over the
base gateway config in lexical order. Tables merge key by key; scalars and
arrays replace. The merged result is validated once, and errors name the
first fragment that causes them.

The directory is selected with `--config-dir` or
`OPENSHELL_GATEWAY_CONFIG_DIR`, and defaults to `gateway.d` next to the base
file when it exists. `config preflight` loads the same merged result and
lists the files it merged.

Refs #5446

Signed-off-by: Evan Lezar <elezar@nvidia.com>
Install /etc/openshell-test/gateway-overrides.toml as
gateway.d/90-test-overrides.toml next to the gateway's base file instead of
rewriting the base file with merge-gateway-toml.py. The gateway merges the
fragment, so the package's gateway.toml stays untouched and the merge script
and its tests are removed.

A package with no default configuration still gets a minimal version = 2 base
file, since a fragment does not declare a version.

Refs #5446

Signed-off-by: Evan Lezar <elezar@nvidia.com>
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

New or updated breaking changes; see the full report for all findings.

1. cli — No explicit risk acceptance found

For openshell-gateway config preflight --path FILE containing [openshell] version = &#x27;two&#x27;, detected_version=unavailable becomes detected_version=2, even without fragments.

  • Impact: Automation matching the stable category=malformed detected_version=unavailable response no longer recognizes malformed schema declarations.
  • Action: Preserve existing preflight detected_version semantics on this no-break train by deriving diagnostics from the actual merged version value rather than assuming schema v2.
  • PR: feat(gateway): merge drop-in config fragments over the base file #5489
Review details
  • Execution: complete
  • Candidate: PR #5489 (31ffaa182e4e3e9658590e33a9893ea83ee8123b)
  • Baseline: 1580589082f693306abd5b63a2d9fc945b0e9caa (1580589082f693306abd5b63a2d9fc945b0e9caa)
  • Reviewed: rust-sdk, python-sdk, typescript-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

This branch has not been deployed

No deployments
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.

feat(gateway): support drop-in configuration fragments (gateway.d/*.toml)

1 participant