Pass --sql-db to URI builder if given#182
Open
ioSpark wants to merge 1 commit into
Open
Conversation
|
|
edmharlaoag
added a commit
to edmharlaoag/knife-ec-backup
that referenced
this pull request
Jun 3, 2026
knife ec backup --with-user-sql ignored the configured PostgreSQL endpoint and database: it always connected to localhost:5432 and to a database named after the SQL user. External-PostgreSQL deployments failed with PG::ConnectionBad, and servers whose database name differs from the SQL user name could not be backed up at all. Two distinct problems in EcKeyBase: 1. Host/port were never derived from chef-server-running.json, and the --sql-host/--sql-port options carried hardcoded localhost/5432 defaults that masked any other value. Drop those defaults, source sql_host/sql_port from private_chef.postgresql.vip/port in load_config_from_file! (||=, so an explicit flag still wins), and fall back to localhost:5432 in #db when unset. 2. The database name was resolved (from --sql-db or autoconfigure) but never written to the connection URI, so it was silently ignored and PostgreSQL fell back to a user-named database. #db now sets the URI path from config[:sql_db]. This follows the one-line fix proposed by @ioSpark in chef#182. Adds specs for running-config host/port adoption, CLI precedence, and the database name appearing in the connection URI. Refs chef#181, chef#182, chef/chef-server#2907 Signed-off-by: edmharlaoag <laoagedmhar@gmail.com>
Previously `--sql-db` did not take effect as this was missing Obvious fix.
b12d187 to
88d797a
Compare
jaymzh
pushed a commit
to edmharlaoag/knife-ec-backup
that referenced
this pull request
Jun 11, 2026
knife ec backup --with-user-sql ignored the configured PostgreSQL endpoint and database: it always connected to localhost:5432 and to a database named after the SQL user. External-PostgreSQL deployments failed with PG::ConnectionBad, and servers whose database name differs from the SQL user name could not be backed up at all. Two distinct problems in EcKeyBase: 1. Host/port were never derived from chef-server-running.json, and the --sql-host/--sql-port options carried hardcoded localhost/5432 defaults that masked any other value. Drop those defaults, source sql_host/sql_port from private_chef.postgresql.vip/port in load_config_from_file! (||=, so an explicit flag still wins), and fall back to localhost:5432 in #db when unset. 2. The database name was resolved (from --sql-db or autoconfigure) but never written to the connection URI, so it was silently ignored and PostgreSQL fell back to a user-named database. #db now sets the URI path from config[:sql_db]. This follows the one-line fix proposed by @ioSpark in chef#182. Adds specs for running-config host/port adoption, CLI precedence, and the database name appearing in the connection URI. Refs chef#181, chef#182, chef/chef-server#2907 Signed-off-by: edmharlaoag <laoagedmhar@gmail.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.




Description
Previously
--sql-dbdid not take effect as the db name was missing from the postgres URI.Related Issue
#181
Types of changes
Checklist:
Gemfile.lockhas changed, I have used--conservativeto do it and included the full output in the Description above.