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

Aurora DBInstance .spec.forProvider field is modified and makes the CR invalid #2106

Open
drewwells opened this issue Oct 15, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@drewwells
Copy link
Contributor

drewwells commented Oct 15, 2024

Crossplane is setting spec.forProvider.{masterUsername,kmsKeyID,port} on a spec that is disallowed when those fields are set.

What happened?

Crossplane attempts to recreate a deleted aurora instance and fails because the forProvider block was modified to an invalid state. kmsKeyID, masterusername and port were populated.

For example, these errors are seen:

The requested DB Instance will be a member of a DB Cluster. Set master user name for the DB Cluster.
create failed: cannot create DBInstance in AWS: InvalidParameterCombination:
      The requested DB Instance will be a member of a DB Cluster. Set database endpoint
      port number for the DB Cluster.\n\tstatus code: 400

How can we reproduce it?

Provision an aurora dbcluster and dbinstance
Delete the dbinstance from AWS console
Trigger crossplane to reconcile the dbinstance which is missing an aws resource now
Crossplane reports confusing errors that the dbcluster is missing fields port, masterUsername, and kmsKeyID. It's actually because the dbinstance now includes those fields.

What environment did it happen in?

provider-aws version: 0.46.0
crossplane: 1.17.0

@drewwells drewwells added the bug Something isn't working label Oct 15, 2024
@MisterMX
Copy link
Collaborator

Crossplane does not support external deletion of resources. The deletion process should always be triggered from within Crossplane.

If there is a way to prevent this error from happening without breaking existing implementations feel free to open a pull request.

@drewwells
Copy link
Contributor Author

drewwells commented Oct 22, 2024 via email

@MisterMX
Copy link
Collaborator

The controller intentionally late-initializes all unset, optional properties with the values retrieved from AWS. I haven't looked into the code specifically but I think you issue is caused by the external deletion of the DBInstance which the controller does not seem to support.

@drewwells
Copy link
Contributor Author

drewwells commented Oct 29, 2024

Those properties can't be set, they have to be left blank. Repo steps are pretty easy.

Create an aurora dbinstance CR
Save the modified spec properties, rename it (metadata.name)
Create it again
You will need to remove the 3 properties specified in the description to create a new dbinstance object

@MisterMX
Copy link
Collaborator

Now I'm not sure anymore if I understand the problem correctly. If you think there is an issue with how the controller builds and sends the creation / update request to AWS feel free to open a PR with a fix.

@drewwells
Copy link
Contributor Author

drewwells commented Oct 31, 2024 via email

@MisterMX
Copy link
Collaborator

MisterMX commented Nov 4, 2024

Every controller populates empty, optional fields with the state of the resource it receives from the external API (here: AWS). That is common across most Crossplane provider and we won't change that.

However, each controller can decide individually which field should be set in the request it sends to AWS. Given the case above: If a single-instance specific field should not be part of the response, we can remove it from the creation or update request.

@drewwells
Copy link
Contributor Author

drewwells commented Nov 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants