Files
mattermost/server/cmd
3570814ddd MM-68316: add mattermost db ping subcommand (#36406)
* MM-68316: add `mattermost db ping` subcommand

Adds a one-shot DB-readiness CLI that opens a connection to the
configured PostgreSQL DSN and exits 0 when reachable. Honours
--timeout (default 5m) and --retry-interval (default 2s); reads the
DSN from --config / MM_CONFIG / MM_SQLSETTINGS_DATASOURCE matching
the existing `db init`/`db migrate` semantics.

Intended primarily as an init-container readiness check for the
mattermost-operator, removing its dependency on a separate
postgres:13 image (relevant for air-gapped deployments).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* MM-68316: address PR feedback (sanitize ping retry log)

Drop mlog.Err(err) from the per-attempt "Waiting for database" log line in
pingWithRetry: lib/pq error strings can echo DSN fragments back at operators
when DSN parsing fails. Replace with a non-sensitive status field. Also
clarifies the TestDBPingInvalidDSN comment to reflect actual lib/pq behavior
(parse error surfaces at PingContext, not Open, so the retry loop treats it
as transient — desired for a readiness probe).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* MM-68316 Preserve safe db ping DSN errors

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-05-21 18:46:52 +00:00
..