Files
CosmicClash/deploy/k8s/base/fleet.yaml
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

129 lines
5.0 KiB
YAML

apiVersion: agones.dev/v1
kind: Fleet
metadata:
name: cosmic-clash-game
namespace: cosmic-clash
labels:
app.kubernetes.io/name: game-fleet
spec:
replicas: 2
strategy:
type: RollingUpdate
template:
metadata:
labels:
app.kubernetes.io/name: game-server
cosmic-clash.io/region: EU
cosmic-clash.io/build: build-1
cosmic-clash.io/protocol: "1"
cosmic-clash.io/transport: enet
annotations:
# The release process replaces this with the immutable image digest;
# the Downward API passes the same value to the supervisor so the
# allocated child can validate its assignment manifest.
cosmic-clash.io/image-digest: sha256:0000000000000000000000000000000000000000000000000000000000000000
spec:
ports:
- name: game
containerPort: 7777
protocol: UDP
health:
disabled: false
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
template:
spec:
nodeSelector:
cosmic-clash.io/capacity-type: on-demand
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app.kubernetes.io/name: game-server
serviceAccountName: match-server
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
seccompProfile:
type: RuntimeDefault
containers:
- name: game-server
image: ghcr.io/cosmic-clash/game-server@sha256:0000000000000000000000000000000000000000000000000000000000000000
args:
- --sdk-base-url=http://127.0.0.1:9357
- --ready-url=http://127.0.0.1:7780/ready
- --drain-url=http://127.0.0.1:7780/drain
- --initial-connect-ready-url=http://127.0.0.1:7780/initial-connect-ready
- --drain-token-env=COSMIC_CLASH_DRAIN_TOKEN
- --control-plane-url=http://control-plane.cosmic-clash.svc.cluster.local:8080
- --server-id-env=COSMIC_CLASH_SERVER_ID
- --image-digest-env=COSMIC_CLASH_IMAGE_DIGEST
- --roster-path=/run/cosmic-clash/join-roster.json
- --transport=enet
- --protocol-version=1
- --
- /opt/cosmic-clash/CosmicClashServer.x86_64
- --allocated-mode
- --match-id=allocation-placeholder
- --server-id=allocation-placeholder
- --playlist-version=casual
- --playlist=casual
- --arena-path=
- --client-build=build-1
- --assignment-expiry-unix=1
- --server-image-digest=sha256:0000000000000000000000000000000000000000000000000000000000000000
- --transport=enet
- --region=EU
- --join-authorisations-file=/run/cosmic-clash/join-roster.json
# The key SET, not one key: an allocated server must accept
# authorisations signed with any currently-valid key so a
# rotation does not break matches already in flight.
- --join-authorisations-key-file=/run/secrets/cosmic-clash/join-signing-keys.json
- --readiness-port=7780
env:
- name: COSMIC_CLASH_SERVER_ID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: COSMIC_CLASH_IMAGE_DIGEST
valueFrom:
fieldRef:
fieldPath: metadata.annotations['cosmic-clash.io/image-digest']
- name: COSMIC_CLASH_DRAIN_TOKEN
valueFrom:
secretKeyRef:
name: cosmic-clash-game-server
key: drain-token
volumeMounts:
- name: allocated-roster
mountPath: /run/cosmic-clash
- name: join-signing-key
mountPath: /run/secrets/cosmic-clash
readOnly: true
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: [ALL]
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 1
memory: 512Mi
volumes:
- name: allocated-roster
emptyDir: {}
- name: join-signing-key
secret:
secretName: cosmic-clash-game-server
items:
- key: join-signing-keys.json
path: join-signing-keys.json