Skip to content
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

Calculate Postgres HBA rules in the controller #4111

Merged
merged 3 commits into from
Mar 4, 2025

Conversation

cbandy
Copy link
Member

@cbandy cbandy commented Feb 28, 2025

The controller assigned mandatory and default rules but did nothing with rules defined in the spec.

The patroni.DynamicConfiguration function was interpreting its schemaless fields while also combining Postgres HBA rules from elsewhere. Its tests were long and complicated.

  1. Postgres HBA rules are now extracted from the schemaless Patroni field in their own function with its own tests.
  2. The PostgresCluster controller now creates a single set of HBA rules based on all the fields of the PostgresCluster spec.
  3. The DynamicConfiguration function is simpler (19 lines, 18% smaller) and easier to test.

Checklist:

  • Have you added an explanation of what your changes do and why you'd like them to be included?
  • Have you updated or added documentation for the change, as applicable?
  • Have you tested your changes on all related environments with successful results, as applicable?
    • Have you added automated tests?

Type of Changes:

  • Testing enhancement

@cbandy cbandy marked this pull request as ready for review February 28, 2025 20:59
We don't use it, and how to quote/escape it has been underspecified for years.
The controller assigned mandatory and default rules but did nothing
with rules defined in the spec.

The patroni.DynamicConfiguration function was interpreting its
schemaless fields while also combining Postgres HBA rules from
elsewhere. Its tests were long and complicated.

 1. Postgres HBA rules are now extracted from the schemaless Patroni
    field in their own function with its own tests.

 2. The PostgresCluster controller now creates a single set of HBA rules
    based on all the fields of the PostgresCluster spec.

 3. The DynamicConfiguration function is simpler (19 lines, 18% smaller)
    and easier to test.
spec: `{
patroni: {
dynamicConfiguration: {
postgresql: {
pg_hba: [custom],
pg_hba: [calculated, elsewhere],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't come through?

Copy link
Member Author

@cbandy cbandy Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't do that work anymore. Now,

  1. patroni.PostgresHBAs reads them out,
  2. postgrescluster.generatePostgresHBAs stitches them together in the right order, then passes that result
  3. here, to patroni.DynamicConfiguration which spells them correctly as input to Patroni.

Copy link
Contributor

@dsessler7 dsessler7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cbandy cbandy merged commit 44a03ed into CrunchyData:main Mar 4, 2025
19 checks passed
@cbandy cbandy deleted the hba-rules branch March 4, 2025 21:38
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.

3 participants