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(elasticache) normalize preferred maintenance window #1303

Conversation

eaceaser
Copy link
Contributor

Description of your changes

Relates to #1023

We discovered a state where provider-aws was repeatedly modifying the elasticache cluster without it becoming available, as described in #1023. Tracked the issue down to the use of a PreferredMaintenanceWindow argument that included capitalized day names: Fri:04:20-Fri:16:20.

This is invalid according to aws docs, as day names are supposed to be lowercased, however the AWS API accepts uppercased day names, and normalizes them behind the scenes to lowercased. This ends up breaking the cacheClusterNeedsUpdate check, which tests for exact equality between the declared maintenance window in the resource spec (which will still be uppercased), and the maintenance window returned from the AWS API, which will be lowercased.

This PR offers a potential fix, by normalizing the casing of the maintenance window when performing this check. However, it suffers from the following issues:

  • we don't know the actual normalization strategy used by AWS here, so this is just a best guess.
  • there are likely other cases impacted by this.

Overall it might be better to try to validate this string at resource-create time, but that would likely require a webhook, etc.

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

adds a unit test, also tested against the AWS API with ReplicationGroup resource w/ capitalized day names.

Signed-off-by: Ed Ceaser <ceasere@gmail.com>
@eaceaser eaceaser force-pushed the fix-elasticache-maintenance-window-normalization branch from 0c247ec to 9cff24c Compare May 11, 2022 22:34
p.PreferredMaintenanceWindow = aws.String("Mon:00:00-Fri:23:59")

}),
cc: elasticachetypes.CacheCluster{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

was looking at building a helper for this, but elasticachecluster_test.go already defines helpers for the CacheCluster struct in the same package, which would potentially collide with the needs of these tests. Would like some guidance on the best way to deal with this

Copy link
Member

@haarchri haarchri left a comment

Choose a reason for hiding this comment

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

LGTM

@haarchri haarchri merged commit 11652a3 into crossplane-contrib:master May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants