feat: add wait-for-db init container for bundled PostgreSQL#12
Open
o6uoq wants to merge 1 commit intosequinstream:mainfrom
Open
feat: add wait-for-db init container for bundled PostgreSQL#12o6uoq wants to merge 1 commit intosequinstream:mainfrom
o6uoq wants to merge 1 commit intosequinstream:mainfrom
Conversation
When deploying with the bundled PostgreSQL subchart, Sequin starts before PostgreSQL accepts connections, causing crash-loop restarts on every fresh install. The startup script (start_commands.sh) runs Ecto migrations immediately with no retry logic. Adds a built-in init container that polls pg_isready until the database is reachable. Uses the PostgreSQL subchart image which provides pg_isready. Gated on postgresql.enabled so it does not run when using an external database. New value: waitForDB.enabled (default: true) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When deploying with the bundled PostgreSQL subchart (
postgresql.enabled: true), Sequin starts before PostgreSQL is ready to accept connections. The startup script (start_commands.sh) runs Ecto migrations immediately with no retry logic, causing 3+ crash-loop restarts on every fresh install:Sequin eventually recovers via Kubernetes restart backoff, but this adds unnecessary delay and noise to every deployment.
Fix
Adds a built-in
wait-for-dbinit container that pollspg_isreadyuntil PostgreSQL accepts connections. The init container:pg_isready)sequin.database.host,sequin.database.port,sequin.database.username) for connection detailscontainerSecurityContextsettingsinitContainerspostgresql.enabled— does not run when using an external databaseNew value:
waitForDB.enabled(default:true)Changes
values.yamlwaitForDB.enabledparametertemplates/_helpers.tplsequin.waitForDB.imagehelpertemplates/deployment.yamlNote: PostgreSQL subchart image tag
The current
postgresqlsubchart dependency (16.x.x) references image tag17.6.0-debian-12-r4which may not yet be available on Docker Hub depending on Bitnami's release pipeline timing. During testing we used--set postgresql.image.tag=latestas a workaround. This is a pre-existing issue unrelated to this PR.Testing
helm lint .— passeshelm templatedry-runs:postgresql.enabled=false: no init container renderedwaitForDB.enabled=false: no init container renderedinitContainers: both render,wait-for-dbruns firsthelm template | kubectl apply --dry-run=server— all manifests validhelm install --wait --timeout 10msucceeds, 0 restarts, init container logs: