Fallback to iterative DescribeLogGroups if batch not supported #1915
+134
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the issue
In #1717, we implemented batching for
DescribeLogGroups
(DLG) calls using theLogGroupIdentifiers
parameter to reduce API throttling when customers have many log groups. However, this batched DLG API is not supported in all cases. When unsupported, the agent fails with anInvalidParameterException
error:"Input filter on Log group identifiers is not supported."
, preventing log group retention policies from being checked and updated.Description of changes
This PR adds a fallback mechanism to handle regions where the batched DLG API is not available:
Primary path: Attempts to use the batched
DescribeLogGroups
API withLogGroupIdentifiers
(introduced in Batch DescribeLogGroups calls #1717)Fallback path: If the batch call fails with the specific unsupported error, falls back to individual
DescribeLogGroups
calls usingLogGroupNamePrefix
for each log group. This is the same logic that was in the agent before.Implementation details:
updateTargetBatch()
→updateTargets()
which orchestrates the batch-first approachupdateTargetsBatch()
for the batched API call (returns error if not supported)updateTargetsIteratively()
for the fallback individual API callsgetRetention()
helper to retrieve retention using prefix-based lookupInvalidParameterException
error code AND exact error message to avoid false positivesLicense
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
Requirements
Before commiting your code, please do the following steps.
make fmt
andmake fmt-sh
make lint
Integration Tests
To run integration tests against this PR, add the
ready for testing
label.