build/deploy: fix initdb scripts blocked when COCKROACH_USER unset#165785
Open
raajheshkannaa wants to merge 1 commit intocockroachdb:masterfrom
Open
build/deploy: fix initdb scripts blocked when COCKROACH_USER unset#165785raajheshkannaa wants to merge 1 commit intocockroachdb:masterfrom
raajheshkannaa wants to merge 1 commit intocockroachdb:masterfrom
Conversation
When COCKROACH_USER is not set, setup_db() called run_sql_query with only the --certs-dir flag and no -e statements. This caused cockroach sql to open an interactive session, blocking the entrypoint from ever reaching process_init_files. Move the run_sql_query call inside the existing COCKROACH_USER guard so it only executes when there are actual GRANT statements to run. Fixes cockroachdb#110997 Release note (bug fix): Docker entrypoint scripts in /docker-entrypoint-initdb.d/ now execute correctly when the COCKROACH_USER environment variable is not set.
Contributor
|
Merging to
|
|
Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Member
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.
Summary
When
COCKROACH_USERis not set,setup_db()callsrun_sql_querywith no-eflags, which opens an interactive SQL session that blocks the entrypoint indefinitely. This prevents scripts in/docker-entrypoint-initdb.d/from running.The fix moves the
run_sql_querycall inside the existingCOCKROACH_USERguard so it only runs when there are GRANT statements to execute.Fixes #110997
Changes
build/deploy/cockroach.sh: Movedrun_sql_querycall inside the[[ -n "$COCKROACH_USER" ]]conditional insetup_db()Test plan
start-single-node --insecureand a mounted init script, without settingCOCKROACH_USERCOCKROACH_USERset and verify GRANT statements still execute correctly