Skip to content

fix(agones): report network player counts, not this proxy's#64

Draft
hbrombeer wants to merge 1 commit into
mainfrom
fix/agones-network-player-counts
Draft

fix(agones): report network player counts, not this proxy's#64
hbrombeer wants to merge 1 commit into
mainfrom
fix/agones-network-player-counts

Conversation

@hbrombeer

Copy link
Copy Markdown
Member

The bug

Two players standing in the same lobby, each connected through a different proxy. /agones reported (1 players) — on both proxies.

Live from the dev cluster at the time of the report:

 player_name |  proxy_id  |         server_name
 dahendriik  | velocity   | minestom-lobby-2-m4j27-96nxf
 A8K1        | velocity-2 | minestom-lobby-2-m4j27-96nxf

AgonesCommand read server.playersConnected.size and proxyServer.playerCount. Both are proxy-local by definition — Velocity has no idea the other proxy exists. The command printed the half it could see as if it were the whole network.

The fix

Ask ProxyService.getNetworkPlayerCounts(), backed by service-player's session table (which already records proxy_id and server_name for every player).

When the presence service cannot be reached, the counts still render — but the command says they are proxy-local. That matters: an unlabelled local count looks exactly like a network count, which is precisely why this shipped unnoticed. Silently degrading back to the old numbers would be reprinting the bug.

plugin-proxy-api is compileOnly, never shaded: the ProxyServiceRegistry we read must be the same class plugin-proxy loaded, or we would read a registry nobody writes to.

Merge order

Last of 5. Until the ones above land, getNetworkPlayerCounts() returns null and /agones behaves as today, minus the false confidence (it now labels the numbers).

  1. feat(player): count online players per backend server library-grpc-contracts#71 → release library-grpc-contracts-player 0.4.0
  2. feat(proxy): expose network-wide player counts per backend server plugin-proxy#15 → release plugin-proxy-api 0.2.0
  3. service-player — implement the RPC
  4. plugin-player — implement countPlayersByServer()
  5. this PR

Verified

./gradlew :velocity:test green against locally-published plugin-proxy-api:0.2.0. New tests: two players on one lobby across two proxies read as (2 players); a fallback to proxy-local counts is labelled; a server nobody is on shows (0 players) rather than vanishing.

/agones printed the players connected to the proxy running it. With two proxies
in front of one lobby, each saw half of it: two players standing together in the
lobby were reported as "1 players" on both.

Velocity cannot do better — playersConnected and playerCount are proxy-local by
definition. Ask ProxyService, which answers for the whole network.

When the network cannot be asked the numbers are still shown, but labelled as
proxy-local. An unlabelled local count is indistinguishable from a network one,
which is how this went unnoticed.
@sonarqubecloud

Copy link
Copy Markdown

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