Skip to content

Commit 2145c0e

Browse files
Fix DBInstance for updating PI and add tests (#95)
Fixes aws-controllers-k8s/community#1346 Description of changes: Updating `EnablePerformanceInsights` caused the `DBInstance` to cycle continuously, as it tried to reconcile the server side default values and handle the asynchronous status updates. Rather than relying on a requeue error to wait for the status to update, this pull request modifies the `DBInstance` custom code to set `ResourceSynced = false` on the resource (for the runtime logic to cause the requeue instead). Furthermore, we remove the server side defaulted values from the diff if they have not been updated in the desired spec. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 5c00e12 commit 2145c0e

File tree

15 files changed

+1251
-100
lines changed

15 files changed

+1251
-100
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2022-06-22T22:42:22Z"
2+
build_date: "2022-06-23T23:45:42Z"
33
build_hash: 4b54669d709a0eb2c1fab659e329060350a40e84
4-
go_version: go1.17.5
4+
go_version: go1.18.3
55
version: v0.19.2
6-
api_directory_checksum: 891cddd4b051d5b865abddeb1a19760b9fbdcd37
6+
api_directory_checksum: b0c5acd3d10a1214f5cc46d2fb8b887d9ecc2fe4
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.27
99
generator_config_info:
10-
file_checksum: 25009e8400a5efd62efed790fd4b5015466a2dc9
10+
file_checksum: 48d07f9a7b6ea79f8398bcd10254d912cd90cb6d
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/db_instance.go

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

apis/v1alpha1/generator.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ resources:
153153
template_path: hooks/db_instance/sdk_update_post_set_output.go.tpl
154154
sdk_delete_pre_build_request:
155155
template_path: hooks/db_instance/sdk_delete_pre_build_request.go.tpl
156-
delta_pre_compare:
157-
template_path: hooks/db_instance/delta_pre_compare.go.tpl
158156
sdk_file_end:
159157
template_path: hooks/db_instance/sdk_file_end.go.tpl
158+
delta_pre_compare:
159+
code: customPreCompare(a, b)
160160
exceptions:
161161
terminal_codes:
162162
- InvalidParameter
@@ -168,13 +168,20 @@ resources:
168168
is_immutable: true
169169
DBInstanceIdentifier:
170170
is_primary_key: true
171+
DBInstanceStatus:
172+
print:
173+
name: "STATUS"
171174
MasterUserPassword:
172175
is_secret: true
173176
KmsKeyId:
174177
references:
175178
resource: Key
176179
service_name: kms
177180
path: Status.ACKResourceMetadata.ARN
181+
BackupTarget:
182+
late_initialize: {}
183+
NetworkType:
184+
late_initialize: {}
178185
# Used by restore db instance from db snapshot
179186
DBSnapshotIdentifier:
180187
from:

config/crd/bases/rds.services.k8s.aws_dbinstances.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ spec:
1616
singular: dbinstance
1717
scope: Namespaced
1818
versions:
19-
- name: v1alpha1
19+
- additionalPrinterColumns:
20+
- jsonPath: .status.dbInstanceStatus
21+
name: STATUS
22+
type: string
23+
name: v1alpha1
2024
schema:
2125
openAPIV3Schema:
2226
description: DBInstance is the Schema for the DBInstances API

generator.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ resources:
153153
template_path: hooks/db_instance/sdk_update_post_set_output.go.tpl
154154
sdk_delete_pre_build_request:
155155
template_path: hooks/db_instance/sdk_delete_pre_build_request.go.tpl
156-
delta_pre_compare:
157-
template_path: hooks/db_instance/delta_pre_compare.go.tpl
158156
sdk_file_end:
159157
template_path: hooks/db_instance/sdk_file_end.go.tpl
158+
delta_pre_compare:
159+
code: customPreCompare(a, b)
160160
exceptions:
161161
terminal_codes:
162162
- InvalidParameter
@@ -168,13 +168,20 @@ resources:
168168
is_immutable: true
169169
DBInstanceIdentifier:
170170
is_primary_key: true
171+
DBInstanceStatus:
172+
print:
173+
name: "STATUS"
171174
MasterUserPassword:
172175
is_secret: true
173176
KmsKeyId:
174177
references:
175178
resource: Key
176179
service_name: kms
177180
path: Status.ACKResourceMetadata.ARN
181+
BackupTarget:
182+
late_initialize: {}
183+
NetworkType:
184+
late_initialize: {}
178185
# Used by restore db instance from db snapshot
179186
DBSnapshotIdentifier:
180187
from:

go.local.mod

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
module github.com/aws-controllers-k8s/rds-controller
2+
3+
go 1.17
4+
5+
replace github.com/aws-controllers-k8s/runtime => ../runtime
6+
7+
require (
8+
github.com/aws-controllers-k8s/kms-controller v0.0.15
9+
github.com/aws-controllers-k8s/runtime v0.18.4
10+
github.com/aws/aws-sdk-go v1.44.27
11+
github.com/go-logr/logr v1.2.0
12+
github.com/spf13/pflag v1.0.5
13+
k8s.io/api v0.23.0
14+
k8s.io/apimachinery v0.23.0
15+
k8s.io/client-go v0.23.0
16+
sigs.k8s.io/controller-runtime v0.11.0
17+
)
18+
19+
require (
20+
github.com/beorn7/perks v1.0.1 // indirect
21+
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
22+
github.com/cespare/xxhash/v2 v2.1.1 // indirect
23+
github.com/davecgh/go-spew v1.1.1 // indirect
24+
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
25+
github.com/fsnotify/fsnotify v1.5.1 // indirect
26+
github.com/go-logr/zapr v1.2.0 // indirect
27+
github.com/gogo/protobuf v1.3.2 // indirect
28+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
29+
github.com/golang/protobuf v1.5.2 // indirect
30+
github.com/google/go-cmp v0.5.5 // indirect
31+
github.com/google/gofuzz v1.1.0 // indirect
32+
github.com/google/uuid v1.1.2 // indirect
33+
github.com/googleapis/gnostic v0.5.5 // indirect
34+
github.com/imdario/mergo v0.3.12 // indirect
35+
github.com/itchyny/gojq v0.12.6 // indirect
36+
github.com/itchyny/timefmt-go v0.1.3 // indirect
37+
github.com/jaypipes/envutil v1.0.0 // indirect
38+
github.com/jmespath/go-jmespath v0.4.0 // indirect
39+
github.com/json-iterator/go v1.1.12 // indirect
40+
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
41+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
42+
github.com/modern-go/reflect2 v1.0.2 // indirect
43+
github.com/pkg/errors v0.9.1 // indirect
44+
github.com/prometheus/client_golang v1.11.0 // indirect
45+
github.com/prometheus/client_model v0.2.0 // indirect
46+
github.com/prometheus/common v0.28.0 // indirect
47+
github.com/prometheus/procfs v0.6.0 // indirect
48+
go.uber.org/atomic v1.7.0 // indirect
49+
go.uber.org/multierr v1.6.0 // indirect
50+
go.uber.org/zap v1.19.1 // indirect
51+
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
52+
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
53+
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
54+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
55+
golang.org/x/text v0.3.7 // indirect
56+
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
57+
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
58+
google.golang.org/appengine v1.6.7 // indirect
59+
google.golang.org/protobuf v1.27.1 // indirect
60+
gopkg.in/inf.v0 v0.9.1 // indirect
61+
gopkg.in/yaml.v2 v2.4.0 // indirect
62+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
63+
k8s.io/apiextensions-apiserver v0.23.0 // indirect
64+
k8s.io/component-base v0.23.0 // indirect
65+
k8s.io/klog/v2 v2.30.0 // indirect
66+
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
67+
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect
68+
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
69+
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect
70+
sigs.k8s.io/yaml v1.3.0 // indirect
71+
)

0 commit comments

Comments
 (0)