Skip to content

Commit 89637de

Browse files
Add check for DB cluster available before updating (#56)
Fixes: aws-controllers-k8s/community#1107 Description of changes: If a DB cluster is in any state other than `Available`, then an attempt to update it will return a terminal `InvalidDBClusterStateFault` error. This error will stop the cluster from reconciling any further, even though the underlying RDS DB cluster is working properly. This PR checks that the DB cluster is in the `Available` state before running the custom update code, otherwise re-queuing it until it is. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 692fea3 commit 89637de

File tree

5 files changed

+10
-24
lines changed

5 files changed

+10
-24
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-01-24T21:04:15Z"
3-
build_hash: cccec82a27ddd880095383360df1fdc8f530842f
4-
go_version: go1.17.5
2+
build_date: "2022-01-31T20:23:51Z"
3+
build_hash: 4ebcd703a95a2fbd71bd07130f92aa6813c1398b
4+
go_version: go1.17.1
55
version: v0.16.3
66
api_directory_checksum: cae902b75e1b0827659c4bfe7ef9f6bb98769f5c
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.37.10
99
generator_config_info:
10-
file_checksum: a40f829b03389cf1b2a003ebe2a79b97bc9d3322
10+
file_checksum: e87619caa6304d2a07818296e3a6a5fd4da1e704
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ resources:
7070
template_path: hooks/db_cluster/sdk_create_post_set_output.go.tpl
7171
sdk_read_many_post_set_output:
7272
template_path: hooks/db_cluster/sdk_read_many_post_set_output.go.tpl
73-
sdk_update_pre_build_request:
74-
template_path: hooks/db_cluster/sdk_update_pre_build_request.go.tpl
7573
sdk_delete_pre_build_request:
7674
template_path: hooks/db_cluster/sdk_delete_pre_build_request.go.tpl
7775
exceptions:

generator.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ resources:
7070
template_path: hooks/db_cluster/sdk_create_post_set_output.go.tpl
7171
sdk_read_many_post_set_output:
7272
template_path: hooks/db_cluster/sdk_read_many_post_set_output.go.tpl
73-
sdk_update_pre_build_request:
74-
template_path: hooks/db_cluster/sdk_update_pre_build_request.go.tpl
7573
sdk_delete_pre_build_request:
7674
template_path: hooks/db_cluster/sdk_delete_pre_build_request.go.tpl
7775
exceptions:

pkg/resource/db_cluster/custom_update.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ func (rm *resourceManager) customUpdate(
5050
ackcondition.SetSynced(desired, corev1.ConditionFalse, &msg, nil)
5151
return desired, requeueWaitUntilCanModify(latest)
5252
}
53+
if !clusterAvailable(latest) {
54+
msg := "DB cluster is not available for modification in '" +
55+
*latest.ko.Status.Status + "' status"
56+
ackcondition.SetSynced(desired, corev1.ConditionFalse, &msg, nil)
57+
return desired, requeueWaitUntilCanModify(latest)
58+
}
5359
if clusterHasTerminalStatus(latest) {
5460
msg := "DB cluster is in '" + *latest.ko.Status.Status + "' status"
5561
ackcondition.SetTerminal(desired, corev1.ConditionTrue, &msg, nil)

templates/hooks/db_cluster/sdk_update_pre_build_request.go.tpl

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)