Skip to content

Commit 88cbbd1

Browse files
authored
feat(server)!: configure the server with server.toml and run workers on Podman (#1470)
* feat(server)!: read server settings from server.toml Launchers name their location and are resolved once at start-up. BREAKING CHANGE: --launchers, --oidc-config and --trusted-proxy-config are replaced by sqb server --config server.toml with [[launchers.docker]], [[launchers.local]], [oidc] and [trusted_proxy] sections. The old flags fail with a pointer to --config. * feat(workers): bound worker containers by launcher run settings and job resources Docker workers keep the location container's dropped capabilities and security options, take [launchers.docker.run] memory, cpus, pids and cgroup_parent, and a job's resources, with max_memory as the ceiling. Only positive limits are sent, so Podman workers are not started with a zero process limit. The reference image can install a released SQLBuild. * feat(location): check a location's health and run the stack on Podman sqb location health prints a target's state and exits 1 when no instance has checked in for 90 seconds or its last load failed. Docker workers join the location's named network when Podman reports it as bridge. A path-filtered and nightly Verify job runs the packaged Compose lifecycle on rootful Podman. sqb dev and sqb location get documentation pages. * ci: let the runner reach the root Podman socket in the Podman Compose job GitHub's Ubuntu runner keeps /run/podman private to root, so changing the socket's group alone left the runner user unable to connect. * ci: build with the classic builder in the Podman Compose job Podman has no BuildKit API, so buildx on the runner built in its own BuildKit container and the images never reached Podman's store.
1 parent 77089f2 commit 88cbbd1

66 files changed

Lines changed: 1948 additions & 392 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/verify.yml‎

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
wheels: ${{ steps.scope.outputs.wheels }}
5151
recovery: ${{ steps.scope.outputs.recovery }}
5252
ui: ${{ steps.scope.outputs.ui }}
53+
podman: ${{ steps.scope.outputs.podman }}
5354
cold_models: ${{ steps.tiers.outputs.cold_models }}
5455
dense_models: ${{ steps.tiers.outputs.dense_models }}
5556
cache_models: ${{ steps.tiers.outputs.cache_models }}
@@ -79,11 +80,12 @@ jobs:
7980
echo "clickhouse=$9"
8081
echo "recovery=${10}"
8182
echo "ui=${11}"
83+
echo "podman=${12}"
8284
} >> "${GITHUB_OUTPUT}"
8385
}
8486
8587
if [[ "${EVENT_NAME}" != "pull_request" && "${EVENT_NAME}" != "merge_group" ]]; then
86-
write_scope true true true true true true true true true true true
88+
write_scope true true true true true true true true true true true true
8789
exit 0
8890
fi
8991
@@ -95,7 +97,7 @@ jobs:
9597
if [[ -z "${BASE_SHA}" || -z "${HEAD_SHA}" ]] || \
9698
! git diff --name-only -z "${BASE_SHA}...${HEAD_SHA}" > "${changed_paths}"; then
9799
echo "Could not diff ${BASE_SHA:-<none>}...${HEAD_SHA:-<none>}; running every suite" >&2
98-
write_scope true true true true true true true true true true true
100+
write_scope true true true true true true true true true true true true
99101
exit 0
100102
fi
101103
@@ -144,7 +146,7 @@ jobs:
144146
&& "${HEAD_REF}" == release-please--branches--* ]]; } && release_metadata_only; then
145147
echo "The change is only release metadata; skipping the suites" \
146148
| tee -a "${GITHUB_STEP_SUMMARY}"
147-
write_scope false false false false false false false false false false false
149+
write_scope false false false false false false false false false false false false
148150
exit 0
149151
fi
150152
@@ -158,6 +160,7 @@ jobs:
158160
compiler_differential=false
159161
recovery=false
160162
ui=false
163+
podman=false
161164
broad=false
162165
changed=false
163166
# A change that only touches the website, root-level Markdown, the README demo GIFs or the
@@ -204,6 +207,14 @@ jobs:
204207
recovery=true
205208
;;
206209
esac
210+
case "${path}" in
211+
# The reference stack and the Docker launcher, which Podman serves through its
212+
# Docker-compatible API.
213+
# Every path here also selects the wheels the job installs.
214+
deploy/Dockerfile|deploy/project/*|deploy/compose*|compose.yml|.dockerignore|crates/sqlbuild-cli/src/workers/*|crates/sqlbuild-cli/src/server_config/*|tests/integration/src/sqlbuild/compiler/compiled_project/publication/test_compose.py|tests/integration/src/sqlbuild/compiler/compiled_project/publication/docker/compose/*|.github/workflows/verify.yml)
215+
podman=true
216+
;;
217+
esac
207218
case "${path}" in
208219
scripts/compiler_differential/*|scripts/run_compiler_differential.py|tests/*/scripts/compiler_differential/*|tests/goldens/*|tests/e2e/fixtures/*|website/examples/*|.github/workflows/verify.yml|Makefile)
209220
compiler_differential=true
@@ -271,7 +282,7 @@ jobs:
271282
done < "${changed_paths}"
272283
273284
if [[ "${changed}" != "true" ]]; then
274-
write_scope true true true true true true true true true true true
285+
write_scope true true true true true true true true true true true true
275286
exit 0
276287
fi
277288
@@ -298,7 +309,8 @@ jobs:
298309
"${compiler_differential}" \
299310
"${clickhouse}" \
300311
"${recovery}" \
301-
"${ui}"
312+
"${ui}" \
313+
"${podman}"
302314
303315
# Pull requests and merge groups run the 3k-model compile jobs and the 1k dense job; the
304316
# nightly run and manual runs add 5k and 10k. Budgets and ratio gates are the same in both.
@@ -1231,6 +1243,46 @@ jobs:
12311243
- name: Verify packaged Compose deployment and operational recovery
12321244
run: make test-compose-packaged
12331245

1246+
podman:
1247+
name: Packaged Compose lifecycle on Podman
1248+
needs: [changes, lockfile, wheels]
1249+
if: needs.changes.outputs.podman == 'true' && needs.changes.outputs.wheels == 'true' && needs.changes.outputs.full == 'true'
1250+
runs-on: ubuntu-24.04
1251+
timeout-minutes: 25
1252+
env:
1253+
# The Docker CLI and its Compose plugin drive rootful Podman through its API socket.
1254+
DOCKER_HOST: unix:///run/podman/podman.sock
1255+
DOCKER_SOCKET: /run/podman/podman.sock
1256+
# Podman has no BuildKit API: buildx would build in its own container and never load the image.
1257+
DOCKER_BUILDKIT: "0"
1258+
steps:
1259+
- uses: actions/checkout@v4
1260+
- uses: ./.github/actions/setup-uv
1261+
with:
1262+
version: "0.12.3"
1263+
enable-cache: true
1264+
- name: Install Python test dependencies without rebuilding the packages
1265+
run: |
1266+
uv python install 3.12
1267+
uv sync --locked --all-groups --all-extras --no-install-package sqlbuild --no-install-package sqlbuild-cli
1268+
- uses: actions/download-artifact@v4
1269+
with:
1270+
name: dist-wheel-linux-x86_64
1271+
path: dist
1272+
- name: Install the same wheels used by the images
1273+
run: uv pip install --no-deps dist/*.whl
1274+
- name: Start the Podman API socket with group access for the runner
1275+
run: |
1276+
sudo systemctl start podman.socket
1277+
sudo chmod 0711 /run/podman
1278+
sudo chgrp "$(id -g)" /run/podman/podman.sock
1279+
sudo chmod 0660 /run/podman/podman.sock
1280+
podman --version
1281+
docker version --format 'Podman API {{.Server.Version}}'
1282+
docker compose version
1283+
- name: Verify packaged Compose deployment and operational recovery
1284+
run: make test-compose-packaged
1285+
12341286
ui:
12351287
name: UI checks and unit tests
12361288
needs: changes
@@ -1296,6 +1348,7 @@ jobs:
12961348
clickhouse,
12971349
wheels,
12981350
compose,
1351+
podman,
12991352
ui,
13001353
]
13011354
runs-on: ubuntu-24.04
@@ -1323,6 +1376,7 @@ jobs:
13231376
CLICKHOUSE_RESULT: ${{ needs.clickhouse.result }}
13241377
WHEELS_RESULT: ${{ needs.wheels.result }}
13251378
COMPOSE_RESULT: ${{ needs.compose.result }}
1379+
PODMAN_RESULT: ${{ needs.podman.result }}
13261380
UI_SELECTED: ${{ needs.changes.outputs.ui }}
13271381
UI_RESULT: ${{ needs.ui.result }}
13281382
LABEL_ONLY: ${{ (github.event.action == 'labeled' || github.event.action == 'unlabeled') && github.event.label.name != 'full-verify' }}
@@ -1335,6 +1389,7 @@ jobs:
13351389
POSTGRES_SELECTED: ${{ needs.changes.outputs.postgres }}
13361390
CLICKHOUSE_SELECTED: ${{ needs.changes.outputs.clickhouse }}
13371391
WHEELS_SELECTED: ${{ needs.changes.outputs.wheels }}
1392+
PODMAN_SELECTED: ${{ needs.changes.outputs.podman }}
13381393
run: |
13391394
if [[ "${LABEL_ONLY}" == "true" ]]; then
13401395
echo "A label other than full-verify changed; this run verifies nothing"
@@ -1371,7 +1426,8 @@ jobs:
13711426
"${POSTGRES_RESULT}" \
13721427
"${CLICKHOUSE_RESULT}" \
13731428
"${WHEELS_RESULT}" \
1374-
"${COMPOSE_RESULT}"; do
1429+
"${COMPOSE_RESULT}" \
1430+
"${PODMAN_RESULT}"; do
13751431
if [[ "${result}" != "success" && "${result}" != "skipped" ]]; then
13761432
echo "A selected verification suite did not pass: ${result}" >&2
13771433
exit 1
@@ -1398,7 +1454,8 @@ jobs:
13981454
"${POSTGRES_SELECTED}:${POSTGRES_RESULT}" \
13991455
"${CLICKHOUSE_SELECTED}:${CLICKHOUSE_RESULT}" \
14001456
"${WHEELS_SELECTED}:${WHEELS_RESULT}" \
1401-
"${WHEELS_SELECTED}:${COMPOSE_RESULT}"; do
1457+
"${WHEELS_SELECTED}:${COMPOSE_RESULT}" \
1458+
"${PODMAN_SELECTED}:${PODMAN_RESULT}"; do
14021459
if [[ "${pair%%:*}" == "true" && "${pair#*:}" != "success" ]]; then
14031460
echo "A suite this change needs did not run to success: ${pair#*:}" >&2
14041461
exit 1

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""A job asks for more memory than its worker may have and fewer CPUs than the launcher default."""
2+
3+
from sqlbuild.orchestration import job, resources, schedule
4+
5+
annual_orders = job(
6+
"annual_orders",
7+
select="orders",
8+
description="Build orders.",
9+
resources=resources(memory="2g", cpus=0.5),
10+
schedule=schedule(cron="0 0 * * *", timezone="UTC", starts_at="2000-01-01T00:00:00Z"),
11+
)

‎clients/typescript/README.md‎

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ separate authentication contract, not an inferred privilege of this client.
4242
## Authenticate through a trusted proxy
4343

4444
Create a person with `sqb admin create-principal orders-reader`, then put the
45-
returned `principal_id` in a server-owned JSON file. Subjects are exact ASCII
46-
upstream identities, not inferred local usernames or email addresses:
47-
48-
```json
49-
{
50-
"origin": "https://control.example.com",
51-
"trusted_peers": ["127.0.0.1"],
52-
"identities": {
53-
"external-orders-reader": "00000000-0000-0000-0000-000000000001"
54-
}
55-
}
45+
returned `principal_id` in the `[trusted_proxy]` section of the server's
46+
`server.toml`. Subjects are exact ASCII upstream identities, not inferred local
47+
usernames or email addresses:
48+
49+
```toml
50+
[trusted_proxy]
51+
origin = "https://control.example.com"
52+
trusted_peers = ["127.0.0.1"]
53+
54+
[trusted_proxy.identities]
55+
external-orders-reader = "00000000-0000-0000-0000-000000000001"
5656
```
5757

5858
Replace the example UUID with the created person's ID, then start
59-
`sqb server --trusted-proxy-config proxy.json`. The proxy must terminate HTTPS,
59+
`sqb server --config server.toml`. The proxy must terminate HTTPS,
6060
remove any client-supplied `X-SQB-User`, and replace it with the authenticated
6161
upstream subject. Restrict access to the HTTP backend to the configured proxy
6262
peers. Trusting loopback also trusts other local processes on that host;
@@ -74,23 +74,22 @@ is inferred from the subject.
7474
Register an authorization-code client with your HTTPS identity provider, using
7575
`https://control.example.com/api/auth/oidc/callback` as its redirect URI. Create
7676
each person through the local control-store-owner administration path and put
77-
their UUID and exact provider subject in a server-owned JSON configuration:
78-
79-
```json
80-
{
81-
"origin": "https://control.example.com",
82-
"issuer": "https://identity.example.com",
83-
"client_id": "orders-control",
84-
"identities": {
85-
"external-orders-reader": "00000000-0000-0000-0000-000000000001"
86-
}
87-
}
77+
their UUID and exact provider subject in the `[oidc]` section of `server.toml`:
78+
79+
```toml
80+
[oidc]
81+
origin = "https://control.example.com"
82+
issuer = "https://identity.example.com"
83+
client_id = "orders-control"
84+
85+
[oidc.identities]
86+
external-orders-reader = "00000000-0000-0000-0000-000000000001"
8887
```
8988

90-
Start `sqb server --oidc-config oidc.json` behind an HTTPS-terminating proxy that
89+
Start `sqb server --config server.toml` behind an HTTPS-terminating proxy that
9190
preserves the configured Host and restricts access to the HTTP backend. For a
9291
confidential client, add `client_secret_env` naming the server environment
93-
variable holding its secret; never put the secret in the JSON file. To trust a
92+
variable holding its secret; never put the secret in `server.toml`. To trust a
9493
private provider CA, add `certificate_authority` pointing to a PEM bundle.
9594
Relative certificate paths resolve from the server process's working directory.
9695
TLS verification remains mandatory and upstream HTTP redirects are not followed.

‎clients/typescript/src/schema.d.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6309,7 +6309,10 @@ export interface operations {
63096309
};
63106310
read_location_health: {
63116311
parameters: {
6312-
query?: never;
6312+
query?: {
6313+
/** @description Only this target's observations */
6314+
target?: string;
6315+
};
63136316
header?: never;
63146317
path: {
63156318
location_id: string;

‎compose.yml‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: ${COMPOSE_PROJECT_NAME:-sqlbuild}
22

33
services:
44
postgres:
5-
image: postgres:17.6-alpine3.22
5+
image: docker.io/library/postgres:17.6-alpine3.22
66
environment:
77
POSTGRES_USER: sqlbuild
88
POSTGRES_DB: sqlbuild
@@ -24,15 +24,17 @@ services:
2424
target: server
2525
args:
2626
PYTHON_VERSION: ${PYTHON_VERSION:-3.12}
27+
SQLBUILD_SOURCE: ${SQLBUILD_SOURCE:-wheels}
28+
SQLBUILD_VERSION: ${SQLBUILD_VERSION:-}
2729
environment:
2830
- SQLBUILD_CONTROL_DATABASE_URL=${SQLBUILD_CONTROL_DATABASE_URL:?Set SQLBUILD_CONTROL_DATABASE_URL}
2931
- SQLBUILD_PLATFORM_WEBHOOK_URL
3032
group_add: ["${DOCKER_GID:?Set DOCKER_GID to the Docker socket group}"]
3133
volumes:
3234
- ${DOCKER_SOCKET:-/var/run/docker.sock}:/var/run/docker.sock
3335
configs:
34-
- source: launchers
35-
target: /etc/sqlbuild/launchers.json
36+
- source: server
37+
target: /etc/sqlbuild/server.toml
3638
ports:
3739
- "${SQLBUILD_BIND_ADDRESS:-127.0.0.1}:${SQLBUILD_PORT:-8000}:8000"
3840
healthcheck:
@@ -54,6 +56,8 @@ services:
5456
target: location
5557
args:
5658
PYTHON_VERSION: ${PYTHON_VERSION:-3.12}
59+
SQLBUILD_SOURCE: ${SQLBUILD_SOURCE:-wheels}
60+
SQLBUILD_VERSION: ${SQLBUILD_VERSION:-}
5761
SQLBUILD_GIT_REVISION: ${SQLBUILD_GIT_REVISION:?Set SQLBUILD_GIT_REVISION}
5862
command: [location, serve, --server, "http://server:8000", --location-id, "${SQLBUILD_LOCATION_ID:?Set SQLBUILD_LOCATION_ID}", --target, development]
5963
environment:
@@ -68,9 +72,20 @@ services:
6872
networks: [workers]
6973

7074
configs:
71-
launchers:
75+
server:
7276
content: |
73-
{"docker":[{"location_id":"${SQLBUILD_LOCATION_ID}","target":"development","server_url":"http://server:8000","max_workers":1,"socket":"/var/run/docker.sock","location_container":"${COMPOSE_PROJECT_NAME:-sqlbuild}-location","executable":"/usr/local/bin/sqb"}]}
77+
[server]
78+
host = "0.0.0.0"
79+
port = 8000
80+
81+
[[launchers.docker]]
82+
location = "orders"
83+
target = "development"
84+
server_url = "http://server:8000"
85+
max_workers = 1
86+
socket = "/var/run/docker.sock"
87+
location_container = "${COMPOSE_PROJECT_NAME:-sqlbuild}-location"
88+
executable = "/usr/local/bin/sqb"
7489
7590
volumes:
7691
control:

‎crates/sqlbuild-cli/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ sqlbuild-process-ownership.workspace = true
3939
sqlbuild-recall.workspace = true
4040
sqlbuild-rules.workspace = true
4141
tokio.workspace = true
42+
toml.workspace = true
4243
uuid.workspace = true
4344

4445
[target.'cfg(unix)'.dependencies]

0 commit comments

Comments
 (0)