Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DBInstance] Revert isEngineMutable check to use previous model for same engine check #498

Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -143,7 +143,8 @@ ApiVersion.DEFAULT, safeAddTags(this::createDbInstance)
}, CallbackContext::isAddTagsComplete, CallbackContext::setAddTagsComplete))
.then(progress -> ensureEngineSet(rdsProxyClient.defaultClient(), progress))
.then(progress -> {
if (ResourceModelHelper.shouldUpdateAfterCreate(progress.getResourceModel())) {
final DBInstance dbInstance = fetchDBInstance(rdsProxyClient.defaultClient(), model);
if (ResourceModelHelper.shouldUpdateAfterCreate(progress.getResourceModel(), dbInstance.engine())) {
return Commons.execOnce(progress, () -> {
progress.getCallbackContext().timestampOnce(RESOURCE_UPDATED_AT, Instant.now());
return versioned(proxy, rdsProxyClient, progress, null, ImmutableMap.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ public static RestoreDbInstanceFromDbSnapshotRequest restoreDbInstanceFromSnapsh
builder.storageThroughput(model.getStorageThroughput());
builder.storageType(model.getStorageType());
}

if (ResourceModelHelper.isOracleCDBEngine(model.getEngine())) {
builder.engine(null);
}

return builder.build();
}

Expand Down Expand Up @@ -388,6 +393,11 @@ static RestoreDbInstanceToPointInTimeRequest restoreDbInstanceToPointInTimeReque
builder.storageThroughput(model.getStorageThroughput());
builder.storageType(model.getStorageType());
}

if (ResourceModelHelper.isOracleCDBEngine(model.getEngine())) {
builder.engine(null);
}

return builder.build();
}

Expand Down Expand Up @@ -599,7 +609,6 @@ public static ModifyDbInstanceRequest modifyDbInstanceAfterCreateRequest(final R
.engineVersion(model.getEngineVersion())
moataz-mhmd marked this conversation as resolved.
Show resolved Hide resolved
.manageMasterUserPassword(model.getManageMasterUserPassword())
.masterUserPassword(model.getMasterUserPassword())
.masterUserPassword(model.getMasterUserPassword())
moataz-mhmd marked this conversation as resolved.
Show resolved Hide resolved
.masterUserSecretKmsKeyId(model.getMasterUserSecret() != null ? model.getMasterUserSecret().getKmsKeyId() : null)
.maxAllocatedStorage(model.getMaxAllocatedStorage())
.monitoringInterval(model.getMonitoringInterval())
Expand All @@ -614,6 +623,11 @@ public static ModifyDbInstanceRequest modifyDbInstanceAfterCreateRequest(final R
builder.storageThroughput(model.getStorageThroughput());
builder.storageType(model.getStorageType());
}

if (ResourceModelHelper.isOracleCDBEngine(model.getEngine())) {
builder.engine(model.getEngine());
moataz-mhmd marked this conversation as resolved.
Show resolved Hide resolved
}

return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static boolean isUpgradeToAuroraMySQL(final ResourceModel previous, final Resour
}

static boolean isEngineMutable(final ResourceModel previous, final ResourceModel desired, final String currentEngine) {
return Objects.equal(currentEngine, desired.getEngine()) ||
return Objects.equal(previous.getEngine(), desired.getEngine()) ||
isUpgradeToAuroraMySQL(previous, desired) ||
isUpgradeToOracleSE2(previous, desired) ||
isOracleConvertToCDB(currentEngine, desired);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ public final class ResourceModelHelper {
private static final String SQLSERVER_ENGINE = "sqlserver";
private static final String MYSQL_ENGINE_PREFIX = "mysql";
private static final String ORACLE_ENGINE_PREFIX = "oracle";
private static final String ORACLE_SE2_CDB = "oracle-se2-cdb";
private static final String ORACLE_EE_CDB = "oracle-ee-cdb";

public static boolean shouldUpdateAfterCreate(final ResourceModel model) {
public static boolean shouldUpdateAfterCreate(final ResourceModel model,
final String dbInstanceEngine) {
return (isReadReplica(model) ||
isRestoreFromSnapshot(model) ||
isRestoreFromClusterSnapshot(model) ||
Expand All @@ -39,7 +42,8 @@ public static boolean shouldUpdateAfterCreate(final ResourceModel model) {
(isSqlServer(model) && isStorageParametersModified(model)) ||
BooleanUtils.isTrue(model.getManageMasterUserPassword()) ||
BooleanUtils.isTrue(model.getDeletionProtection()) ||
BooleanUtils.isTrue(model.getEnablePerformanceInsights())
BooleanUtils.isTrue(model.getEnablePerformanceInsights()) ||
ImmutabilityHelper.isOracleConvertToCDB(dbInstanceEngine, model)
);
}

Expand Down Expand Up @@ -173,4 +177,8 @@ public static String getAutomaticBackupReplicationRegion(final ResourceModel mod
}
return model.getAutomaticBackupReplicationRegion();
}

public static boolean isOracleCDBEngine(final String engine) {
return ORACLE_EE_CDB.equalsIgnoreCase(engine) || ORACLE_SE2_CDB.equalsIgnoreCase(engine);
}
}
Loading
Loading