Repository navigation
Conversation
upToDate compared ConnectionLimit and the privilege fields as pointers. lateInit copies the observed pointers into the spec once, but every later reconcile arrives with fresh pointers from the API server, so an unchanged Role was never up to date and Update re-issued ALTER ROLE CONNECTION LIMIT on every poll. The fields are compared by value now, in the cluster and the namespaced controller. Fixes crossplane-contrib#487 Signed-off-by: Youssef Omar Bouden <youssef.bouden2002@gmail.com>
|
+1, we hit the same thing on v0.15.0 (AWS RDS PostgreSQL), and the fix in #488 / #468 matches what we found. We noticed it after enabling pgaudit ( It also hits roles that set neither We'd be glad to see this merged and released. |
| @@ -434,28 +434,28 @@ func (c *external) Delete(ctx context.Context, mg *v1alpha1.Role) (managed.Exter | |||
| } | |||
|
|
|||
| func upToDate(observed *v1alpha1.RoleParameters, desired *v1alpha1.RoleParameters) bool { | |||
There was a problem hiding this comment.
I feel it's better to do cmp.Equal in observed vs desired with IgnoreFields (the ones that Observe never fills) plus SortSlices to avoid spurious diffs:
func upToDate(observed *v1alpha1.RoleParameters, desired *v1alpha1.RoleParameters) bool {
return cmp.Equal(
observed,
desired,
cmpopts.IgnoreFields(v1alpha1.RoleParameters{}, "PasswordSecretRef", "PasswordRotationTrigger"),
cmpopts.SortSlices(func(o, d v1alpha1.RoleConfigurationParameter) bool { return o.Name < d.Name })
)
}There was a problem hiding this comment.
but IIRC this will be implemented from crossplane/crossplane-runtime (see http://github.com/crossplane/crossplane-runtime/pull/945)
There was a problem hiding this comment.
Thanks, that is cleaner. Done in 265791d for both controllers, the two TestObserve cases still cover it.
On #945: as I read it, it adds an UpToDate condition that surfaces whatever Observe returns in ResourceUpToDate, so the comparison itself stays in the provider and this fix is still needed for it to report true.
| } | ||
|
|
||
| func upToDate(observed *namespacedv1alpha1.RoleParameters, desired *namespacedv1alpha1.RoleParameters) bool { | ||
| if observed.ConnectionLimit != desired.ConnectionLimit { |
Signed-off-by: Youssef Omar Bouden <youssef.bouden2002@gmail.com>
Description of your changes
upToDatein the PostgreSQL Role controllers comparedConnectionLimitand the seven privilege fields as pointers.lateInitcopies the observed pointers into the spec once, but every later reconcile arrives with fresh pointers from the API server, so an unchanged Role was never up to date andUpdatere-issuedALTER ROLE ... CONNECTION LIMITon every poll, which is what breaks RDS Blue/Green deployments in #487. The fields are now compared by value withcmp.Equal, in the cluster and the namespaced controller.Fixes #487
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
Two
TestObservecases in each controller: the observed limit and the spec limit equal through different pointers now reportResourceUpToDate: true, and a different limit still reportsfalse. The first case fails onmaster.make reviewablepasses (generate, tidy, golangci-lint with 0 issues, unit tests).