fix: keep MSK configurations and RDS events in the request region (#5940)

* fix(msk): keep configurations in the region that created them

MSK clusters became regional in #3353, but configurations did not:
ListConfigurations returned every region's, DescribeConfiguration and the
tag operations answered for another region's ARN, and a configuration name
used in one region could not be reused in another. Each now considers only
configurations whose ARN names the request region. The ARN has always
carried that region, so no record needs migrating.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(rds): list only the request region's events in DescribeEvents

DescribeEvents took no region and scanned the whole event store, so each
region saw the events of instances and clusters in the others. The handler
now passes the request region, and an event is listed in the region its
source ARN names; an event recorded without a source ARN stays visible, as
before.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

---------

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-18 14:12:51 -04:00
1 parent dd832b45dc
commit 317074e303
6 files changed
+68 -16

No files matched your search

@@ -180,6 +180,24 @@ class MskServiceTest {
assertEquals(0, mskService.listClusters().size());
}
@Test
void configurationsAreRegionalLikeClusters() {
MskConfiguration east = mskService.createConfiguration("shared-config", "desc", List.of("3.6.0"), "props");
when(regionResolver.getRegion()).thenReturn("eu-west-1");
// The same name is free in another region, and each region lists and reads only its own.
MskConfiguration west = mskService.createConfiguration("shared-config", "desc", List.of("3.6.0"), "props");
assertEquals(List.of(west), mskService.listConfigurations(null, null).items());
AwsException describe = assertThrows(AwsException.class,
() -> mskService.describeConfiguration(east.getArn()));
assertEquals("BadRequestException", describe.getErrorCode());
assertThrows(AwsException.class, () -> mskService.listTagsForResource(east.getArn()));
when(regionResolver.getRegion()).thenReturn("us-east-1");
assertEquals(List.of(east), mskService.listConfigurations(null, null).items());
assertEquals(east, mskService.describeConfiguration(east.getArn()));
}
@Test
void deleteCluster() {
MskCluster cluster = mskService.createCluster("test-cluster");
@@ -292,7 +292,7 @@ class RdsQueryHandlerTest {
void describeEvents_reconcilesOnlyTheRequestedDbInstance() {
DbInstance requested = makeInstance("requested");
when(service.listDbInstances("requested", null)).thenReturn(List.of(requested));
when(service.describeEvents("requested", "db-instance", null, null, null))
when(service.describeEvents(null, "requested", "db-instance", null, null, null))
.thenReturn(List.of());
MultivaluedMap<String, String> p = params();
p.add("SourceIdentifier", "requested");
@@ -308,7 +308,7 @@ class RdsQueryHandlerTest {
@Test
void describeEvents_doesNotReconcileInstancesForAnotherSourceType() {
when(service.describeEvents("cluster", "db-cluster", null, null, null))
when(service.describeEvents(null, "cluster", "db-cluster", null, null, null))
.thenReturn(List.of());
MultivaluedMap<String, String> p = params();
p.add("SourceIdentifier", "cluster");
@@ -3529,7 +3529,7 @@ class RdsServiceTest {
listener.onAutoPause(AutoPauseListener.Event.RESUMED, start.plusSeconds(91));
List<RdsEvent> events = rdsService.describeEvents(
"paused-1", "db-instance", start.minusSeconds(1), start.plusSeconds(120), null);
"us-east-1", "paused-1", "db-instance", start.minusSeconds(1), start.plusSeconds(120), null);
assertEquals(List.of(
"Initiated pause for the DB instance.",
"Successfully paused the DB instance.",
@@ -9026,14 +9026,14 @@ class RdsServiceTest {
assertEquals(DbInstanceStatus.FAILED, refreshed.getStatus());
verify(proxyManager).stopProxy("rds-resource:" + refreshed.getDbInstanceArn());
List<RdsEvent> events = rdsService.describeEvents("dead-db", "db-instance", null, null, 60);
List<RdsEvent> events = rdsService.describeEvents("us-east-1", "dead-db", "db-instance", null, null, 60);
assertEquals(1, events.size());
assertEquals(List.of("availability"), events.getFirst().eventCategories());
assertEquals(refreshed.getDbInstanceArn(), events.getFirst().sourceArn());
// Repeated health reads do not duplicate the transition event.
rdsService.refreshDbInstanceRuntimeHealth(refreshed);
assertEquals(1, rdsService.describeEvents("dead-db", "db-instance", null, null, 60).size());
assertEquals(1, rdsService.describeEvents("us-east-1", "dead-db", "db-instance", null, null, 60).size());
}
@Test
@@ -9049,7 +9049,7 @@ class RdsServiceTest {
assertEquals(DbInstanceStatus.AVAILABLE, refreshed.getStatus());
verify(proxyManager, never()).stopProxy("rds-resource:" + refreshed.getDbInstanceArn());
assertTrue(rdsService.describeEvents("blip-db", "db-instance", null, null, 60).isEmpty());
assertTrue(rdsService.describeEvents("us-east-1", "blip-db", "db-instance", null, null, 60).isEmpty());
}
@Test
@@ -9071,7 +9071,7 @@ class RdsServiceTest {
assertEquals(DbInstanceStatus.FAILED, afterDefiniteAnswer.getStatus());
verify(proxyManager).stopProxy(proxyKey);
verify(containerManager, times(2)).probeContainer("cont-id");
assertEquals(1, rdsService.describeEvents("recover-db", "db-instance", null, null, 60).size());
assertEquals(1, rdsService.describeEvents("us-east-1", "recover-db", "db-instance", null, null, 60).size());
}
@Test
@@ -9089,13 +9089,31 @@ class RdsServiceTest {
eventStore.put(retained.id(), retained);
List<RdsEvent> result = rdsService.describeEvents(
null, null, now.minus(Duration.ofDays(20)), now.plusSeconds(1), null);
"us-east-1", null, null, now.minus(Duration.ofDays(20)), now.plusSeconds(1), null);
assertEquals(List.of(retained), result);
assertTrue(eventStore.get("retained").isPresent());
assertTrue(eventStore.get("expired").isEmpty());
}
@Test
void describeEventsListsOnlyTheRequestRegionsEvents() throws Exception {
InMemoryStorage<String, RdsEvent> eventStore = new InMemoryStorage<>();
Field eventsField = RdsService.class.getDeclaredField("events");
eventsField.setAccessible(true);
eventsField.set(rdsService, eventStore);
Instant now = Instant.now();
RdsEvent east = new RdsEvent("east", "db-east", "db-instance", "created", List.of("creation"),
now.minusSeconds(60), "arn:aws:rds:us-east-1:123456789012:db:db-east");
RdsEvent west = new RdsEvent("west", "db-west", "db-instance", "created", List.of("creation"),
now.minusSeconds(60), "arn:aws:rds:eu-west-1:123456789012:db:db-west");
eventStore.put(east.id(), east);
eventStore.put(west.id(), west);
assertEquals(List.of(east), rdsService.describeEvents("us-east-1", null, null, null, null, null));
assertEquals(List.of(west), rdsService.describeEvents("eu-west-1", null, null, null, null, null));
}
@Test
void optionGroupsUseTheInjectedAccountAwareStorage() {
String accountId = "123456789012";