-
-
Notifications
You must be signed in to change notification settings - Fork 231
pg bouncer upgrade #1572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pg bouncer upgrade #1572
Conversation
|
Next steps are to work on the tests for this upgrade + default settings. |
f6b6c7a to
bbd1190
Compare
|
No config to add/change here as defaults are good; customisable config can be added to API later. Errors occur when testing in |
|
@encima re-ran the failed test. |
|
Tests for pgbouncer still to be written:
|
65c9561 to
074c41a
Compare
074c41a to
78fd845
Compare
939694e to
d147824
Compare
|
Noticed the make step seems to make source and docs now; fixing |
|
Benefit of 1.240 is that we do not need to change the default settings as max_prepared_statements is enabled by default and set to 200; we can expose configs later and optimise by instance Only clients connecting with prepared statements enabled (i.e. |
WalkthroughAdds PgBouncer 1.25.1: a Nix derivation and package export, updates Ansible to install in stage2_nix builds and add pandoc/python3 deps, and extends tests to resolve expected PgBouncer version and binary path. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Test as "Testinfra"
participant Vars as "Ansible vars.yml / nix/pgbouncer.nix"
participant Nix as "Nix build / package registry"
participant Ansible as "Ansible playbook"
participant Host as "Target host / pgbouncer"
rect rgba(200,230,255,0.5)
Test->>Vars: load_expected_pgbouncer_version()
Vars-->>Test: return version (1.25.1)
end
rect rgba(200,255,200,0.5)
Ansible->>Nix: (stage2_nix) request pgbouncer package
Nix-->>Ansible: provide pgbouncer derivation/profile
end
rect rgba(255,230,200,0.5)
Ansible->>Host: install pgbouncer (pandoc, python3 deps)
Host-->>Ansible: installed
Ansible->>Host: create config (guarded by nixpkg_mode)
Host-->>Ansible: config created
end
rect rgba(230,200,255,0.5)
Test->>Host: verify binary at PGBOUNCER_BINARY matches EXPECTED_PGBOUNCER_VERSION
Host-->>Test: version check result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ansible/tasks/setup-pgbouncer.yml (1)
51-51: Typo:nolignshould benologin.The shell path
/usr/sbin/nolignappears to be a typo. This will cause user creation to fail or set an invalid shell.🐛 Proposed fix
- shell: '/usr/sbin/nolign' + shell: '/usr/sbin/nologin'
🤖 Fix all issues with AI agents
In `@ansible/tasks/setup-pgbouncer.yml`:
- Line 80: Change the task conditional that currently reads "when: nixpkg_mode"
so the placeholder files are created for all relevant build modes; update the
when expression to "debpkg_mode or nixpkg_mode or stage2_nix" (so downstream
lineinfile tasks that omit create and the subsequent file permission tasks will
find the files). Edit the task containing the current when: nixpkg_mode
condition (the placeholder file creation task) to use the expanded boolean
expression to match the parent import and ensure compatibility with the
lineinfile (lines ~103-106) and permission tasks (lines ~108-116).
In `@nix/pgbouncer.nix`:
- Around line 1-52: The pgbouncer derivation currently lists c-ares in
buildInputs but never enables it in configureFlags, so either remove c-ares from
the buildInputs list or enable it by adding the "--with-cares" configure flag;
locate the stdenv.mkDerivation block for pgbouncer and update the buildInputs
array (remove c-ares) if you don't want c-ares support, or append "--with-cares"
to the configureFlags expression (alongside the existing "--with-systemd"
option) if you do want c-ares DNS resolver enabled.
In `@testinfra/test_ami_nix.py`:
- Around line 174-175: The module declares EXPECTED_PGBOUNCER_VERSION
(initialized by load_expected_pgbouncer_version()) and PGBOUNCER_BINARY but
never uses them; either remove these unused module-level constants or add tests
that exercise them. To fix: if PgBouncer behavior is not needed, delete
EXPECTED_PGBOUNCER_VERSION, PGBOUNCER_BINARY and the call to
load_expected_pgbouncer_version() to avoid import-time work; otherwise implement
tests (e.g., test_pgbouncer_binary_exists and test_pgbouncer_version_matches)
that reference PGBOUNCER_BINARY and EXPECTED_PGBOUNCER_VERSION and validate the
binary exists and its version matches load_expected_pgbouncer_version() (using
subprocess or fixture helpers). Ensure references use the exact symbol names
EXPECTED_PGBOUNCER_VERSION, PGBOUNCER_BINARY, and
load_expected_pgbouncer_version() so future reviewers can locate the change.
🧹 Nitpick comments (1)
testinfra/test_ami_nix.py (1)
150-171: Consider more robust YAML/Nix parsing.The current string-based parsing is fragile—it doesn't handle quoted values consistently, comments on the same line, or whitespace variations. For YAML, consider using
yaml.safe_load()(already have PyYAML via boto3 dependencies). For Nix, regex would be more reliable.♻️ Optional: Use YAML parser for vars.yml
def load_expected_pgbouncer_version() -> str: + import yaml repo_root = Path(__file__).resolve().parent.parent ansible_vars = repo_root / "ansible" / "vars.yml" if ansible_vars.exists(): with ansible_vars.open() as f: - for raw_line in f: - line = raw_line.strip() - if line.startswith("pgbouncer_release:"): - return line.split(":", 1)[1].strip().strip('"') + data = yaml.safe_load(f) + if data and "pgbouncer_release" in data: + return str(data["pgbouncer_release"]) nix_file = repo_root / "nix" / "pgbouncer.nix" if nix_file.exists(): with nix_file.open() as f: - for raw_line in f: - line = raw_line.strip() - if line.startswith("version ="): - value = line.split("=", 1)[1].strip() - return value.strip(";").strip('"') + import re + content = f.read() + match = re.search(r'version\s*=\s*"([^"]+)"', content) + if match: + return match.group(1) raise RuntimeError( "Could not determine expected PgBouncer version from configuration files" )
| # Full version strings for each major version | ||
| postgres_release: | ||
| postgresorioledb-17: "17.6.0.029-orioledb" | ||
| postgres17: "17.6.1.072" | ||
| postgres15: "15.14.1.072" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to bump these versions
What kind of change does this PR introduce?
pgbouncer needs updating for for prepared statement support, addressing incorporation of upgrades
This PR updates the version to 1.24.1
This PR performs the upgrade, repackages the build of pgbouncer from source in a nix package, and will cover automated testing in testinfra as well.
Summary by CodeRabbit
New Features
Updates
Behavioral
Tests
✏️ Tip: You can customize this high-level summary in your review settings.