Skip to content

Commit 4fab887

Browse files
committed
test(tmachine): apply gateway overrides as a drop-in config
Install an environment's gateway overrides as `gateway.d/90-test-overrides.toml` next to the gateway's own config instead of merging them into it with a script. A package with no default config runs on the drop-in config alone. The override files declare `[openshell] version = 2`. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 4b7ba0c commit 4fab887

8 files changed

Lines changed: 65 additions & 313 deletions

File tree

‎TESTING.md‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -593,27 +593,25 @@ nix run .#openshell-test-runner -- run \
593593

594594
An environment overrides gateway settings by writing the tables to change to
595595
`/etc/openshell-test/gateway-overrides.toml` in a playbook that runs before the
596-
installer. The file holds whole tables, such as `[openshell.gateway]` or
597-
`[openshell.drivers.podman]`, and is not a complete configuration. Each
598-
installer applies it to the gateway's own file:
599-
600-
- `binaries` applies it to the `/etc/openshell/gateway.toml` it generates.
601-
- `deb` and `rpm` apply it to the service user's
596+
installer. The file declares `[openshell] version = 2` and the tables to change, such as
597+
`[openshell.gateway]` or `[openshell.drivers.podman]`. Each
598+
installer installs it as the drop-in config `gateway.d/90-test-overrides.toml`
599+
next to the gateway's own `gateway.toml`, and the gateway merges it over that
600+
file. The base file is never edited:
601+
602+
- `binaries` installs it beside the `/etc/openshell/gateway.toml` it generates.
603+
- `deb` and `rpm` install it beside the service user's
602604
`~/.config/openshell/gateway.toml`, the file the packaged service reads. The
603-
file starts as a copy of the rpm's
604-
`/usr/share/openshell-gateway/gateway.toml.default`, where the service would
605-
seed it on first start, or as a minimal `version = 2` file when the package
606-
has no default. No environment replaces the packaged file, and an environment
607-
with no overrides leaves it untouched.
605+
rpm still seeds that file from
606+
`/usr/share/openshell-gateway/gateway.toml.default` on first start. A package
607+
with no default runs on the drop-in config alone. An environment with no
608+
overrides leaves the packaged configuration untouched.
608609
- `k3s` installers ignore the file.
609610

610-
`tests/tmachine/ansible/roles/openshell_gateway/files/merge-gateway-toml.py`
611-
does the work. Each key in the overrides replaces the same key in the table, or
612-
is added to it, and a table the file lacks is appended. The rest of the file,
613-
comments included, stays. The script parses the result and fails the setup,
614-
leaving the file unchanged, when it isn't valid TOML. It can't remove a key.
615-
Settings that the packaged service reads from `gateway.env` instead of the
616-
TOML are not covered.
611+
A key in the drop-in config replaces the same key in the base file's table, or is
612+
added to it, and a table the base lacks is added. Arrays replace the base
613+
array. A drop-in config can't remove a key. Settings that the packaged service reads
614+
from `gateway.env` instead of the TOML are not covered.
617615

618616
The `oci-image` feature suite (`tests/suites/features/oci-image`) checks OCI
619617
image identity and working-directory behavior shared by the Docker and Podman

‎tasks/test.toml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,9 @@ depends = [
2626
"test:maintainer-approval",
2727
"test:cargo-lockfile-alignment",
2828
"test:review-readiness",
29-
"test:merge-gateway-toml",
3029
"test:accepted-work",
3130
]
3231

33-
["test:merge-gateway-toml"]
34-
description = "Test the tmachine gateway TOML merge script"
35-
run = "uv run --no-project --with pytest pytest tests/tmachine/ansible/roles/openshell_gateway/files/merge_gateway_toml_test.py"
36-
3732
["test:cargo-lockfile-alignment"]
3833
description = "Test the Cargo lockfile alignment check"
3934
run = "uv run --no-project --with pytest pytest tasks/scripts/check_cargo_lockfile_alignment_test.py"

‎tests/tmachine/ansible/playbooks/drivers/podman/userns.yaml‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
#
66
# `podman_userns_mode` is default, auto, keep-id or private. Every mode except
77
# default writes its `[openshell.drivers.podman]` settings to
8-
# `/etc/openshell-test/gateway-overrides.toml`, which every installer applies to the active
9-
# gateway-overrides.toml (the openshell_gateway role for `binaries`, the
10-
# openshell_packaged_gateway role for the packages); default removes the file. The
8+
# `/etc/openshell-test/gateway-overrides.toml`, which every installer installs as a
9+
# `gateway.d` drop-in next to the active gateway.toml (the openshell_gateway role
10+
# for `binaries`, the openshell_packaged_gateway role for the packages); default
11+
# removes the file. The
1112
# Podman support crate (tests/support/podman) reads the published mode and
1213
# runs Podman's own reference container in it.
1314
---
@@ -19,12 +20,18 @@
1920
podman_userns_settings:
2021
default: ""
2122
auto: |
23+
[openshell]
24+
version = 2
2225
[openshell.drivers.podman]
2326
userns = "auto"
2427
keep-id: |
28+
[openshell]
29+
version = 2
2530
[openshell.drivers.podman]
2631
userns = "keep-id"
2732
private: |
33+
[openshell]
34+
version = 2
2835
[openshell.drivers.podman]
2936
userns = "private"
3037
uidmap = ["0:0:1", "1:1:65535"]
@@ -62,7 +69,7 @@
6269
mode: "0644"
6370
when: podman_userns_mode != "default"
6471

65-
# The fragment is the only source of userns, uidmap and gidmap settings in
72+
# The drop-in config is the only source of userns, uidmap and gidmap settings in
6673
# the gateway's configuration, so default mode leaves them unset.
6774
- name: Remove Podman driver user-namespace settings for default mode
6875
become: true

‎tests/tmachine/ansible/roles/cdi_fixtures/tasks/main.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
ansible.builtin.copy:
5656
dest: /etc/openshell-test/gateway-overrides.toml
5757
content: |
58+
[openshell]
59+
version = 2
5860
[openshell.drivers.{{ environment_driver }}]
5961
allow_driver_config = true
6062
owner: root

‎tests/tmachine/ansible/roles/openshell_gateway/files/merge-gateway-toml.py‎

Lines changed: 0 additions & 165 deletions
This file was deleted.

‎tests/tmachine/ansible/roles/openshell_gateway/files/merge_gateway_toml_test.py‎

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)