Skip to content

feat(cmangos-ptr): dedicated MariaDB for PTR [DO NOT MERGE — gated]#4108

Draft
xunholy wants to merge 1 commit into
mainfrom
feat/cmangos-ptr-dedicated-db
Draft

feat(cmangos-ptr): dedicated MariaDB for PTR [DO NOT MERGE — gated]#4108
xunholy wants to merge 1 commit into
mainfrom
feat/cmangos-ptr-dedicated-db

Conversation

@xunholy

@xunholy xunholy commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Caution

DO NOT MERGE. Gated on two external prerequisites (below). Kept as a draft so it can't merge accidentally. Merging without these breaks all PTR logins and/or PTR DB init.

What

Moves PTR's ptrmangos / ptrcharacters / ptrlogs onto a dedicated MariaDB (cmangos-ptr-database). The shared cmangos-database keeps only the auth DB (classicrealmd) + live's game DBs. This removes the world/character connection + buffer-pool contention that OOM-killed the shared instance and broke live logins on 2026-06-18.

classicrealmd (realmlist + accounts + session keys) stays shared, so single-auth / both-realms-visible / GM-flags-carry-over is unchanged. PTR's mangosd becomes the only cross-instance client (login → shared, world/char/logs → its own box).

⛔ Prerequisites (do both before un-drafting)

  1. Fork image — add MANGOS_REALMD_DBHOST to the entrypoint in xunholy/cmangos-classic so the login DB can be on a different host than world/char/logs, defaulting to MANGOS_DBHOST (so live/realmd are unaffected). Build + pin the PTR image. Without it, PTR login lookups hit the new instance, find no classicrealmd, and every PTR login fails.
  2. 1Password — add a DB_ROOT_PASSWORD field to the cmangos item. The new cmangos-ptr-database-creds ExternalSecret needs it for first-init root. Scoped to a dedicated secret so a missing key can't disrupt live auth.

