You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DescribeClusters API has a 100-element limit. Users with >100 clusters got InvalidParameterException. Added batching (chunks of 100) matching existing pattern in tasks/dao.go and services/dao.go.
This PR fixes a critical bug where users with >100 ECS clusters would encounter InvalidParameterException due to AWS API limits. The fix implements batching for the DescribeClusters API call, matching patterns already established in the codebase.
Code Quality ✅
Strengths:
Consistent Pattern: The batching implementation in custom/ecs/clusters/dao.go:55-75 correctly follows the existing pattern used in tasks/dao.go:95-117 and services/dao.go:90-114
Clean Implementation: The batch size of 100 is appropriate and matches the AWS API limit for DescribeClusters
Proper Slicing: Correctly handles the last batch with end = len(clusterArns) to avoid slice bounds issues
When a batch fails, the function continues and returns partial results without indicating some clusters were skipped. This matches the pattern in tasks/dao.go and services/dao.go, so it's consistent with the codebase design.
However, consider whether users should be notified when cluster information is incomplete. The current silent failure could lead to confusion if users expect to see all clusters but only receive some.
Options:
Keep current behavior (consistent with existing code) ✅
Return a wrapped error that includes partial results
Add a summary log after the loop indicating total clusters vs. successfully described
For this PR, option 1 is appropriate since you're matching established patterns.
Optimal Batch Size: Using 100 (the API limit) minimizes API calls
No Unnecessary Copies: Direct append to resources slice is efficient
The implementation should handle large cluster counts efficiently. For 1000 clusters, this reduces API calls from potentially timing out on a single 1000-element request to 10 manageable batches.
Security Concerns ✅
No security issues identified:
No user input is directly used in AWS API calls
Context is properly threaded through
No credential handling changes
Follows AWS SDK best practices
Test Coverage ⚠️
Missing: No test file exists for custom/ecs/clusters/dao.go
Recommendation: While this PR fixes a critical bug and should be merged, consider adding tests in a follow-up PR:
// custom/ecs/clusters/dao_test.gofuncTestClusterDAO_List_BatchesLargeCounts(t*testing.T) {
// Test with >100 clusters to verify batching// Mock ECS client to return 150 cluster ARNs// Verify DescribeClusters called twice (100 + 50)
}
funcTestClusterDAO_List_HandlesPartialFailure(t*testing.T) {
// Test that partial batch failures don't fail entire operation// Mock second batch to fail// Verify first batch results are still returned
}
This would match the test coverage pattern in custom/ecs/clusters/resource_test.go.
Additional Notes
Import Addition: The log import at dao.go:13 is necessary and correct
API Limit Documentation: The comment // Describe clusters in batches of 100 (API limit) is helpful and accurate
Backward Compatibility: This change is fully backward compatible - users with <100 clusters see no behavior change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Summary
Changes
DescribeClustersAPI has a 100-element limit. Users with >100 clusters gotInvalidParameterException. Added batching (chunks of 100) matching existing pattern intasks/dao.goandservices/dao.go.Merge