Skip to content

fix(terraria,tmodloader): probe readiness without connecting - #42

Merged
ValgulNecron merged 2 commits into
mainfrom
fix/terraria-readiness-probe
Oct 5, 2026
Merged

ValgulNecron merged 2 commits into
mainfrom
fix/terraria-readiness-probe

Conversation

@ValgulNecron

@ValgulNecron ValgulNecron commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This replaces the crashing tcpSocket readiness probe in terraria and tmodloader with an exec probe that never connects to the game.

The bug: the Terraria server crashes when a client connects and closes right away. That is exactly what the kubelet's tcpSocket probe does every 10 s, so the probe crash-looped the pod.

Evidence from the 2026-10-04 kubelab live sweep:

  • The pod log showed two ... is connecting... lines, then an ObjectDisposedException in Terraria.Netplay.ServerLoop, and the container exited.
  • The pod had 5 game-container starts in 6 minutes.
  • A crash during world generation left the restarted server stuck at Choose World:.

The fix:

  • The readiness probe is now this command:
    sh -c "grep -qsE ':1E61 [0-9A-F]+:[0-9A-F]{4} 0A' /proc/net/tcp /proc/net/tcp6"
  • It succeeds only when a socket is in state 0A (LISTEN) on local port 7777 (0x1E61).
  • The pattern cannot match a connection whose remote port is 7777.
  • The pod turns Ready once the server accepts players, without the probe ever opening a connection.
  • initialDelaySeconds, periodSeconds and failureThreshold are unchanged.
  • specs.md explains the probe for both modules.
  • Versions: terraria 2.2.1 → 2.2.2, tmodloader 1.0.0 → 1.0.1.

Verification (kubelab, 2026-10-05)

  • Vanilla server: a vanilla-latest server with this probe was not-ready 4 times during world generation, then turned Ready. It stayed Ready for 6.5 minutes with 0 restarts. Its log had no is connecting or ObjectDisposed lines.
  • Probe check, run in the pod: the command returns 0 for port 7777 and 1 for 7778. /proc/net/tcp shows 00000000:1E61 00000000:0000 0A.
  • tModLoader image: a one-off pod shows sh, grep -E, /proc/net/tcp and /proc/net/tcp6 are all present. A full tModLoader boot test was not possible, because the image exits without an uploaded modpack (see the note below).
  • Precedent: exec probes are already used by nuclear-option and minecraft-java.
  • Both test servers were deleted afterwards.

Separate issue found while testing (not fixed here)

The tmodloader template's MODPACK config field has no default and is not marked required. The image exits ("Modpack name was not provided", or "Modpack was not detected" when no modpack is uploaded), so a fresh tModLoader server crash-loops until a modpack is uploaded. The tModLoader versions on the terraria template behave the same way.

Follow-up in Gameplane

ValgulNecron/Gameplane#551 bumps the modules pointer to this branch and mirrors the probe in the Terraria bot e2e fixture. Please merge this PR with a merge commit (not squash or rebase), so the pinned SHA stays on main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NsN6bnAMRM9XQtrTQ6KC7U

The Terraria server crashes with an ObjectDisposedException in
Netplay.ServerLoop when a client connects and closes at once, which is
exactly what the kubelet's tcpSocket readiness probe does every 10 s. On
the kubelab live sweep the pod restarted 5 times in 6 minutes, and a crash
during world generation left the restart stuck at "Choose World:".

Both templates now declare no probe, like dont-starve-together; the
operator then sets none on the game container. terraria 2.2.1 -> 2.2.2,
tmodloader 1.0.0 -> 1.0.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NsN6bnAMRM9XQtrTQ6KC7U
Signed-off-by: valgulnecron <39313199+ValgulNecron@users.noreply.github.com>
…of dropping it

Removing the readiness probe stopped the crash loop but left the pod Ready
before the server could take players. Bring the probe back as an exec probe
that reads /proc/net/tcp for a socket LISTENing on 7777 (0x1E61): it never
opens a connection, so it cannot trigger the ObjectDisposedException that
the kubelet's tcpSocket connect-and-close caused.

Verified on kubelab: a vanilla server with this probe stayed Ready for 6.5
minutes with 0 restarts and no connection in its log (the tcpSocket probe
gave 5 restarts in 6 minutes); the probe returns 0 for port 7777 and 1 for
7778; the tModLoader image has sh, grep -E and /proc/net/tcp{,6}.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NsN6bnAMRM9XQtrTQ6KC7U
Signed-off-by: valgulnecron <39313199+ValgulNecron@users.noreply.github.com>
@ValgulNecron ValgulNecron changed the title fix(terraria,tmodloader): drop the tcpSocket readiness probe fix(terraria,tmodloader): probe readiness without connecting Oct 5, 2026
@ValgulNecron
ValgulNecron merged commit afbcf1f into main Oct 5, 2026
1 check passed
@ValgulNecron
ValgulNecron deleted the fix/terraria-readiness-probe branch October 5, 2026 01:45
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