Skip to content

Add a validated field for Postgres parameters #4060

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

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

cbandy
Copy link
Member

@cbandy cbandy commented Dec 20, 2024

The validation rules of Kubernetes 1.29 (Beta in 1.25) allow for this kind of field.

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:

  • New feature

What is the current behavior (link to any open issues here)?

Postgres parameters are specified under .spec.patroni.dynamicConfiguration.

What is the new behavior (if this is a feature change)?

Postgres parameters can be specified under .spec.config.parameters and .spec.patroni.dynamicConfiguration. The two sections are merged, with the former taking precedence.

Other Information:

Issue: PGO-313

Comment on lines +4694 to +4697
anyOf:
- type: integer
- type: string
x-kubernetes-int-or-string: true
Copy link
Member Author

Choose a reason for hiding this comment

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

📝 a maxLength on this string value may reduce CEL costs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't able to convince controller-gen to do this.

  • Handling of intstr.IntOrString is hard-coded, causing it to ignore markers on a type alias.
  • A local type can be marked x-kubernetes-int-or-string, but that doesn't generate an anyOf: [int, string] schema.

@cbandy cbandy marked this pull request as ready for review February 14, 2025 22:56
//
// +kubebuilder:validation:XValidation:rule=`!has(self.listen_addresses)`,message=`network connectivity is always enabled: listen_addresses`
// +kubebuilder:validation:XValidation:rule=`!has(self.port)`,message=`change port using .spec.port instead`
// +kubebuilder:validation:XValidation:rule=`!has(self.ssl) && !self.exists(k, k.startsWith("ssl_"))`
Copy link
Contributor

Choose a reason for hiding this comment

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

For some of these, are you considering the message to be self evident?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know what to say in these cases. I welcome any suggestions!

Copy link
Contributor

@benjaminjb benjaminjb left a comment

Choose a reason for hiding this comment

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

One question about some CEL checks not having messages, but LGTM, though I guess I still have a broader question re: why we're doing this. (Is this a move towards per-instance settings?)

@cbandy
Copy link
Member Author

cbandy commented Feb 19, 2025

I still have a broader question re: why we're doing this. (Is this a move towards per-instance settings?)

The wide-open field in Patroni is error-prone, and its feedback loop is too slow. These presence-of rules indicate immediately which parameters are allowed/ignored by PGO.

I populated this list by looking at what we assign through the Mandatory field. Can you think of any other parameters we should validate?

I'm now noticing that these rules allow two possible wal_level, but we force it to logical elsewhere. I'll see if I can do anything about that quickly.

@cbandy
Copy link
Member Author

cbandy commented Feb 19, 2025

I'll see if I can do anything about that quickly.

Nope. I'll tighten the validation there for now.

The validation rules of Kubernetes 1.29 (Beta in 1.25) allow for this
kind of field.

Issue: PGO-313
@cbandy cbandy merged commit e4dfdf2 into CrunchyData:main Feb 21, 2025
19 checks passed
@cbandy cbandy deleted the parameters branch February 21, 2025 21:36
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