Skip to content

Commit

Permalink
fix(DBCluster): fix NPE when null capacity specified for Serverless V2
Browse files Browse the repository at this point in the history
  • Loading branch information
zrfr authored and angusy29 committed Jan 8, 2025
1 parent e314edb commit 9b354f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public static ResourceModel setDefaults(final ResourceModel resourceModel) {
}

final var serverlessV2ScalingConfiguration = resourceModel.getServerlessV2ScalingConfiguration();
if (serverlessV2ScalingConfiguration != null && serverlessV2ScalingConfiguration.getMinCapacity() == 0) {
final var isServerlessV2 = serverlessV2ScalingConfiguration != null;
final var isAutoPause = isServerlessV2 && serverlessV2ScalingConfiguration.getMinCapacity() != null
&& serverlessV2ScalingConfiguration.getMinCapacity() == 0;
if (isAutoPause) {
if (serverlessV2ScalingConfiguration.getSecondsUntilAutoPause() == null) {
serverlessV2ScalingConfiguration.setSecondsUntilAutoPause(DEFAULT_SECONDS_UNTIL_AUTO_PAUSE_V2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,11 +830,12 @@ void handleRequest_EngineVersionUpdateIfMismatch() {
"1, , 3, , ", // modify minCapacity
"1, , 0, 600, 600", // enable auto-pause with specific seconds until auto-pause
"1, , 0, , 300", // enable auto-pause with default seconds until auto-pause
"0, 600, 0, , 300" // reset seconds until auto-pause to default
"0, 600, 0, , 300", // reset seconds until auto-pause to default
" , , 3, , " // update from null to non-null capacity [CFN-582]
})
void handleRequest_ServerlessV2ScalingConfiguration_Success(
final double minCapacityBefore, final Integer secondsUntilAutoPauseBefore,
final double minCapacityAfter, final Integer secondsUntilAutoPauseAfter,
final Double minCapacityBefore, final Integer secondsUntilAutoPauseBefore,
final Double minCapacityAfter, final Integer secondsUntilAutoPauseAfter,
final Integer expectedSecondsUntilAutoPause) {
when(rdsProxy.client().modifyDBCluster(any(ModifyDbClusterRequest.class)))
.thenReturn(ModifyDbClusterResponse.builder().build());
Expand Down

0 comments on commit 9b354f9

Please sign in to comment.