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

fix(controllers): use custom CriticalAnnotationUpdater #1953

Conversation

wotolom
Copy link
Contributor

@wotolom wotolom commented Nov 20, 2023

Description of your changes

updated description

as suggested by #1953 (comment), this adds a custom implementation of managed.RetryingCriticalAnnotationUpdater - before the change from crossplane/crossplane-runtime#526 - that is used in all controllers.

This aims to revert back the suddenly being effective/working one-time-initialization (of spec.forProvider) based on the AWS Create() response in most many controllers.

Fixes #1951

OG description

This change removes all field/parameter initialization based on the Create() response in ACK generated controllers.
(I did not mark this as breaking, bc this change aims to revert back to pre v0.45 behaviour.)

Fixes #1951

The ACK generated controllers always were using the AWS Create()-Call response to set fields in cr.spec.forProvider and cr.status.atProvider. However, before provider-aws v0.45.0, this did actually never propagate to the resource in the k8s-cluster.
This can be verified by debugging a MR in v0.44 and one in v0.45.
When trying to find out, what change had this effect, respectively why this setting of fields did not propagated to the MR before, I was only able to narrow it down to this commit that bumped - among others - crossplane-runtime to v1.14.1.
Note: This PR comment also was observing this changed behavior, linked to the mentioned commit.

some findings, while debugging:

ToDos before removing Draft-state:

  • adapt failing unit tests

I have:

  • Read and followed Crossplane's [contribution process].
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Tested manually for rds.DBInstance, rds.DBCluster, docdb.DBInstance, docdb.DBCluster and neptune.DBCluster

@MisterMX
Copy link
Collaborator

MisterMX commented Nov 21, 2023

@wotolom thanks for pointing that out. This is quite a tricky breaking change that wasn't pointed out in the release notes of https://github.com/crossplane/crossplane-runtime.

I wonder if it is possible to fix this issue without removing the code from Create? After all there are some cases in AWS where certain information can only be retrieved with the create response. I think it might be better to just change the logic in isUpToDate to adapt to the field changes (if possible).

If we want a quick fix for this issue I guess the easiest solution is to use a custom implementation of managed.RetryingCriticalAnnotationUpdater that is equivalent to the behaviour before crossplane/crossplane-runtime#526 was merged. It can be added as a controller option using managed.WithCriticalAnnotationUpdater. This also results in much less code changes for the hotfix while sticking to code that we know works.

We can then decide how we want to move forward with this issue for v0.46+.

@wotolom wotolom force-pushed the fix-remove-one-time-init-after-creation branch from 4c785e1 to c7c2137 Compare November 22, 2023 13:04
@wotolom wotolom marked this pull request as ready for review November 22, 2023 13:09
@wotolom
Copy link
Contributor Author

wotolom commented Nov 22, 2023

I wonder if it is possible to fix this issue without removing the code from Create? After all there are some cases in AWS where certain information can only be retrieved with the create response. I think it might be better to just change the logic in isUpToDate to adapt to the field changes (if possible).

also postCreate() would be a legit place to set/unset some fields. E.g. in the specific case of rds.DbInstance where we need to control which fields are (late)init depending on whether parameter DBClusterIdentifier is set or not.

If we want a quick fix for this issue I guess the easiest solution is to use a custom implementation of managed.RetryingCriticalAnnotationUpdater that is equivalent to the behaviour before crossplane/crossplane-runtime#526 was merged. It can be added as a controller option using managed.WithCriticalAnnotationUpdater. This also results in much less code changes for the hotfix while sticking to code that we know works.

However I did go with this solution for now as hotfix, due the uncertainty how many/which resources/controllers are running into this issue besides rds.DBInstance.

@wotolom wotolom changed the title fix(ack): remove - only newly working - one-time init after creation fix(controllers): use custom CriticalAnnotationUpdater Nov 22, 2023
limitations under the License.
*/

package custommanaged
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not very happy with this package name. Can we move it to /pkg/utils/reconciler/managed and maybe import it as custommanaged if necessary?

Also it would be good to add a doc string to this package to explain the reason for this special implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, done! :)

@wotolom wotolom force-pushed the fix-remove-one-time-init-after-creation branch from c7c2137 to 638e422 Compare November 22, 2023 16:25
Signed-off-by: Charel Baum (external expert on behalf of DB Netz AG) <charel.baum-extern@deutschebahn.com>
@wotolom wotolom force-pushed the fix-remove-one-time-init-after-creation branch from 638e422 to 5fc305b Compare November 22, 2023 16:46
Copy link
Collaborator

@MisterMX MisterMX left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you very much @wotolom for this fix!

@MisterMX MisterMX merged commit 367e1be into crossplane-contrib:master Nov 22, 2023
9 checks passed
Copy link

Successfully created backport PR #1956 for release-0.45.

@wotolom wotolom deleted the fix-remove-one-time-init-after-creation branch November 22, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RDS instance in modify loop due to Crossplane checking AWS initialized fields. (version 0.45)
2 participants