Skip to content

Commit f3d9765

Browse files
authored
fix(tmachine): restore package-installed Podman qualification (#4289)
* test(tmachine): apply environment gateway overrides to the packaged gateway An environment overrides gateway settings by writing the tables to change to /etc/openshell-test/gateway-overrides.toml. Every installer applies the file with merge-gateway-toml.py: the binaries installer to the configuration it generates, and the deb and rpm installers to the service user's gateway.toml, which starts from the package's default configuration instead of replacing it. Each key replaces the same key in the base file or is added to its table, comments are kept, and a result that is not valid TOML fails the setup. Run the Podman user-namespace driver suites with the rpm installer. Signed-off-by: Evan Lezar <elezar@nvidia.com> * test(tmachine): run e2e-podman against the packaged gateway Detect the installer in the e2e-podman playbook: the binaries installer keeps its HTTP gateway, and the package installers use /usr/bin/openshell and the registered openshell gateway. Run the lane on rpm in CI. Signed-off-by: Evan Lezar <elezar@nvidia.com> * fix(tmachine): harden the gateway TOML merge against unhandled statements Treat array-of-tables headers as table boundaries so replacing a value before one no longer consumes its header. Require the overrides to be valid TOML, accept single- and double-quoted keys, and fail when any override value is missing from the merged result instead of silently dropping it. Add regression tests and a mise task for them. Signed-off-by: Evan Lezar <elezar@nvidia.com> --------- Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 7873aaa commit f3d9765

17 files changed

Lines changed: 405 additions & 67 deletions

File tree

‎.github/workflows/branch-e2e.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@ jobs:
462462
secrets:
463463
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
464464

465-
# Run the Podman e2e suite on tmachine. It needs the binary installer's CLI
466-
# path and local HTTP gateway.
465+
# Run the Podman e2e suite on tmachine against the packaged gateway.
467466
podman-e2e-integration:
468467
needs: prepare-integration
469468
permissions:
@@ -477,7 +476,7 @@ jobs:
477476
integration-inputs-artifact-id: ${{ needs.prepare-integration.outputs.integration_inputs_artifact_id }}
478477
test-matrix: >-
479478
[
480-
{"environment":"fedora-podman-rootless","installer":"binaries","testsuite":"e2e-podman"}
479+
{"environment":"fedora-podman-rootless","installer":"rpm","testsuite":"e2e-podman"}
481480
]
482481
483482
docker-e2e:

‎.github/workflows/e2e-suites.yml‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ jobs:
9191
{"environment":"ubuntu-k3s","installer":"k3s-ha","family":"features","package":"host-gateway","gateway":"tmachine","runner":"ubuntu-24.04"},
9292
{"environment":"fedora-podman-rootful-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"},
9393
{"environment":"fedora-podman-rootless-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"},
94-
{"environment":"fedora-podman-rootful-userns-default","installer":"binaries","family":"drivers/podman","gateway":"tmachine","runner":"ubuntu-24.04"},
95-
{"environment":"fedora-podman-rootful-userns-auto","installer":"binaries","family":"drivers/podman","gateway":"tmachine","runner":"ubuntu-24.04"},
96-
{"environment":"fedora-podman-rootful-userns-keep-id","installer":"binaries","family":"drivers/podman","gateway":"tmachine","runner":"ubuntu-24.04"},
97-
{"environment":"fedora-podman-rootful-userns-private","installer":"binaries","family":"drivers/podman","gateway":"tmachine","runner":"ubuntu-24.04"},
98-
{"environment":"fedora-podman-rootless-userns-default","installer":"binaries","family":"drivers/podman","gateway":"tmachine","runner":"ubuntu-24.04"},
99-
{"environment":"fedora-podman-rootless-userns-auto","installer":"binaries","family":"drivers/podman","gateway":"tmachine","runner":"ubuntu-24.04"},
100-
{"environment":"fedora-podman-rootless-userns-keep-id","installer":"binaries","family":"drivers/podman","gateway":"tmachine","runner":"ubuntu-24.04"},
101-
{"environment":"fedora-podman-rootless-userns-private","installer":"binaries","family":"drivers/podman","gateway":"tmachine","runner":"ubuntu-24.04"}
94+
{"environment":"fedora-podman-rootful-userns-default","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"},
95+
{"environment":"fedora-podman-rootful-userns-auto","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"},
96+
{"environment":"fedora-podman-rootful-userns-keep-id","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"},
97+
{"environment":"fedora-podman-rootful-userns-private","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"},
98+
{"environment":"fedora-podman-rootless-userns-default","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"},
99+
{"environment":"fedora-podman-rootless-userns-auto","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"},
100+
{"environment":"fedora-podman-rootless-userns-keep-id","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"},
101+
{"environment":"fedora-podman-rootless-userns-private","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}
102102
]'
103103
# `suite` names the row's tests in the job and artifact names.
104104
matrix=$(jq -c --arg family "${FAMILY}" '{include: map(

‎.github/workflows/integration-runner.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ on:
2424
type: string
2525
default: >-
2626
[
27-
{"environment":"fedora-podman-rootless","installer":"binaries","testsuite":"e2e-podman"}
27+
{"environment":"fedora-podman-rootless","installer":"rpm","testsuite":"e2e-podman"}
2828
]
2929
3030
permissions:

‎.github/workflows/integration-test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
type: string
2828
default: >-
2929
[
30-
{"environment":"fedora-podman-rootless","installer":"binaries","testsuite":"e2e-podman"}
30+
{"environment":"fedora-podman-rootless","installer":"rpm","testsuite":"e2e-podman"}
3131
]
3232
3333
permissions:

‎CI.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,11 @@ selected. DEB and RPM packages build only when integration qualification is sele
166166
the DEB on Ubuntu with Docker and installs the CLI and gateway RPMs on Fedora with
167167
rootful and rootless Podman. These lanes run conformance using the matching runtime
168168
images. Release Dev, Release, and Pre-release use the same package installers.
169-
The feature suites (`tests/suites/features`) run the same way, on the
170-
package installers. The Podman driver suite (`tests/suites/drivers/podman`) and the
171-
`e2e-podman` lane retain the binary installer because they configure its system
172-
service, local HTTP gateway, and CLI path. The driver suite and `e2e-podman` run
169+
The feature suites (`tests/suites/features`) and the Podman driver suite
170+
(`tests/suites/drivers/podman`) run the same way, on the package installers; the
171+
driver suite's environments merge their Podman settings into the packaged
172+
gateway's configuration (see `TESTING.md`). The `e2e-podman` lane runs on the
173+
RPM installer as well. The driver suite and `e2e-podman` run
173174
only in `Branch E2E Checks`. The manual Integration Tests workflow runs the
174175
remaining tmachine testsuites, such as `e2e-podman`, and downloads the packages
175176
selected by its matrix.

‎TESTING.md‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ Run the portable subset in a disposable rootless Podman guest:
541541

542542
```shell
543543
nix run .#build-artifacts
544-
nix run .#tmachine -- test fedora-podman-rootless binaries e2e-podman
544+
nix run .#tmachine -- test fedora-podman-rootless rpm e2e-podman
545545
```
546546

547547
Print the exact tmachine archive selection as a shell `PODMAN_CI_TESTS` array:
@@ -566,14 +566,40 @@ matching lines in `branch-checks.yml`, and `ALIGNED_WORKSPACES`. The Podman
566566
driver suite (`tests/suites/drivers/podman`) compares OpenShell and direct
567567
Podman user-namespace mappings.
568568
Each `fedora-podman-{rootful,rootless}-userns-<mode>` environment configures
569-
the gateway with one mode (`default`, `auto`, `keep-id` or `private`); only the
570-
`binaries` installer applies it:
569+
the gateway with one mode (`default`, `auto`, `keep-id` or `private`) and works
570+
with every installer; CI runs it with `rpm`:
571571

572572
```shell
573573
nix run .#openshell-test-runner -- run \
574-
--environment fedora-podman-rootless-userns-keep-id --installer binaries \
575-
--gateway tmachine --family drivers/podman
576-
```
574+
--environment fedora-podman-rootless-userns-keep-id --installer rpm \
575+
--family drivers/podman
576+
```
577+
578+
#### Gateway overrides in an environment
579+
580+
An environment overrides gateway settings by writing the tables to change to
581+
`/etc/openshell-test/gateway-overrides.toml` in a playbook that runs before the
582+
installer. The file holds whole tables, such as `[openshell.gateway]` or
583+
`[openshell.drivers.podman]`, and is not a complete configuration. Each
584+
installer applies it to the gateway's own file:
585+
586+
- `binaries` applies it to the `/etc/openshell/gateway.toml` it generates.
587+
- `deb` and `rpm` apply it to the service user's
588+
`~/.config/openshell/gateway.toml`, the file the packaged service reads. The
589+
file starts as a copy of the rpm's
590+
`/usr/share/openshell-gateway/gateway.toml.default`, where the service would
591+
seed it on first start, or as a minimal `version = 2` file when the package
592+
has no default. No environment replaces the packaged file, and an environment
593+
with no overrides leaves it untouched.
594+
- `k3s` installers ignore the file.
595+
596+
`tests/tmachine/ansible/roles/openshell_gateway/files/merge-gateway-toml.py`
597+
does the work. Each key in the overrides replaces the same key in the table, or
598+
is added to it, and a table the file lacks is appended. The rest of the file,
599+
comments included, stays. The script parses the result and fails the setup,
600+
leaving the file unchanged, when it isn't valid TOML. It can't remove a key.
601+
Settings that the packaged service reads from `gateway.env` instead of the
602+
TOML are not covered.
577603

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

‎tasks/test.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ depends = [
2626
"test:maintainer-approval",
2727
"test:cargo-lockfile-alignment",
2828
"test:review-readiness",
29+
"test:merge-gateway-toml",
2930
]
3031

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

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,30 @@
4848
HOME: /home/tmachine
4949
XDG_RUNTIME_DIR: /run/user/1000
5050

51+
# The binaries installer runs a plain-HTTP gateway named tmachine from a
52+
# system service and puts the CLI in /usr/local/bin. The package installers
53+
# run the packaged user service, install the CLI in /usr/bin and register
54+
# the gateway as openshell, using the package default network and namespace.
55+
- name: Detect the installer
56+
ansible.builtin.stat:
57+
path: /usr/local/bin/openshell
58+
register: podman_e2e_binaries_cli
59+
60+
- name: Select the gateway under test
61+
ansible.builtin.set_fact:
62+
podman_e2e_binaries: "{{ podman_e2e_binaries_cli.stat.exists }}"
63+
podman_e2e_cli: "{{ '/usr/local/bin/openshell' if podman_e2e_binaries_cli.stat.exists else '/usr/bin/openshell' }}"
64+
podman_e2e_gateway: "{{ 'tmachine' if podman_e2e_binaries_cli.stat.exists else 'openshell' }}"
65+
5166
- name: Remove any previous OpenShell gateway registration
67+
when: podman_e2e_binaries
5268
ansible.builtin.command:
5369
argv: [/usr/local/bin/openshell, gateway, remove, tmachine]
5470
changed_when: false
5571
failed_when: false
5672

5773
- name: Register the configured OpenShell gateway
74+
when: podman_e2e_binaries
5875
ansible.builtin.command:
5976
argv: [/usr/local/bin/openshell, gateway, add, http://127.0.0.1:17670, --local, --name, tmachine]
6077

@@ -75,12 +92,12 @@
7592
CONTAINER_ENGINE: podman
7693
CONTAINER_HOST: unix:///run/user/1000/podman/podman.sock
7794
HOME: /home/tmachine
78-
OPENSHELL_BIN: /usr/local/bin/openshell
95+
OPENSHELL_BIN: "{{ podman_e2e_cli }}"
7996
OPENSHELL_E2E_CONTAINER_ENGINE_UNSET_XDG_CONFIG_HOME: "1"
8097
OPENSHELL_E2E_DRIVER: podman
81-
OPENSHELL_E2E_NETWORK_NAME: tmachine
82-
OPENSHELL_E2E_SANDBOX_NAMESPACE: tmachine
83-
OPENSHELL_GATEWAY: tmachine
98+
OPENSHELL_E2E_NETWORK_NAME: "{{ podman_e2e_gateway }}"
99+
OPENSHELL_E2E_SANDBOX_NAMESPACE: "{{ podman_e2e_gateway }}"
100+
OPENSHELL_GATEWAY: "{{ podman_e2e_gateway }}"
84101
OPENSHELL_PODMAN_SOCKET: /run/user/1000/podman/podman.sock
85102
XDG_RUNTIME_DIR: /run/user/1000
86103
register: podman_e2e_test_result
@@ -96,9 +113,12 @@
96113
var: podman_e2e_test_result.stdout_lines
97114

98115
- name: Capture OpenShell gateway journal after Podman E2E test failure
99-
become: true
116+
become: "{{ podman_e2e_binaries }}"
100117
ansible.builtin.command:
101-
argv: [journalctl, --unit, openshell-gateway.service, --no-pager, --lines, "200"]
118+
argv: >-
119+
{{ ['journalctl', '--unit', 'openshell-gateway.service', '--no-pager', '--lines', '200']
120+
if podman_e2e_binaries else
121+
['journalctl', '--user-unit', 'openshell-gateway.service', '--no-pager', '--lines', '200'] }}
102122
changed_when: false
103123
failed_when: false
104124
when: podman_e2e_test_result.rc != 0

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,27 @@
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-
# `podman_userns_driver_config`, which the openshell_gateway role (the
9-
# `binaries` installer) appends to gateway.toml; default removes the file. The
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
1011
# Podman support crate (tests/support/podman) reads the published mode and
1112
# runs Podman's own reference container in it.
1213
---
1314
- name: Podman user namespaces for tests
1415
hosts: all
1516
gather_facts: false
1617
vars:
17-
podman_userns_driver_config: /etc/openshell-test/podman-driver.toml
18+
podman_userns_driver_config: /etc/openshell-test/gateway-overrides.toml
1819
podman_userns_settings:
1920
default: ""
2021
auto: |
22+
[openshell.drivers.podman]
2123
userns = "auto"
2224
keep-id: |
25+
[openshell.drivers.podman]
2326
userns = "keep-id"
2427
private: |
28+
[openshell.drivers.podman]
2529
userns = "private"
2630
uidmap = ["0:0:1", "1:1:65535"]
2731
gidmap = ["0:0:1", "1:1:65535"]
@@ -59,7 +63,7 @@
5963
when: podman_userns_mode != "default"
6064

6165
# The fragment is the only source of userns, uidmap and gidmap settings in
62-
# the rendered gateway.toml, so default mode leaves them unset.
66+
# the gateway's configuration, so default mode leaves them unset.
6367
- name: Remove Podman driver user-namespace settings for default mode
6468
become: true
6569
ansible.builtin.file:

0 commit comments

Comments
 (0)