Skip to content

Commit cfe16d6

Browse files
authored
Allow storage update operation to unavailable db instance (#200)
Issue [#2214](aws-controllers-k8s/community#2214) Description of changes: With this change we allow the controller to make a storage update call when the DB instance is unavailable due to a `storage-full` status. This case is not easy to test, since the minimum storage to allocate is 20GiB. Options for testing: * Create an existing DB instance that is already unavailable due to `storage-full` status and update storage (this would then require us to fill up the remaining space) more ideas are welcome... By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent ee3d577 commit cfe16d6

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ack_generate_info:
2-
build_date: "2024-10-10T04:05:06Z"
2+
build_date: "2024-11-25T18:12:36Z"
33
build_hash: 36c2d234498c2bc4f60773ab8df632af4067f43b
44
go_version: go1.23.2
55
version: v0.39.1

pkg/resource/db_instance/hooks.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,3 +581,12 @@ func setDeleteDBInstanceInput(
581581
input.DeleteAutomatedBackups = params.DeleteAutomatedBackup
582582
return nil
583583
}
584+
585+
// needStorageUpdate
586+
func needStorageUpdate(
587+
r *resource,
588+
delta *ackcompare.Delta,
589+
) bool {
590+
return strings.Contains(*r.ko.Status.DBInstanceStatus, "storage-full") &&
591+
delta.DifferentAt("Spec.AllocatedStorage")
592+
}

pkg/resource/db_instance/sdk.go

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

templates/hooks/db_instance/sdk_update_pre_build_request.go.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
ackcondition.SetSynced(desired, corev1.ConditionTrue, nil, nil)
1515
return desired, nil
1616
}
17-
if !instanceAvailable(latest) {
17+
if !instanceAvailable(latest) && !needStorageUpdate(latest, delta) {
1818
msg := "DB instance cannot be modifed while in '" + *latest.ko.Status.DBInstanceStatus + "' status"
1919
ackcondition.SetSynced(desired, corev1.ConditionFalse, &msg, nil)
2020
return desired, requeueWaitUntilCanModify(latest)

0 commit comments

Comments
 (0)