Files
CosmicClash/compose.allocated-smoke.yml
T
Josh Creek 5765532409 fix(allocator): publish signed assignment rosters before servers start
The root blocker (issue #14). The worker bound the provider allocation
and stopped. Service.PublishRoster and store.SaveVerifiedAssignmentRoster
both existed, fully tested, with zero non-test callers, and the
production allocator configured neither a roster store nor a signing
key. Nothing ever wrote the assignments table.

The allocated supervisor fetches a non-empty roster before it launches
the game child, so every real allocation failed at that fetch: no match
could reach ASSIGNMENT_READY or accept a player. Existing tests seeded
assignments directly, which is exactly why the missing hand-off went
unnoticed.

The worker now builds one join authorisation per durable participant,
signs each with the active key, and publishes them. Participants are
read through the same query SaveVerifiedAssignmentRoster re-validates
against, so the allocator cannot construct a roster the persistence
boundary would reject. The manifest commits to a digest over the whole
roster, so a server cannot be handed a truncated roster whose surviving
entries are each individually valid.

Persist the provider endpoint on the allocation: it arrived on the
provider response and was never stored, so a worker crashing between
allocating and publishing had no endpoint to recover and would have
stranded the match permanently. Republishing is idempotent, so that
crash now simply retries.

cmd/allocator refuses to start without key material rather than running
an allocator that binds allocations and silently strands every match.
The k8s allocator Deployment mounts the same key set the Fleet does, and
both now take the JSON key map so a rotation can publish several.

New integration test drives the real worker through to the supervisor's
own roster read path without seeding the assignments table. Verified it
fails with "assignments = 0, want 2" when the publish step is removed.
2026-09-05 10:42:31 +01:00

113 lines
4.7 KiB
YAML

services:
database:
image: postgres:17-alpine
environment:
POSTGRES_DB: cosmic_clash_test
POSTGRES_USER: cosmic_clash_test
POSTGRES_PASSWORD: cosmic_clash_test
healthcheck:
test: ["CMD-SHELL", "pg_isready -U cosmic_clash_test -d cosmic_clash_test"]
interval: 1s
timeout: 3s
retries: 30
control-plane:
build:
context: .
target: testkit-api
environment:
COSMIC_CLASH_POSTGRES_DSN: postgres://cosmic_clash_test:cosmic_clash_test@database:5432/cosmic_clash_test?sslmode=disable
COSMIC_CLASH_WORKLOAD_SECRET: compose-workload-secret
command: ["--listen=0.0.0.0:8080", "--migrations=/opt/cosmic-clash/migrations"]
depends_on:
database:
condition: service_healthy
ports:
- "18080:8080"
matcher:
build:
context: .
target: matcher
environment:
COSMIC_CLASH_POSTGRES_DSN: postgres://cosmic_clash_test:cosmic_clash_test@database:5432/cosmic_clash_test?sslmode=disable
command: ["--dsn=postgres://cosmic_clash_test:cosmic_clash_test@database:5432/cosmic_clash_test?sslmode=disable", "--migrations=/opt/cosmic-clash/migrations", "--playlist=casual", "--size=6", "--interval=1s"]
depends_on:
database:
condition: service_healthy
agones-provider:
image: python:3.12-alpine
command: ["python3", "/opt/fake_agones_provider.py"]
environment:
FAKE_AGONES_TLS_CERT: /run/cosmic-clash/fake-agones.crt
FAKE_AGONES_TLS_KEY: /run/cosmic-clash/fake-agones.key
volumes:
- ./scripts/fake_agones_provider.py:/opt/fake_agones_provider.py:ro
- ${COMPOSE_SMOKE_DIR:-/tmp/cosmic-clash-allocated-smoke}/fake-agones.crt:/run/cosmic-clash/fake-agones.crt:ro
- ${COMPOSE_SMOKE_DIR:-/tmp/cosmic-clash-allocated-smoke}/fake-agones.key:/run/cosmic-clash/fake-agones.key:ro
allocator:
build:
context: .
target: allocator
environment:
COSMIC_CLASH_POSTGRES_DSN: postgres://cosmic_clash_test:cosmic_clash_test@database:5432/cosmic_clash_test?sslmode=disable
COSMIC_CLASH_AGONES_URL: https://agones-provider:8443
COSMIC_CLASH_AGONES_NAMESPACE: cosmic-clash
COSMIC_CLASH_WORKLOAD_SECRET: compose-workload-secret
COSMIC_CLASH_KUBERNETES_TOKEN_PATH: /run/cosmic-clash/kubernetes-token
COSMIC_CLASH_KUBERNETES_CA_PATH: /run/cosmic-clash/fake-agones.crt
command: ["--dsn=postgres://cosmic_clash_test:cosmic_clash_test@database:5432/cosmic_clash_test?sslmode=disable", "--migrations=/opt/cosmic-clash/migrations", "--interval=1s", "--transport=enet"]
depends_on:
database:
condition: service_healthy
agones-provider:
condition: service_started
volumes:
- ${COMPOSE_SMOKE_DIR:-/tmp/cosmic-clash-allocated-smoke}/kubernetes-token:/run/cosmic-clash/kubernetes-token:ro
- ${COMPOSE_SMOKE_DIR:-/tmp/cosmic-clash-allocated-smoke}/fake-agones.crt:/run/cosmic-clash/fake-agones.crt:ro
maintenance:
build:
context: .
target: maintenance
environment:
COSMIC_CLASH_POSTGRES_DSN: postgres://cosmic_clash_test:cosmic_clash_test@database:5432/cosmic_clash_test?sslmode=disable
command: ["--dsn=postgres://cosmic_clash_test:cosmic_clash_test@database:5432/cosmic_clash_test?sslmode=disable", "--migrations=/opt/cosmic-clash/migrations", "--interval=1h", "--initial-connect-interval=1s"]
depends_on:
database:
condition: service_healthy
game-server:
build:
context: .
target: game-server
command:
- --drain-url=http://127.0.0.1:7780/drain
- --drain-token-env=COSMIC_CLASH_DRAIN_TOKEN
- --drain-grace=10s
- --
- /opt/cosmic-clash/cosmic-clash-server
- --port=31001
- --allocated-mode
- --match-id=compose-match-0001
- --server-id=compose-server-0001
- --playlist-version=casual
- --playlist=casual
- --client-build=build-1
- --assignment-expiry-unix=4102444800
- --server-image-digest=sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- --transport=enet
- --region=EU
- --join-authorisations-file=/run/cosmic-clash/join-roster.json
- --join-authorisations-key-file=/run/secrets/cosmic-clash/join-signing-keys.json
- --readiness-port=7780
environment:
COSMIC_CLASH_DRAIN_TOKEN: compose-drain-token
COSMIC_CLASH_CONTROL_PLANE_URL: http://control-plane:8080
COSMIC_CLASH_WORKLOAD_TOKEN: ${COSMIC_CLASH_COMPOSE_WORKLOAD_TOKEN:?allocated smoke workload token is required}
volumes:
- ${COMPOSE_SMOKE_DIR:-/tmp/cosmic-clash-allocated-smoke}/join-roster.json:/run/cosmic-clash/join-roster.json:ro
- ${COMPOSE_SMOKE_DIR:-/tmp/cosmic-clash-allocated-smoke}/join-signing-keys.json:/run/secrets/cosmic-clash/join-signing-keys.json:ro