Skip to content

Commit 721e2af

Browse files
authored
Fix Redis to Valkey in-place upgrade by handling Engine in ModifyReplicationGroup (#188)
Fixes: aws-controllers-k8s/community#2299 Description of changes: fixes the issue where in-place upgrades from ElastiCache Redis to Valkey clusters failed with `InvalidParameterCombination: valkey parameter group is not applicable to engine redis`. The problem occurred because the ElastiCache controller's custom `ModifyReplicationGroup` implementation was missing the `Engine` and `CacheParameterGroupName` fields in the API request payload, causing AWS to reject Valkey parameter groups being applied to what it perceived as a Redis engine. Additionally, the `ModifyReplicationGroup` API returns stale field values that don't immediately reflect requested changes, leading the controller to detect false differences and trigger terminal conditions. The solution adds both missing fields to the modify request payload, and normalizes API responses by overriding stale Engine field values with the user's intended values before processing. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 15b7e88 commit 721e2af

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ack_generate_info:
2-
build_date: "2025-09-05T22:54:05Z"
3-
build_hash: 1d9076d0211773ff8ab8682b28b912c7ece10676
2+
build_date: "2025-09-10T22:13:23Z"
3+
build_hash: 9e29f017d9e942548af133d2f31aecae248a8816
44
go_version: go1.25.0
5-
version: v0.51.0-2-g1d9076d
5+
version: v0.51.0-3-g9e29f01
66
api_directory_checksum: 65127f2f0a24a801fad4e043be37857f0e6bcfb9
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.32.6

helm/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ metadata:
1010
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
1111
k8s-app: {{ include "ack-elasticache-controller.app.name" . }}
1212
helm.sh/chart: {{ include "ack-elasticache-controller.chart.name-version" . }}
13+
{{- range $key, $value := .Values.deployment.labels }}
14+
{{ $key }}: {{ $value | quote }}
15+
{{- end }}
1316
spec:
1417
replicas: {{ .Values.deployment.replicas }}
1518
selector:

pkg/resource/replication_group/hooks.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ func (rm *resourceManager) modifyReplicationGroup(
613613

614614
// SecurityGroupIds, EngineVersion
615615
if rm.securityGroupIdsDiffer(desired, latest, latestCacheCluster) ||
616-
delta.DifferentAt("Spec.EngineVersion") {
616+
delta.DifferentAt("Spec.EngineVersion") || delta.DifferentAt("Spec.Engine") || delta.DifferentAt("Spec.CacheParameterGroupName") {
617617
input := rm.newModifyReplicationGroupRequestPayload(desired, latest, latestCacheCluster, delta)
618618
resp, respErr := rm.sdkapi.ModifyReplicationGroup(ctx, input)
619619
rm.metrics.RecordAPICall("UPDATE", "ModifyReplicationGroup", respErr)
@@ -622,7 +622,16 @@ func (rm *resourceManager) modifyReplicationGroup(
622622
return nil, respErr
623623
}
624624

625-
return rm.setReplicationGroupOutput(ctx, desired, resp.ReplicationGroup)
625+
// The ModifyReplicationGroup API returns stale field Engine that don't
626+
// immediately reflect the requested changes, causing the controller to detect false
627+
// differences and trigger terminal conditions. Override these fields with the user's
628+
// intended values before passing to the generated setReplicationGroupOutput function.
629+
normalizedRG := *resp.ReplicationGroup
630+
if desired.ko.Spec.Engine != nil {
631+
normalizedRG.Engine = desired.ko.Spec.Engine
632+
}
633+
634+
return rm.setReplicationGroupOutput(ctx, desired, &normalizedRG)
626635
}
627636

628637
// no updates done
@@ -1169,6 +1178,16 @@ func (rm *resourceManager) newModifyReplicationGroupRequestPayload(
11691178
input.EngineVersion = desired.ko.Spec.EngineVersion
11701179
}
11711180

1181+
if delta.DifferentAt("Spec.Engine") &&
1182+
desired.ko.Spec.Engine != nil {
1183+
input.Engine = desired.ko.Spec.Engine
1184+
}
1185+
1186+
if delta.DifferentAt("Spec.CacheParameterGroupName") &&
1187+
desired.ko.Spec.CacheParameterGroupName != nil {
1188+
input.CacheParameterGroupName = desired.ko.Spec.CacheParameterGroupName
1189+
}
1190+
11721191
return input
11731192
}
11741193

0 commit comments

Comments
 (0)