fix(config): drop a conformance pack's tags when the pack is deleted (#5779)

* fix(config): drop a conformance pack's tags when the pack is deleted

* fix(config): serialize PutConformancePack and DeleteConformancePack per pack

An update Put is a get-then-put. A Delete landing between the two removed
the pack and its tags, then the Put re-inserted it under the old ARN: the
Delete reported success while the pack survived with its tags gone. Both
operations now take the per-key lock aggregation authorizations already use.

* test(config): force the pack update/delete overlap instead of sampling it

Replace the 100,000-round race sample with a deterministic test, as
SnsPolicyAndSandboxEditsTest does: park PutConformancePack in its persist
(inside the per-pack lock), start DeleteConformancePack, and assert with
ThreadStates.awaitBlockedOrDone that the delete waits. Removing the lock
from either put or delete fails it.

* test: share ParkingStore in floci.testing, parking the next read or write

Moves the two private copies (SNS parked a read, Config parked a write)
into one store next to ThreadStates; the caller arms parkNextRead or
parkNextWrite.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-10-16 20:36:55 -04:00
1 parent a70b9b8d55
commit f7240b8ace
5 files changed
+207 -56

No files matched your search

@@ -821,33 +821,47 @@ public class AwsConfigService {
// --- Conformance Packs ---
/** Put on an existing pack is a get-then-put, so it runs under the lock delete takes. Unlocked,
* a delete landing between the get and the put would remove the pack and its tags, and the
* put would then re-insert it under its old ARN: a successful delete, a pack that survives,
* and tags silently gone. */
public ConformancePack putConformancePack(String region, String packName,
String templateS3Uri, String templateBody) {
Map<String, ConformancePack> store = packsFor(region);
ConformancePack existing = store.get(packName);
if (existing != null) {
ConformancePack updated = new ConformancePack(existing.conformancePackName(), existing.conformancePackArn(),
existing.conformancePackId(), templateS3Uri, templateBody);
store.put(packName, updated);
synchronized (lockFor(conformancePackLockKey(region, packName))) {
Map<String, ConformancePack> store = packsFor(region);
ConformancePack existing = store.get(packName);
if (existing != null) {
ConformancePack updated = new ConformancePack(existing.conformancePackName(),
existing.conformancePackArn(), existing.conformancePackId(), templateS3Uri, templateBody);
store.put(packName, updated);
persistRegion(conformancePacks, region);
return updated;
}
String packId = "conformance-pack-" + shortId();
String packArn = AwsArnUtils.Arn.of("config", region, regionResolver.getAccountId(),
"conformance-pack/" + packName + "/" + packId).toString();
ConformancePack pack = new ConformancePack(packName, packArn, packId, templateS3Uri, templateBody);
store.put(packName, pack);
persistRegion(conformancePacks, region);
return updated;
return pack;
}
String packId = "conformance-pack-" + shortId();
String packArn = AwsArnUtils.Arn.of("config", region, regionResolver.getAccountId(),
"conformance-pack/" + packName + "/" + packId).toString();
ConformancePack pack = new ConformancePack(packName, packArn, packId, templateS3Uri, templateBody);
store.put(packName, pack);
persistRegion(conformancePacks, region);
return pack;
}
public void deleteConformancePack(String region, String packName) {
Map<String, ConformancePack> store = packsFor(region);
if (store.remove(packName) == null) {
throw new AwsException("NoSuchConformancePackException",
"Conformance pack '" + packName + "' does not exist.", 400);
synchronized (lockFor(conformancePackLockKey(region, packName))) {
Map<String, ConformancePack> store = packsFor(region);
ConformancePack removed = store.remove(packName);
if (removed == null) {
throw new AwsException("NoSuchConformancePackException",
"Conformance pack '" + packName + "' does not exist.", 400);
}
persistRegion(conformancePacks, region);
tags.remove(removed.conformancePackArn());
}
persistRegion(conformancePacks, region);
}
private static String conformancePackLockKey(String region, String packName) {
return "conformance-pack|" + region + "|" + packName;
}
public List<ConformancePack> describeConformancePacks(String region, List<String> names) {