-
Notifications
You must be signed in to change notification settings - Fork 91
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?
Changes from all commits
dcebb23
38a8227
ca497d4
e60b95e
30f0927
ec89b16
558d0f1
13973cd
7ea7670
24a83a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -207,6 +207,7 @@ func (c *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex | |||||||||||||
| Replication: new(bool), | ||||||||||||||
| BypassRls: new(bool), | ||||||||||||||
| }, | ||||||||||||||
| ConnectionLimit: new(int32), | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| query := "SELECT " + | ||||||||||||||
|
|
@@ -259,6 +260,8 @@ func (c *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex | |||||||||||||
| } | ||||||||||||||
| cr.Status.AtProvider.ConfigurationParameters = observed.ConfigurationParameters | ||||||||||||||
|
|
||||||||||||||
| cr.Status.AtProvider.ConnectionLimit = observed.ConnectionLimit | ||||||||||||||
|
|
||||||||||||||
| _, pwdChanged, err := c.getPassword(ctx, cr) | ||||||||||||||
| if err != nil { | ||||||||||||||
| return managed.ExternalObservation{}, err | ||||||||||||||
|
|
@@ -405,10 +408,11 @@ func (c *external) Update(ctx context.Context, mg resource.Managed) (managed.Ext | |||||||||||||
| // Update state to reflect the current configuration parameters | ||||||||||||||
| cr.Status.AtProvider.ConfigurationParameters = cr.Spec.ForProvider.ConfigurationParameters | ||||||||||||||
| } | ||||||||||||||
| cl := cr.Spec.ForProvider.ConnectionLimit | ||||||||||||||
| if cl != nil { | ||||||||||||||
| newCl := cr.Spec.ForProvider.ConnectionLimit | ||||||||||||||
| currCl := cr.Status.AtProvider.ConnectionLimit | ||||||||||||||
| if (newCl != nil && currCl != nil) && (int64(*currCl) != int64(*newCl)) { | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the three casts to int64? Could we simply drop then?
Comment on lines
+411
to
+413
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||||||||||||||
| if err := c.db.Exec(ctx, xsql.Query{ | ||||||||||||||
| String: fmt.Sprintf("ALTER ROLE %s CONNECTION LIMIT %d", crn, int64(*cl)), | ||||||||||||||
| String: fmt.Sprintf("ALTER ROLE %s CONNECTION LIMIT %d", crn, int64(*newCl)), | ||||||||||||||
| }); err != nil { | ||||||||||||||
| return managed.ExternalUpdate{}, errors.Wrap(err, errUpdateRole) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
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!