Skip to content

Pass --sql-db to URI builder if given#182

Open
ioSpark wants to merge 1 commit into
chef:mainfrom
ioSpark:fix/missing-sql-db-config
Open

Pass --sql-db to URI builder if given#182
ioSpark wants to merge 1 commit into
chef:mainfrom
ioSpark:fix/missing-sql-db-config

Conversation

@ioSpark

@ioSpark ioSpark commented Feb 9, 2024

Copy link
Copy Markdown

Description

Previously --sql-db did not take effect as the db name was missing from the postgres URI.

Related Issue

#181

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • If Gemfile.lock has changed, I have used --conservative to do it and included the full output in the Description above.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin. (obvious fix in this case)

@ioSpark ioSpark requested review from a team as code owners February 9, 2024 12:18
@sonarqubecloud

sonarqubecloud Bot commented Feb 9, 2024

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@sonarqubecloud

Copy link
Copy Markdown

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.
@jaymzh jaymzh force-pushed the fix/missing-sql-db-config branch from b12d187 to 88d797a Compare June 11, 2026 18:26
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant