Skip to content

feat(velocity): drain players via transfer before shutdown - #66

Merged
hbrombeer merged 2 commits into
mainfrom
feat/proxy-drain
Aug 1, 2026
Merged

feat(velocity): drain players via transfer before shutdown#66
hbrombeer merged 2 commits into
mainfrom
feat/proxy-drain

Conversation

@hbrombeer

Copy link
Copy Markdown
Member

Core of the proxy drain project: a Velocity pod that is rolled today kicks everyone on it. The chart's preStop hook (groundsgg/charts, grounds-velocity 0.9.0) now calls a loopback drain endpoint served by this plugin:

  • Lobby players get a Minecraft transfer packet right away and reconnect through the public name → mc-router → the already-Ready replacement proxy.
  • Players inside a round stay untouched — Agones keeps their Allocated GameServer alive; the moment the round sends them back towards a lobby, that connect becomes the transfer instead (ServerPreConnectEvent).
  • Deadline (grace period − 60s): whoever is left is transferred regardless — still better than the kick seconds away. Pre-1.20.5 clients get an honest disconnect message.
  • New logins are denied while draining.

Endpoints (loopback only): /drain/start?deadlineSeconds=N, /drain/players, /drain/status. GROUNDS_DRAIN_TRANSFER_HOST unset = wait-only drain.

Session correctness on transfer (reconnect vs. stale session) is handled by groundsgg/library-grpc-contracts#78 / groundsgg/service-player#95 / groundsgg/plugin-player#31 — deploy those first or transferred players bounce off ALREADY_ONLINE for up to 90s.

Rollout order: contracts → service-player → plugin-player → this (new velocity image) → charts grounds-velocity 0.9.0 → deploy values (drain.enabled, drain.transferHost, terminationGracePeriodSeconds).

A proxy pod that is rolled today kicks everyone on it. The preStop hook
now calls a loopback drain endpoint instead: lobby players are moved to
another proxy with a Minecraft transfer packet immediately, players
inside a round stay until the round sends them back towards a lobby
(that connect becomes the transfer), and at the deadline the rest is
transferred regardless. New logins are denied while draining.

Wait-only without GROUNDS_DRAIN_TRANSFER_HOST; endpoint is loopback so
only the pod's own preStop hook can trigger it.
GROUNDS_DRAIN_TRANSFER_HOST becomes an override: without it the target
is this region's own entry in the REGIONS catalogue (what /region
already transfers players with), selected by REGION. One shared values
file then drains correctly in every region.
@sonarqubecloud

sonarqubecloud Bot commented Aug 1, 2026

Copy link
Copy Markdown

@hbrombeer
hbrombeer marked this pull request as ready for review August 1, 2026 19:46
@hbrombeer
hbrombeer merged commit 286154c into main Aug 1, 2026
3 checks passed
@hbrombeer
hbrombeer deleted the feat/proxy-drain branch August 1, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant