Skip to content

Commit dd40399

Browse files
Ignore EngineVersion minor updates when autoMinorVersionUpgrade is enabled (#166)
Fixes [Issue](aws-controllers-k8s/community#2009) By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 7a05259 commit dd40399

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pkg/resource/db_cluster/custom_update.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package db_cluster
1515

1616
import (
1717
"context"
18+
"regexp"
1819
"slices"
1920

2021
ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1"
@@ -28,6 +29,8 @@ import (
2829
svcapitypes "github.com/aws-controllers-k8s/rds-controller/apis/v1alpha1"
2930
)
3031

32+
var r = regexp.MustCompile(`[0-9]*$`)
33+
3134
// customUpdate is required to fix
3235
// https://github.com/aws-controllers-k8s/community/issues/917. The Input shape
3336
// sent to ModifyDBCluster MUST have fields that are unchanged between desired
@@ -577,7 +580,9 @@ func (rm *resourceManager) newCustomUpdateRequestPayload(
577580
res.SetEnableIAMDatabaseAuthentication(*desired.ko.Spec.EnableIAMDatabaseAuthentication)
578581
}
579582
if desired.ko.Spec.EngineVersion != nil && delta.DifferentAt("Spec.EngineVersion") {
580-
res.SetEngineVersion(*desired.ko.Spec.EngineVersion)
583+
if requireEngineVersionUpdate(desired.ko.Spec.EngineVersion, latest.ko.Spec.EngineVersion, *desired.ko.Spec.AutoMinorVersionUpgrade) {
584+
res.SetEngineVersion(*desired.ko.Spec.EngineVersion)
585+
}
581586
}
582587
if desired.ko.Spec.MasterUserPassword != nil && delta.DifferentAt("Spec.MasterUserPassword") {
583588
tmpSecret, err := rm.rr.SecretValueFromReference(ctx, desired.ko.Spec.MasterUserPassword)
@@ -672,3 +677,9 @@ func getCloudwatchLogExportsConfigDifferences(cloudwatchLogExportsConfigDesired
672677
}
673678
return logsTypesToEnable, logsTypesToDisable
674679
}
680+
681+
func requireEngineVersionUpdate(desiredEngineVersion *string, latestEngineVersion *string, autoMinorVersionUpgrade bool) bool {
682+
desiredMajorEngineVersion := r.ReplaceAllString(*desiredEngineVersion, "${1}")
683+
latestMajorEngineVersion := r.ReplaceAllString(*latestEngineVersion, "${1}")
684+
return !autoMinorVersionUpgrade || desiredMajorEngineVersion != latestMajorEngineVersion
685+
}

0 commit comments

Comments
 (0)