Changes

  • New cmangos-ptr-database app: HelmRelease (mariadb:12.2), PVC (10Gi), dedicated ExternalSecret, ks.yaml; registered in the ArtifactGenerator + cluster-00 overlay. No VolSync — PTR data is reconstructible via the db-init Job.
  • cmangos-ptr: MANGOS_DBHOSTcmangos-ptr-database; add MANGOS_REALMD_DBHOST=cmangos-database; wait-db waits for both instances; dependsOn: cmangos-ptr-database (it owns the creds secret the Job uses).
  • db-init Job → cross-instance clone: read live as the app user, create/grant/restore on the new instance as root; *_db_version rows copied via single-table dumps (cross-instance INSERT…SELECT can't work anymore).
  • Shared cmangos-database-creds / externalsecret-database.yaml untouched.

Cutover (once prerequisites are met)

  1. Ship + PTR-pin the image (prereq 1); confirm live still boots (default-fallback path).
  2. Add DB_ROOT_PASSWORD to 1Password (prereq 2).
  3. Mark ready + merge → cmangos-ptr-database comes up; db-init clones ptr* onto it; PTR mangosd rolls onto the new instance.
  4. Verify a GM login + a bot spawn on PTR.
  5. Reclaim: DROP DATABASE ptrmangos/ptrcharacters/ptrlogs on the shared cmangos-database — this is what actually relieves the shared instance.

Rollback before step 5: revert the cmangos-ptr env change (points back at cmangos-database, old ptr* still there). Instant, no data loss.

Validation done

  • kustomize build new app dir → ExternalSecret + HelmRelease + PVC render
  • kustomize build --load-restrictor LoadRestrictionsNone overlays/cluster-00 → 153 docs
  • yamllint + full pre-commit suite → passed
  • Coherence: realm-row-migration still writes shared classicrealmd; db-init admins new instance / reads live

https://claude.ai/code/session_01T37E9UJr2ymcGhQoV8Yq93

Splits PTR's world/characters/logs onto a dedicated MariaDB
(cmangos-ptr-database), leaving the shared cmangos-database hosting only
the auth DB (classicrealmd) + live's game DBs. This removes the
connection/buffer contention that OOM-killed the shared instance and
broke live logins on 2026-06-18. realmlist + accounts stay shared, so
the single-auth / both-realms UX is unchanged.

GATED on two external prerequisites — DO NOT MERGE until both are done:
  1. Image: add MANGOS_REALMD_DBHOST support to the entrypoint in the
     fork xunholy/cmangos-classic (login DB on a different host than
     world/char/logs), build + pin the PTR image. Without it, PTR login
     lookups hit the new instance (no classicrealmd) and all PTR logins
     fail.
  2. 1Password: add a DB_ROOT_PASSWORD field to the `cmangos` item. The
     new cmangos-ptr-database-creds ExternalSecret needs it for first-init
     root. Scoped to a dedicated secret so a missing key can't disrupt
     live auth (shared cmangos-database-creds is untouched).

Changes:
- new cmangos-ptr-database app (HelmRelease, PVC, dedicated ExternalSecret,
  ks) + ArtifactGenerator source + overlay registration. No VolSync: PTR
  data is reconstructible via the db-init Job.
- cmangos-ptr: MANGOS_DBHOST -> cmangos-ptr-database, add
  MANGOS_REALMD_DBHOST=cmangos-database, wait-db waits for both instances,
  dependsOn cmangos-ptr-database (owns the creds secret the Job uses).
- db-init Job is now a cross-instance clone: read live as the app user,
  create/grant/restore on the new instance as root; *_db_version rows
  copied via single-table dumps instead of cross-instance INSERT...SELECT.

Cutover + rollback steps are in the PR description.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 24, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
k8s-gitops 39999f1 Commit Preview URL

Branch Preview URL
Jun 24 2026, 11:25 PM

@unholy-bot

unholy-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor
--- kubernetes/apps/overlays/cluster-00 Kustomization: flux-system/cluster ArtifactGenerator: flux-system/k8s-gitops

+++ kubernetes/apps/overlays/cluster-00 Kustomization: flux-system/cluster ArtifactGenerator: flux-system/k8s-gitops

@@ -72,12 +72,17 @@

   - copy:
     - from: '@repo/apps/base/game-servers/cmangos-ptr/app/'
       to: '@artifact/apps/base/game-servers/cmangos-ptr/app/'
     name: cmangos-ptr
     originRevision: '@repo'
   - copy:
+    - from: '@repo/apps/base/game-servers/cmangos-ptr-database/app/'
+      to: '@artifact/apps/base/game-servers/cmangos-ptr-database/app/'
+    name: cmangos-ptr-database
+    originRevision: '@repo'
+  - copy:
     - from: '@repo/apps/base/game-servers/cmangos-realmd/app/'
       to: '@artifact/apps/base/game-servers/cmangos-realmd/app/'
     name: cmangos-realmd
     originRevision: '@repo'
   - copy:
     - from: '@repo/apps/base/crossplane-system/crossplane/providers/'
--- kubernetes/apps/overlays/cluster-00 Kustomization: flux-system/cluster Kustomization: game-servers/cmangos-ptr

+++ kubernetes/apps/overlays/cluster-00 Kustomization: flux-system/cluster Kustomization: game-servers/cmangos-ptr

@@ -8,12 +8,15 @@

     kustomize.toolkit.fluxcd.io/namespace: flux-system
   name: cmangos-ptr
   namespace: game-servers
 spec:
   decryption:
     provider: sops
+  dependsOn:
+  - name: cmangos-ptr-database
+    namespace: game-servers
   interval: 30m
   path: ./apps/base/game-servers/cmangos-ptr/app
   prune: true
   retryInterval: 1m
   sourceRef:
     kind: ExternalArtifact
--- kubernetes/apps/overlays/cluster-00 Kustomization: flux-system/cluster Kustomization: game-servers/cmangos-ptr-database

+++ kubernetes/apps/overlays/cluster-00 Kustomization: flux-system/cluster Kustomization: game-servers/cmangos-ptr-database

@@ -0,0 +1,30 @@

+---
+apiVersion: kustomize.toolkit.fluxcd.io/v1
+kind: Kustomization
+metadata:
+  labels:
+    gitops.owncloud.ai/defaults: disabled
+    kustomize.toolkit.fluxcd.io/name: cluster
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: cmangos-ptr-database
+  namespace: game-servers
+spec:
+  decryption:
+    provider: sops
+  dependsOn:
+  - name: onepassword
+    namespace: external-secrets
+  - name: rook-ceph-cluster
+    namespace: rook-ceph
+  interval: 30m
+  path: ./apps/base/game-servers/cmangos-ptr-database/app
+  prune: true
+  retryInterval: 1m
+  sourceRef:
+    kind: ExternalArtifact
+    name: cmangos-ptr-database
+    namespace: flux-system
+  targetNamespace: game-servers
+  timeout: 10m
+  wait: true
+

xunholy added a commit to xunholy/cmangos-classic that referenced this pull request Jun 26, 2026
…HOST) (#28)

The runner entrypoint composed all four mangosd *DatabaseInfo lines from a
single MANGOS_DBHOST, so a world server could not keep its game DBs on one
MariaDB while validating sessions against the shared auth (classicrealmd)
DB on another. Add MANGOS_REALMD_DBHOST: the login DB host for mangosd's
LoginDatabaseInfo (and realmd's, which only uses the login DB). It defaults
to MANGOS_DBHOST in init_runner, so any deployment that doesn't set it —
including realmd, which always runs on the auth instance — renders byte for
byte identical config.

Enables the k8s-gitops cmangos-ptr split onto a dedicated MariaDB
(xunholy/k8s-gitops#4108): PTR world/characters/logs move off the shared
instance while login stays shared.

Verified by composing mangosd.conf/realmd.conf against mock env: with the
var set, LoginDatabaseInfo uses the auth host and world/char/logs use the
game host; with it unset, all four resolve to MANGOS_DBHOST as before.
shellcheck clean (no new findings).
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