-
Notifications
You must be signed in to change notification settings - Fork 89
Suppress unnecessary changes to connection limits by checking existing value for PostgreSQL #237
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
base: master
Are you sure you want to change the base?
Conversation
|
@ajcaldera1 Awesome, looking forward to this! Could you squash or rebase it, and make sure you've added DCO for your commit? At the moment the button to run CI is not enabled, I suspect it is related to the fact that this contains 24 commits with many merged 😄 |
…trib#232) Bumps google.golang.org/protobuf from 1.31.0 to 1.33.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-version: 1.33.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
* fix: enable management policies Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com> * fix: linter Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com> * chore: offload lint changes to crossplane-contrib#216 Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com> * chore: revert changes as per peer review Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com> --------- Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com> Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
…#236) * chore: remove duplicate entry of golangci version Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com> * chore: bump up versions for crossplane 1.20 Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com> * chore: restore changes Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com> --------- Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com> Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
…e before mutating it. This will help cut down the number of ALTER ROLE statements that would otherwise needlessly fire for each role. Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
…on of kubectl. Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
Signed-off-by: Alan Caldera <30800723+ajcaldera1@users.noreply.github.com>
| } | ||
| } | ||
|
|
||
| // openDB returns a new database connection |
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.
Could you do this in a separate PR?
Would rather have many smaller PRs which focus on one feature, thanks!
| if cl != nil { | ||
| newCl := cr.Spec.ForProvider.ConnectionLimit | ||
| currCl := cr.Status.AtProvider.ConnectionLimit | ||
| if (newCl != nil && currCl != nil) && (int64(*currCl) != int64(*newCl)) { |
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.
Why the three casts to int64? Could we simply drop then?
| newCl := cr.Spec.ForProvider.ConnectionLimit | ||
| currCl := cr.Status.AtProvider.ConnectionLimit | ||
| if (newCl != nil && currCl != nil) && (int64(*currCl) != int64(*newCl)) { |
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.
The default here is unlimited, represented as -1?
Could we do this instead, or do you see any issues with this?
| newCl := cr.Spec.ForProvider.ConnectionLimit | |
| currCl := cr.Status.AtProvider.ConnectionLimit | |
| if (newCl != nil && currCl != nil) && (int64(*currCl) != int64(*newCl)) { | |
| newCl := ptr.Deref(cr.Spec.ForProvider.ConnectionLimit, -1) | |
| currCl := ptr.Deref(cr.Status.AtProvider.ConnectionLimit, -1) | |
| if currCl != newCl { |
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.
Don't you also need this ptr.Deref-ing in
func upToDate(observed *v1alpha1.RoleParameters, desired *v1alpha1.RoleParameters) bool {
if observed.ConnectionLimit != desired.ConnectionLimit {
return false
}to
func upToDate(observed *v1alpha1.RoleParameters, desired *v1alpha1.RoleParameters) bool {
if ptr.Deref(observed.ConnectionLimit, -1) != ptr.Deref(desired.ConnectionLimit, -1) {
return false
}Could you add some tests for Observe or upToDate covering this case?
Description of your changes
This change checks the state of the connection limit for a Postgres role prior to mutating it. The previous behavior would blindly fire the ALTER ROLE CONNECTION LIMIT -1 even if there was no change. Added test to verify connection limit settings were being properly mutated. Corrected a couple of instances of
kubectlbeing referenced in the tests that caused them to fail, replaced with shell variable${KUBECTL}.Fixes #194
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
Added test to e2e suite to verify the connection limit and review Postgres logs to ensure that no statement had been fired when it was unnecessary.