Skip to content

Commit

Permalink
Allow storage update operation to unavailable db instance (#200)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
michaelhtm authored Nov 25, 2024
1 parent ee3d577 commit cfe16d6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ack_generate_info:
build_date: "2024-10-10T04:05:06Z"
build_date: "2024-11-25T18:12:36Z"
build_hash: 36c2d234498c2bc4f60773ab8df632af4067f43b
go_version: go1.23.2
version: v0.39.1
Expand Down
9 changes: 9 additions & 0 deletions pkg/resource/db_instance/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,12 @@ func setDeleteDBInstanceInput(
input.DeleteAutomatedBackups = params.DeleteAutomatedBackup
return nil
}

// needStorageUpdate
func needStorageUpdate(
r *resource,
delta *ackcompare.Delta,
) bool {
return strings.Contains(*r.ko.Status.DBInstanceStatus, "storage-full") &&
delta.DifferentAt("Spec.AllocatedStorage")
}
2 changes: 1 addition & 1 deletion pkg/resource/db_instance/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ackcondition.SetSynced(desired, corev1.ConditionTrue, nil, nil)
return desired, nil
}
if !instanceAvailable(latest) {
if !instanceAvailable(latest) && !needStorageUpdate(latest, delta) {
msg := "DB instance cannot be modifed while in '" + *latest.ko.Status.DBInstanceStatus + "' status"
ackcondition.SetSynced(desired, corev1.ConditionFalse, &msg, nil)
return desired, requeueWaitUntilCanModify(latest)
Expand Down

0 comments on commit cfe16d6

Please sign in to comment.