Skip to content

Commit

Permalink
fix(DBCluster): fix local write forwarding error on cluster update
Browse files Browse the repository at this point in the history
This change fixes an issue causing resource updates to fail with a
"Local Write Forwarding is already disabled/enabled on cluster" error.
The fix is to send EnableLocalWriteForwarding in the modify request only
when this property is actually changing.
  • Loading branch information
zrfr committed Jul 1, 2024
1 parent aac81a8 commit f9763d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static ModifyDbClusterRequest modifyDbClusterRequest(
.domainIAMRoleName(desiredModel.getDomainIAMRoleName())
.enableGlobalWriteForwarding(desiredModel.getEnableGlobalWriteForwarding())
.enableIAMDatabaseAuthentication(diff(previousModel.getEnableIAMDatabaseAuthentication(), desiredModel.getEnableIAMDatabaseAuthentication()))
.enableLocalWriteForwarding(desiredModel.getEnableLocalWriteForwarding())
.enableLocalWriteForwarding(diff(previousModel.getEnableLocalWriteForwarding(), desiredModel.getEnableLocalWriteForwarding()))
.enablePerformanceInsights(desiredModel.getPerformanceInsightsEnabled())
.iops(desiredModel.getIops())
.masterUserPassword(diff(previousModel.getMasterUserPassword(), desiredModel.getMasterUserPassword()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,25 @@ public void modifyDbClusterRequest_sameServerlessV2ScalingConfiguration() {
assertThat(request.serverlessV2ScalingConfiguration()).isEqualTo(null);
}

@Test
public void modifyDbClusterRequest_enableLocalWriteForwarding() {
final var previousModel = RESOURCE_MODEL.toBuilder().enableLocalWriteForwarding(null).build();

final var desiredModel = RESOURCE_MODEL.toBuilder().enableLocalWriteForwarding(true).build();

final var request = Translator.modifyDbClusterRequest(previousModel, desiredModel, IS_NOT_ROLLBACK);
assertThat(request.enableLocalWriteForwarding()).isEqualTo(true);
}

@Test
public void modifyDbClusterRequest_sameLocalWriteForwarding() {
final var previousModel = RESOURCE_MODEL.toBuilder().enableLocalWriteForwarding(false).build();
final var desiredModel = RESOURCE_MODEL.toBuilder().enableLocalWriteForwarding(false).build();

final var request = Translator.modifyDbClusterRequest(previousModel, desiredModel, IS_NOT_ROLLBACK);
assertThat(request.enableLocalWriteForwarding()).isNull();
}

@Test
public void test_translateDbClusterFromSdk_emptyDomainMembership() {
final DBCluster cluster = DBCluster.builder()
Expand Down

0 comments on commit f9763d1

Please sign in to comment.