MM-68316: add builtin DB readiness check mode#459
Conversation
Adds an opt-in `spec.database.readinessCheck.mode` field on the
Mattermost CR. When set to "builtin", the operator constructs the
DB-readiness init container from the same Mattermost image as the
main container and runs `mattermost db ping --timeout=...` instead
of pulling postgres:13. The default ("external"/unset) preserves
today's postgres:13 + pg_isready behaviour.
This unblocks air-gapped deployments that cannot mirror postgres:13
into their internal registry. A future operator release will
deprecate and eventually flip the default once the Mattermost floor
version ships `mattermost db ping`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@nickmisasi: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsI understand the commands that are listed here |
📝 WalkthroughWalkthroughAdds configurable database readiness checks: new DatabaseReadinessCheck type (Mode: external|builtin, optional Timeout), CRD/schema updates, deepcopy support, init-container selection for builtin (in-image mattermost db ping) vs external checks, and corresponding tests and docs updates. ChangesDatabase Readiness Check
Sequence DiagramsequenceDiagram
participant Operator as Operator / Controller
participant Spec as Mattermost Spec
participant Secret as DB Secret
participant Pod as Deployment / Pod
participant Init as Init Container
participant DB as Database
Operator->>Spec: Read spec.database.readinessCheck.mode
alt mode == "builtin"
Operator->>Secret: Read MM_CONFIG and datasource
Operator->>Pod: Create init container using Mattermost image
Pod->>Init: Start /mattermost/bin/mattermost db ping --timeout=<duration>
Init->>DB: Connect and ping database
else mode == "external" or unset
Operator->>Secret: Check DB_CONNECTION_CHECK_URL
alt DB_CONNECTION_CHECK_URL present
Operator->>Pod: Create external readiness-check init container
Pod->>Init: Run external check image
Init->>DB: Check via URL
else DB_CONNECTION_CHECK_URL absent
Operator->>Pod: Do not add readiness-check init container
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@config/crd/bases/installation.mattermost.com_mattermosts.yaml`:
- Around line 247-253: Add a validation schema for readinessCheck.timeout so
invalid duration strings are rejected at CRD validation time: update the CRD's
schema for the readinessCheck object (the readinessCheck.timeout property) to
include a validation pattern (regex) and/or minLength that matches the expected
Kubernetes duration format (e.g., number+unit like "5m", "30s", "1h") and set
type: string; this will ensure invalid values are rejected by the API server
instead of failing later during reconciliation. Reference the
readinessCheck.timeout property in the CRD schema and add the pattern constraint
and an appropriate description update.
In `@docs/mattermost_v1beta1_crd.md`:
- Line 232: Fix the typo in the CRD docs for the `dedicatedJobServer` field by
replacing "recieve" with the correct spelling "receive" in the description text
for `dedicatedJobServer` in docs/mattermost_v1beta1_crd.md (look for the table
row containing `dedicatedJobServer` and the phrase "will recieve no user
traffic"). Ensure the updated sentence reads "will receive no user traffic"
exactly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1cb4ca0d-1d4b-497d-a4c2-46c1f9d4e615
📒 Files selected for processing (9)
apis/mattermost/v1beta1/mattermost_types.goapis/mattermost/v1beta1/zz_generated.deepcopy.goconfig/crd/bases/installation.mattermost.com_mattermosts.yamldocs/mattermost-operator/mattermost-operator.yamldocs/mattermost_v1beta1_crd.mdpkg/mattermost/database_external.gopkg/mattermost/database_external_test.gopkg/mattermost/mattermost.gopkg/mattermost/mattermost_v1beta_test.go
- Add kubebuilder pattern validation to readinessCheck.timeout so invalid duration strings are rejected at CRD admission rather than at reconcile time. - Fix "recieve" -> "receive" typo in JobServer.DedicatedJobServer godoc; regenerated CRD docs and bundled YAMLs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Adds an opt-in
spec.database.readinessCheck.modefield on the Mattermost CR. When set tobuiltin, the operator builds the DB-readiness init container from the same Mattermost image as the main container and runsmattermost db ping --timeout=...instead of pullingpostgres:13. The default (external/ unset) preserves today'spostgres:13+pg_isreadybehaviour, so existing CRs are unaffected.This unblocks air-gapped deployments that cannot mirror
postgres:13into their internal registry — they can now reuse the Mattermost image they already have. A future operator release will deprecate, then flip, the default once the Mattermost floor version shipsmattermost db ping. Companion change: mattermost/mattermost MM-68316.Ticket Link
Fixes https://mattermost.atlassian.net/browse/MM-68316
Documentation
Release Note