Skip to content

Conversation

@echen-98
Copy link
Contributor

Description of changes:

Associating then updating a cache parameter group to a replication group previously did not work. Now we populate latest.Spec.CacheParameterGroupName from the response of the DescribeCacheClusters API.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@echen-98
Copy link
Contributor Author

Fixed unit test failures and removed a unit test redundant with existing declarative unit tests. Reason for that being we can't necessarily expect ReadOne to result in no difference between latest and desired if default fields exist and those fields map back to latest.Spec (meaning desired.Spec would have nil and latest.Spec would have some non-nil default value).

ko := resource.ko
if latestCacheCluster.CacheParameterGroup != nil && latestCacheCluster.CacheParameterGroup.CacheParameterGroupName != nil {
cpgName := *latestCacheCluster.CacheParameterGroup.CacheParameterGroupName
ko.Spec.CacheParameterGroupName = &cpgName
Copy link
Contributor

Choose a reason for hiding this comment

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

if ko.Spec.CacheParameterGroupName was non-nil and different from latestCacheCluster.CacheParameterGroup.CacheParameterGroupName, why would we overwrite ko.Spec.CacheParameterGroupName here? This smells funny...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intention is just to retrieve the cache parameter group currently associated to the replication group. That information comes from the DescribeCacheClusters API since it is not present in the DescribeReplicationGroups API response.

If ko.Spec.CacheParameterGroupName is non-nil and gets overwritten, that's precisely what we want because the original value was copied over from desired, the latest value is different from that, and the controller will go on to detect a diff and invoke a Modify call with the desired CacheParameterGroupName.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aws-controllers-k8s/community#846 (comment)

This falls under "case 3" of spec fields as I mentioned in this issue a while back

@ack-bot
Copy link
Collaborator

ack-bot commented Oct 25, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: echen-98, kumargauravsharma

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [echen-98,kumargauravsharma]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kumargauravsharma kumargauravsharma merged commit 7f4c389 into aws-controllers-k8s:main Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants