Skip to content

Commit d72e06b

Browse files
brucegucodeTenglong Gu
andauthored
Ignore NetworkType param if no change, not consider diff when engine version diff in minor version (#91)
* Ignore NetworkType param if no change, not consider diff when engine version diff in minor version Co-authored-by: Tenglong Gu <[email protected]>
1 parent 78a5798 commit d72e06b

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
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: "2022-06-17T22:34:21Z"
2+
build_date: "2022-06-20T19:21:08Z"
33
build_hash: a45f3b900849ec03c5e16ed2778c0b8e2923ffee
4-
go_version: go1.18.3
5-
version: v0.19.0-5-ga45f3b9
4+
go_version: go1.18.2
5+
version: v0.19.1
66
api_directory_checksum: 7567208aa7463aaa3c937e45107f520e6fc2946f
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.27

pkg/resource/db_instance/delta.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/db_instance/hooks.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"context"
1818
"errors"
1919
"fmt"
20+
"strings"
2021

2122
ackcondition "github.com/aws-controllers-k8s/runtime/pkg/condition"
2223
ackrequeue "github.com/aws-controllers-k8s/runtime/pkg/requeue"
@@ -194,3 +195,16 @@ func (rm *resourceManager) restoreDbInstanceFromDbSnapshot(
194195
}
195196
return &resource{r.ko}, nil
196197
}
198+
199+
// RDS will choose preferred engine minor version if only
200+
// engine major version is provided and controler should not
201+
// treat them as different, such as spec has 14, status has 14.1
202+
// controller should treat them as same
203+
func reconcileEngineVersion(
204+
a *resource,
205+
b *resource,
206+
) {
207+
if a != nil && b != nil && strings.HasPrefix(*b.ko.Spec.EngineVersion, *a.ko.Spec.EngineVersion) {
208+
a.ko.Spec.EngineVersion = b.ko.Spec.EngineVersion
209+
}
210+
}

pkg/resource/db_instance/sdk.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/hooks/db_instance/delta_pre_compare.go.tpl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@
99
// reconciler will keep updating the dbinstance and constantly requeueing it.
1010
if a != nil && a.ko.Spec.AvailabilityZone == nil && b != nil && b.ko.Spec.AvailabilityZone != nil {
1111
a.ko.Spec.AvailabilityZone = b.ko.Spec.AvailabilityZone
12-
}
12+
}
13+
14+
// RDS will choose preferred engine minor version if only
15+
// engine major version is provided and controler should not
16+
// treat them as different, such as spec has 14, status has 14.1
17+
// controller should treat them as same
18+
reconcileEngineVersion(a, b)

templates/hooks/db_instance/sdk_update_post_build_request.go.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// RDS will not compare diff value and accept any modify db call
1111
// for below values, MonitoringInterval, CACertificateIdentifier
12-
// and user master password
12+
// and user master password, NetworkType
1313
// hence if there is no delta between desired
1414
// and latest, exclude it from ModifyDBInstanceRequest
1515
if !delta.DifferentAt("Spec.MonitoringInterval") {
@@ -21,3 +21,6 @@
2121
if !delta.DifferentAt("Spec.MasterUserPassword.Name") {
2222
input.MasterUserPassword = nil
2323
}
24+
if !delta.DifferentAt("Spec.NetworkType") {
25+
input.NetworkType = nil
26+
}

0 commit comments

Comments
 (0)