fix(bedrock-agentcore): serialize runtime tags with deletion (#7721)

This commit is contained in:
Jackson Price authored and GitHub committed 2026-11-08 05:04:49 -04:00
1 parent 9822ad5f05
commit a28c52f951
4 files changed
+261 -67

No files matched your search

@@ -316,19 +316,29 @@ public class BedrockAgentCoreControlService {
// ──────────────────────────── Tagging (Phase 4) ────────────────────────────
public Map<String, String> getTagsByArn(String region, String arn) {
return new HashMap<>(getAgentRuntimeByArn(region, arn).getTags());
Map<String, String> snapshot = new HashMap<>();
updateRuntimeTags(region, arn, snapshot::putAll, false);
return snapshot;
}
public void tagByArn(String region, String arn, Map<String, String> tags) {
AgentRuntime runtime = getAgentRuntimeByArn(region, arn);
runtime.getTags().putAll(tags);
storage.put(key(region, runtime.getAgentRuntimeId()), runtime);
updateRuntimeTags(region, arn, runtimeTags -> runtimeTags.putAll(tags), true);
}
public void untagByArn(String region, String arn, List<String> keys) {
AgentRuntime runtime = getAgentRuntimeByArn(region, arn);
keys.forEach(runtime.getTags()::remove);
storage.put(key(region, runtime.getAgentRuntimeId()), runtime);
updateRuntimeTags(region, arn, runtimeTags -> keys.forEach(runtimeTags::remove), true);
}
private void updateRuntimeTags(String region, String arn, Consumer<Map<String, String>> change,
boolean persist) {
String runtimeId = getAgentRuntimeByArn(region, arn).getAgentRuntimeId();
synchronized (runtimeLock(region, runtimeId)) {
AgentRuntime runtime = getAgentRuntime(runtimeId, region);
change.accept(runtime.getTags());
if (persist) {
storage.put(key(region, runtimeId), runtime);
}
}
}
/** The runtime a runtime ARN names, at any version; ResourceNotFoundException when none does. */