Repository navigation
Splice user_hba.conf by data directory major for PG 16-18 - #76
Merged
Merged
Conversation
PostgreSQL 16+ scripts wrote `include_if_exists "/etc/config/user_hba.conf"` into pg_hba.conf unconditionally. A major upgrade from 15 restarts the pod on the 16 image before pg_upgrade runs, so the 16 start script rewrote the 15 data directory's pg_hba.conf with that include. The 15 server cannot parse it, and pg_upgrade failed with "could not load pg_hba.conf". Choose the form from $PGDATA/PG_VERSION: 16 or newer keeps the live include, older data directories get the file spliced in with cat, as the 15 scripts already do. A missing PG_VERSION (fresh data directory) uses the image major. Signed-off-by: souravbiswassanto <saurov@appscode.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
PG 16–18 role scripts write
include_if_exists "/etc/config/user_hba.conf"intopg_hba.confunconditionally. A major upgrade from 15 restarts the pod on the 16 image beforepg_upgraderuns. The 16 start script then rewrites the 15 data directory'spg_hba.confwith that include, and the 15 server cannot parse it:Observed live:
15.12-bookworm→16.12-bookwormfails inpg_upgrade.16.x→17.xand17.x→18.xsucceed, since the old server is 16+.Change
Each affected script gets a
kubedb_write_user_hbahelper that chooses the form from$PGDATA/PG_VERSION:include_if_exists(live reload, unchanged behaviour)/etc/config/user_hba.confin withcat, as the 15 scripts already doPG_VERSION(fresh data directory): use this image's major, so fresh pods behave as beforeTouched:
16|17|18×primary/start.sh,standby/run.sh,standby/remote-replica.sh(9 files, 45 call sites). The 15 and older scripts are unchanged.Testing
bash -npasses on all 9 files.PG_VERSION,PG_VERSION=15,PG_VERSIONequal to the image major, andPG_VERSION=15with no user rules. All outputs as expected.Rollout / not included
PostgresVersioninitContainerentries pointed at it. This PR does not change the catalog.postgreshbaIncludeSupported()still keys off the CR version. It is consistent at steady state; the restart at the end of a major upgrade re-runs the splice.pg_hba.conf) need manual recovery.