Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,14 @@ protected ProgressEvent<ResourceModel, CallbackContext> updateDbInstance(
final AmazonWebServicesClientProxy proxy,
final ResourceHandlerRequest<ResourceModel> request,
final ProxyClient<RdsClient> rdsProxyClient,
final ProgressEvent<ResourceModel, CallbackContext> progress
final ProgressEvent<ResourceModel, CallbackContext> progress,
final DBInstance dbInstance
) {
return proxy.initiate("rds::modify-db-instance", rdsProxyClient, progress.getResourceModel(), progress.getCallbackContext())
.translateToServiceRequest(resourceModel -> Translator.modifyDbInstanceRequest(
request.getPreviousResourceState(),
request.getDesiredResourceState(),
dbInstance,
BooleanUtils.isTrue(request.getRollback()))
)
.backoffDelay(config.getBackoff())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import software.amazon.awssdk.services.rds.model.CloudwatchLogsExportConfiguration;
import software.amazon.awssdk.services.rds.model.CreateDbInstanceReadReplicaRequest;
import software.amazon.awssdk.services.rds.model.CreateDbInstanceRequest;
import software.amazon.awssdk.services.rds.model.DBInstance;
import software.amazon.awssdk.services.rds.model.DeleteDbInstanceRequest;
import software.amazon.awssdk.services.rds.model.DescribeDbClusterSnapshotsRequest;
import software.amazon.awssdk.services.rds.model.DescribeDbClustersRequest;
Expand All @@ -46,6 +47,7 @@
import software.amazon.awssdk.services.rds.model.StartDbInstanceAutomatedBackupsReplicationRequest;
import software.amazon.awssdk.services.rds.model.StopDbInstanceAutomatedBackupsReplicationRequest;
import software.amazon.awssdk.utils.StringUtils;
import software.amazon.cloudformation.exceptions.CfnInvalidRequestException;
import software.amazon.rds.common.handler.Commons;
import software.amazon.rds.common.handler.Tagging;
import software.amazon.rds.dbinstance.util.ResourceModelHelper;
Expand Down Expand Up @@ -444,6 +446,7 @@ public static ModifyDbInstanceRequest modifyDbInstanceRequestV12(
public static ModifyDbInstanceRequest modifyDbInstanceRequest(
final ResourceModel previousModel,
final ResourceModel desiredModel,
final DBInstance physicalDBInstance,
final Boolean isRollback
) {
final ModifyDbInstanceRequest.Builder builder = ModifyDbInstanceRequest.builder()
Expand Down Expand Up @@ -495,16 +498,29 @@ public static ModifyDbInstanceRequest modifyDbInstanceRequest(

if (BooleanUtils.isTrue(isRollback)) {
if (isProvisionedIoStorage(desiredModel)) {
builder.allocatedStorage(max(getAllocatedStorage(previousModel), getAllocatedStorage(desiredModel)));
// 3-way max between previous model, desired model and current instance storage
// because you cannot shrink storage in RDS
final Integer allocatedStorage = max(getAllocatedStorage(previousModel), getAllocatedStorage(desiredModel));
builder.allocatedStorage(max(physicalDBInstance.allocatedStorage(), allocatedStorage));
builder.iops(desiredModel.getIops());
}
} else {
builder.engineVersion(diff(previousModel.getEngineVersion(), desiredModel.getEngineVersion()));
final Integer allocatedStorageDiff = diff(getAllocatedStorage(previousModel), getAllocatedStorage(desiredModel));

// When you have an IOPS configurable storage type
// both parameters, allocatedStorage and iops MUST be specified in the modifyDBInstance call
if (isProvisionedIoStorage(desiredModel)) {
builder.allocatedStorage(getAllocatedStorage(desiredModel));
if (allocatedStorageDiff != null) {
// if user specifies allocated storage, then use it
builder.allocatedStorage(allocatedStorageDiff);
} else {
// if not, we should take max of physical and the template's in case their instance has scaled out
builder.allocatedStorage(max(physicalDBInstance.allocatedStorage(), getAllocatedStorage(desiredModel)));
}
builder.iops(desiredModel.getIops());
} else {
builder.allocatedStorage(diff(getAllocatedStorage(previousModel), getAllocatedStorage(desiredModel)));
builder.allocatedStorage(allocatedStorageDiff);
builder.iops(diff(previousModel.getIops(), desiredModel.getIops()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
progress.getCallbackContext().timestampOnce(RESOURCE_UPDATED_AT, Instant.now());
return versioned(proxy, rdsProxyClient, progress, null, ImmutableMap.of(
ApiVersion.V12, (pxy, pcl, prg, tgs) -> updateDbInstanceV12(pxy, request, pcl, prg),
ApiVersion.DEFAULT, (pxy, pcl, prg, tgs) -> updateDbInstance(pxy, request, pcl, prg)
ApiVersion.DEFAULT, (pxy, pcl, prg, tgs) -> {
final DBInstance dbInstance = fetchDBInstance(rdsProxyClient.defaultClient(), progress.getResourceModel());
return updateDbInstance(pxy, request, pcl, prg, dbInstance);
}
)).then(p -> Events.checkFailedEvents(
rdsProxyClient.defaultClient(),
p.getResourceModel().getDBInstanceIdentifier(),
Expand Down
Loading
Loading