From 9fb2dff818cf7ce5b8c03f226cbedb296b62d1a8 Mon Sep 17 00:00:00 2001 From: Jacob Rothstein Date: Thu, 22 Oct 2026 16:09:00 -0700 Subject: [PATCH 1/3] validate.sh: stop the standalone container before the compose profiles The standalone container runs on --network host whenever an entry subscribes to a compose profile, and it was left running while the gateway and production-stack stacks came up. An entry that also serves h2/h3 keeps 8443 (and 8080), so the stack's edge failed to bind, shared the port, or exited on the QUIC port, and the checks reached the standalone server instead of the stack. --- scripts/validate.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/validate.sh b/scripts/validate.sh index f10af4413c..09a3719c5f 100755 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -2469,6 +2469,26 @@ if has_test "echo-ws" || has_test "echo-ws-pipeline" || has_test "echo-ws-limite fi fi +# ───── Hand the host's ports to the compose stacks ───── +# +# Any compose profile puts the standalone container on --network host (see +# docker_args above), and nothing stopped it before the stacks below came up. +# It keeps 8080 and, for an entry with an h2 or h3 profile, 8443: the ports +# the stack's server and edge bind. The edge then failed to bind, shared +# localhost with the standalone server, or (with h3 enabled) exited on the +# QUIC port, and the checks below described whichever process answered. The +# gateway checks can pass against a server with no proxy in front of it, and +# production-stack fails its auth wall, which the edge enforces and the +# server does not. libuvcpp works around it in the entry (main.cc, near +# init_database, and proxy-production/nginx.conf). +# +# Stopped rather than removed so the final dump_logs can still inspect it; the +# EXIT trap removes it. +if [ "$GATEWAY_ONLY" = "false" ] && { has_test "gateway-64" || has_test "gateway-h3" || has_test "production-stack"; }; then + echo "[compose] stopping $CONTAINER_NAME: the compose stacks bind the same host ports" + docker stop "$CONTAINER_NAME" >/dev/null 2>&1 || true +fi + # ───── Gateway profiles (reverse proxy + server, shared validation flow) ───── # # Both gateway-64 (h2) and gateway-h3 (h3 at the edge) use the same endpoint From 5374ad6c4bbe123376acb86a5a8a76925eecde92 Mon Sep 17 00:00:00 2001 From: MDA2AV Date: Fri, 13 Nov 2026 16:37:58 +0000 Subject: [PATCH 2/3] authsvc: ship the real binary under cargo 1.100's build-dir layout production-stack has failed on the bench host since the morning of 2026-11-13 on every entry (roadrunner-gateway #1757, morojs #1761, tako-gateway #1762): the shared authsvc container exits 0 with no output, the edge never sees it healthy, and the run ends with no results. rust:1-alpine moved to Rust 1.100 on 2026-11-12. Its cargo keeps each package's artifacts under target/release/build/// rather than target/release/deps/, so the cache-priming step's `rm -rf target/release/deps/authsvc*` stopped matching anything. The placeholder built from `fn main() {}` stayed up to date, the second `cargo build` finished in 0.04s without compiling src/, and the image shipped the placeholder: a 418 KB binary that exits 0 at once. `cargo clean --release -p authsvc` removes the placeholder's artifacts wherever cargo keeps them, and a grep for the server's startup line fails the build if the placeholder is ever shipped again. Built against the current rust:1-alpine (1.100.0): a 1.2 MB binary that logs "authsvc listening on ...", answers /_health with 200 and an /_auth without a token with 401. --- frameworks/_shared/authsvc/Dockerfile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/frameworks/_shared/authsvc/Dockerfile b/frameworks/_shared/authsvc/Dockerfile index bd5ecae961..d8173a283b 100644 --- a/frameworks/_shared/authsvc/Dockerfile +++ b/frameworks/_shared/authsvc/Dockerfile @@ -10,15 +10,27 @@ RUN apk add --no-cache musl-dev pkgconfig # Prime the dep cache: build against an empty main.rs so cargo downloads # and compiles the dependency graph once. Actual src/ changes below don't # invalidate this layer. +# +# `cargo clean -p authsvc` then drops the placeholder's own artifacts, and only +# those, wherever this cargo keeps them. This step used to delete +# target/release/deps/authsvc* by hand. Cargo 1.100 moved each package's +# artifacts to target/release/build///, the glob stopped +# matching, and the build below found the placeholder up to date and shipped +# it: an authsvc that exits 0 at once without a word, so every +# production-stack run failed before measuring anything. COPY Cargo.toml . RUN mkdir src && echo 'fn main() {}' > src/main.rs && \ cargo build --release && \ - rm -rf src target/release/deps/authsvc* + cargo clean --release -p authsvc && \ + rm -rf src -# Now add the real source and rebuild. +# Now add the real source and rebuild. The grep fails the build if the +# placeholder is ever shipped again: the server's startup line is in the +# real binary and nowhere in the empty one. COPY src ./src RUN cargo build --release && \ - strip target/release/authsvc + strip target/release/authsvc && \ + grep -q "authsvc listening on" target/release/authsvc FROM alpine:3.20 # ca-certificates are needed if authsvc ever connects to something over From cdb764ea1840560458ea1e34e998c1590b14ed7e Mon Sep 17 00:00:00 2001 From: MDA2AV Date: Fri, 13 Nov 2026 16:37:58 +0000 Subject: [PATCH 3/3] aspnet-minimal_nginx, aspnet-minimal_caddy: build against aspnet-minimal's Services and Types Both Dockerfiles still COPY aspnet-minimal's AppData.cs and Models.cs, which #1002 (2026-07-18) split into Services/ and Types/, so neither image has built since. They were the only failures in #1615's validation sweep, and their published results have not been refreshed since July. Copy Handlers.cs with Services/ and Types/, register DatabaseService, DatasetService, ItemService and the AppJsonContext resolver the way aspnet-minimal's Program.cs does, and give the nginx entry's /api routes DatabaseService's Postgres pool in place of AppData.PgDataSource. The caddy entry gains the StackExchange.Redis reference DatabaseService needs; it connects to nothing unless REDIS_URL is set, which gateway-h3 never does. --- frameworks/aspnet-minimal_caddy/Dockerfile | 9 +++--- frameworks/aspnet-minimal_caddy/Program.cs | 17 ++++++++++- .../aspnet-minimal_caddy.csproj | 1 + frameworks/aspnet-minimal_nginx/Dockerfile | 7 +++-- frameworks/aspnet-minimal_nginx/Program.cs | 29 ++++++++++++++----- frameworks/aspnet-minimal_nginx/README.md | 2 +- 6 files changed, 49 insertions(+), 16 deletions(-) diff --git a/frameworks/aspnet-minimal_caddy/Dockerfile b/frameworks/aspnet-minimal_caddy/Dockerfile index 51f9a0698c..44ba3473ed 100644 --- a/frameworks/aspnet-minimal_caddy/Dockerfile +++ b/frameworks/aspnet-minimal_caddy/Dockerfile @@ -2,13 +2,14 @@ FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /app # Copy project file and shared source from aspnet-minimal. We reuse the -# same Handlers/AppData/Models as aspnet-minimal_nginx — the only thing -# specific to this entry is the Caddy proxy config. +# same Handlers and the Services/Types they are written against as +# aspnet-minimal_nginx — the only thing specific to this entry is the Caddy +# proxy config. COPY frameworks/aspnet-minimal_caddy/aspnet-minimal_caddy.csproj . COPY frameworks/aspnet-minimal_caddy/Program.cs . COPY frameworks/aspnet-minimal/Handlers.cs . -COPY frameworks/aspnet-minimal/AppData.cs . -COPY frameworks/aspnet-minimal/Models.cs . +COPY frameworks/aspnet-minimal/Services ./Services +COPY frameworks/aspnet-minimal/Types ./Types RUN dotnet publish -c Release -o out diff --git a/frameworks/aspnet-minimal_caddy/Program.cs b/frameworks/aspnet-minimal_caddy/Program.cs index 16e1e4648e..1195328e1b 100644 --- a/frameworks/aspnet-minimal_caddy/Program.cs +++ b/frameworks/aspnet-minimal_caddy/Program.cs @@ -1,8 +1,20 @@ +using HttpArena.Services; +using HttpArena.Types; + using Microsoft.AspNetCore.Server.Kestrel.Core; var builder = WebApplication.CreateBuilder(args); builder.Logging.ClearProviders(); +// The handlers are aspnet-minimal's, written against its services; they are +// registered here the way aspnet-minimal registers them. +builder.Services.ConfigureHttpJsonOptions(o => + o.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonContext.Default)); + +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); + builder.WebHost.ConfigureKestrel(options => { options.ListenAnyIP(8080, lo => @@ -13,7 +25,10 @@ var app = builder.Build(); -AppData.Load(); +// Load the dataset and open the Postgres pool at startup instead of on the +// first request. +_ = app.Services.GetRequiredService(); +_ = app.Services.GetRequiredService(); app.MapGet("/baseline2", Handlers.Sum); app.MapGet("/json/{count}", Handlers.Json); diff --git a/frameworks/aspnet-minimal_caddy/aspnet-minimal_caddy.csproj b/frameworks/aspnet-minimal_caddy/aspnet-minimal_caddy.csproj index 2fbebb32af..f675f10348 100644 --- a/frameworks/aspnet-minimal_caddy/aspnet-minimal_caddy.csproj +++ b/frameworks/aspnet-minimal_caddy/aspnet-minimal_caddy.csproj @@ -8,5 +8,6 @@ + diff --git a/frameworks/aspnet-minimal_nginx/Dockerfile b/frameworks/aspnet-minimal_nginx/Dockerfile index 77bed4dc41..f454c57bdb 100644 --- a/frameworks/aspnet-minimal_nginx/Dockerfile +++ b/frameworks/aspnet-minimal_nginx/Dockerfile @@ -1,12 +1,13 @@ FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /app -# Copy project file and shared source from aspnet-minimal +# Copy project file and shared source from aspnet-minimal: its Handlers and +# the Services/Types they are written against COPY frameworks/aspnet-minimal_nginx/aspnet-minimal_nginx.csproj . COPY frameworks/aspnet-minimal_nginx/Program.cs . COPY frameworks/aspnet-minimal/Handlers.cs . -COPY frameworks/aspnet-minimal/AppData.cs . -COPY frameworks/aspnet-minimal/Models.cs . +COPY frameworks/aspnet-minimal/Services ./Services +COPY frameworks/aspnet-minimal/Types ./Types RUN dotnet publish -c Release -o out diff --git a/frameworks/aspnet-minimal_nginx/Program.cs b/frameworks/aspnet-minimal_nginx/Program.cs index f7079585b1..36c02a7277 100644 --- a/frameworks/aspnet-minimal_nginx/Program.cs +++ b/frameworks/aspnet-minimal_nginx/Program.cs @@ -1,4 +1,6 @@ using System.Text.Json; +using HttpArena.Services; +using HttpArena.Types; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Server.Kestrel.Core; @@ -9,6 +11,15 @@ var builder = WebApplication.CreateBuilder(args); builder.Logging.ClearProviders(); +// The gateway handlers are aspnet-minimal's, written against its services; +// they are registered here the way aspnet-minimal registers them. +builder.Services.ConfigureHttpJsonOptions(o => + o.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonContext.Default)); + +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); + builder.WebHost.ConfigureKestrel(options => { options.ListenAnyIP(8080, lo => @@ -67,7 +78,11 @@ var app = builder.Build(); -AppData.Load(); +// Load the dataset and open the Postgres pool at startup instead of on the +// first request. The /api routes below run their queries on the same pool. +_ = app.Services.GetRequiredService(); +_ = app.Services.GetRequiredService(); +var pg = app.Services.GetRequiredService().Postgres; // ── gateway-64 routes (unchanged) ─────────────────────────────────────────── @@ -133,9 +148,9 @@ async cancel => { wasMiss = true; - if (AppData.PgDataSource is null) return ""; + if (pg is null) return ""; - await using var cmd = AppData.PgDataSource.CreateCommand( + await using var cmd = pg.CreateCommand( "SELECT id, name, category, price, quantity, active, rating_score, rating_count " + "FROM items WHERE id = $1 LIMIT 1"); cmd.Parameters.AddWithValue(id); @@ -195,13 +210,13 @@ return; } - if (AppData.PgDataSource is null) + if (pg is null) { ctx.Response.StatusCode = 503; return; } - await using var cmd = AppData.PgDataSource.CreateCommand( + await using var cmd = pg.CreateCommand( "UPDATE items SET name = $1, price = $2, quantity = $3 WHERE id = $4"); cmd.Parameters.AddWithValue(update.Name); cmd.Parameters.AddWithValue(update.Price); @@ -242,9 +257,9 @@ async cancel => { wasMiss = true; - if (AppData.PgDataSource is null) return ""; + if (pg is null) return ""; - await using var cmd = AppData.PgDataSource.CreateCommand( + await using var cmd = pg.CreateCommand( "SELECT id, name, email, plan FROM users WHERE id = $1 LIMIT 1"); cmd.Parameters.AddWithValue(uid); diff --git a/frameworks/aspnet-minimal_nginx/README.md b/frameworks/aspnet-minimal_nginx/README.md index 01f1f08abd..485fe81224 100644 --- a/frameworks/aspnet-minimal_nginx/README.md +++ b/frameworks/aspnet-minimal_nginx/README.md @@ -87,4 +87,4 @@ Empirically tuned for this entry: - `libgssapi-krb5-2` installed in the runtime image — required by `StackExchange.Redis` for TLS/auth layer initialization (crashes without it even on plain TCP) - Routes behind `/api/*` are only registered when `REDIS_URL` is set (guarded by `if (!string.IsNullOrWhiteSpace(redisUrl))`) — otherwise ASP.NET's endpoint builder fails to resolve `HybridCache` as a DI dependency and every route returns 500 - Postgres runs on tmpfs (`--tmpfs /var/lib/postgresql/data`) for write performance -- Shares `Handlers.cs`, `AppData.cs`, `Models.cs` from `aspnet-minimal/` via Dockerfile COPY +- Shares `Handlers.cs`, `Services/` and `Types/` from `aspnet-minimal/` via Dockerfile COPY