Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ack_generate_info:
build_date: "2021-10-14T18:44:40Z"
build_date: "2021-10-18T18:57:57Z"
build_hash: 385779a205bea50e8762b76bc75cab957cf723b9
go_version: go1.15.2
version: v0.15.1
Expand Down
70 changes: 0 additions & 70 deletions pkg/resource/replication_group/manager_test.go

This file was deleted.

16 changes: 15 additions & 1 deletion pkg/resource/replication_group/post_set_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func (rm *resourceManager) updateSpecFields(
if err == nil && latestCacheCluster != nil {
setEngineVersion(latestCacheCluster, resource)
setMaintenanceWindow(latestCacheCluster, resource)
setCacheParameterGroup(latestCacheCluster, resource)
}
}

Expand All @@ -66,7 +67,7 @@ func setReplicasPerNodeGroup(
}
}

// if EngineVersion was specified in desired.Spec, update ko.Sepc with the latest observed value (if non-nil)
// if EngineVersion was specified in desired.Spec, update ko.Spec with the latest observed value (if non-nil)
func setEngineVersion(
latestCacheCluster *svcsdk.CacheCluster,
resource *resource,
Expand All @@ -88,3 +89,16 @@ func setMaintenanceWindow(
ko.Spec.PreferredMaintenanceWindow = &pmw
}
}

// setCacheParameterGroup updates the cache parameter group associated with the replication group
// (if non-nil in API response) regardless of whether it was specified in desired
func setCacheParameterGroup(
latestCacheCluster *svcsdk.CacheCluster,
resource *resource,
) {
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

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
apiVersion: elasticache.services.k8s.aws/v1alpha1
kind: ReplicationGroup
# omitted metadata
spec:
atRestEncryptionEnabled: false
cacheNodeType: cache.t3.micro
cacheParameterGroupName: "default.redis5.0"
engine: redis
numNodeGroups: 1
preferredMaintenanceWindow: "wed:08:00-wed:09:00"
replicasPerNodeGroup: 1
replicationGroupDescription: cluster-mode disabled RG
replicationGroupID: rg-cmd
snapshotRetentionLimit: 0
snapshotWindow: "10:00-11:00"
transitEncryptionEnabled: false
status:
ackResourceMetadata:
arn: arn:aws:elasticache:us-east-1:012345678910:replicationgroup:rg-cmd
ownerAccountID: ""
allowedScaleUpModifications:
- cache.m3.2xlarge
- cache.m3.large
- cache.m3.medium
- cache.m3.xlarge
- cache.m4.10xlarge
- cache.m4.2xlarge
- cache.m4.4xlarge
- cache.m4.large
- cache.m4.xlarge
- cache.m5.12xlarge
- cache.m5.24xlarge
- cache.m5.2xlarge
- cache.m5.4xlarge
- cache.m5.large
- cache.m5.xlarge
- cache.m6g.large
- cache.r3.2xlarge
- cache.r3.4xlarge
- cache.r3.8xlarge
- cache.r3.large
- cache.r3.xlarge
- cache.r4.16xlarge
- cache.r4.2xlarge
- cache.r4.4xlarge
- cache.r4.8xlarge
- cache.r4.large
- cache.r4.xlarge
- cache.r5.12xlarge
- cache.r5.24xlarge
- cache.r5.2xlarge
- cache.r5.4xlarge
- cache.r5.large
- cache.r5.xlarge
- cache.r6g.2xlarge
- cache.r6g.4xlarge
- cache.r6g.8xlarge
- cache.r6g.large
- cache.r6g.xlarge
- cache.t2.medium
- cache.t2.micro
- cache.t2.small
- cache.t3.medium
- cache.t3.small
authTokenEnabled: false
automaticFailover: disabled
clusterEnabled: false
conditions:
- status: "True"
type: ACK.ResourceSynced
description: cluster-mode disabled RG
events:
- date: "2021-03-30T20:12:00Z"
message: Replication group rg-cmd created
globalReplicationGroupInfo: {}
memberClusters:
- rg-cmd-001
- rg-cmd-002
multiAZ: disabled
nodeGroups:
- nodeGroupID: "0001"
nodeGroupMembers:
- cacheClusterID: rg-cmd-001
cacheNodeID: "0001"
currentRole: primary
preferredAvailabilityZone: us-east-1b
readEndpoint:
address: rg-cmd-001.xxxxxx.0001.use1.cache.amazonaws.com
port: 6379
- cacheClusterID: rg-cmd-002
cacheNodeID: "0001"
currentRole: replica
preferredAvailabilityZone: us-east-1d
readEndpoint:
address: rg-cmd-002.xxxxxx.0001.use1.cache.amazonaws.com
port: 6379
primaryEndpoint:
address: rg-cmd.xxxxxx.ng.0001.use1.cache.amazonaws.com
port: 6379
readerEndpoint:
address: rg-cmd-ro.xxxxxx.ng.0001.use1.cache.amazonaws.com
port: 6379
status: available
pendingModifiedValues: {}
status: available
4 changes: 2 additions & 2 deletions pkg/resource/replication_group/testdata/test_suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ tests:
output_fixture: "cache_clusters/read_many/rg_cmd_primary_cache_node.json"
invoke: ReadOne
expect:
latest_state: "replication_group/cr/rg_cmd_create_completed.yaml"
latest_state: "replication_group/cr/rg_cmd_create_completed_latest.yaml"
error: nil
- name: "ReadOne=NoDiff"
description: "Given desired state matches with server side resource data, ko.Status remain unchanged (resource is stable)"
Expand All @@ -70,7 +70,7 @@ tests:
output_fixture: "cache_clusters/read_many/rg_cmd_primary_cache_node.json"
invoke: ReadOne
expect:
latest_state: "replication_group/cr/rg_cmd_create_completed.yaml" #unchanged
latest_state: "replication_group/cr/rg_cmd_create_completed_latest.yaml"
error: nil
- name: "Update=IncreaseReplicaCount"
description: "Ensure a replica is added once a new config is provided"
Expand Down
1 change: 0 additions & 1 deletion test/e2e/tests/test_replicationgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ def test_rg_associate_resources(self, rg_associate_resources_input, rg_associate
# assert new state
assert_associated_resources(rg_associate_resources_input['RG_ID'], sg_list, sns_topic, ug_list)

@pytest.mark.blocked # TODO: remove when passing
def test_rg_update_cpg(self, rg_update_cpg_input, rg_update_cpg, bootstrap_resources):
# wait for resource to sync and retrieve initial state
(reference, _) = rg_update_cpg
Expand Down