Skip to content

Add Exponential/Backoff retry to GetResourceTags #4710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2025
Merged

Conversation

harishxr
Copy link
Contributor

@harishxr harishxr commented Jul 11, 2025

Summary

This PR enhances the ECS Agent's GetResourceTags function by implementing exponential backoff and retry logic for resource tag retrieval. The implementation addresses potential transient failures when interacting with the ECS API, particularly focusing on handling throttling and rate limiting scenarios.

Implementation details

The GetResourceTags function now includes an exponential backoff mechanism using retry.NewExponentialBackoff with configurable parameters. It implements context-aware retry logic, using context.WithTimeout for overall operation timeout and properly handling context cancellation. The function now differentiates between transient and non-transient errors, with special handling for throttling and rate limit exceeded cases. Structured logging has been implemented, providing detailed error information including resource ARN and attempt counts.

Testing

  • Manual testing was performed using Apache Benchmark with concurrent requests to verify the exponential backoff and retry mechanism worked when facing throttling when calling ${ECS_CONTAINER_METADATA_URI_V4}/taskWithTags

New tests cover the changes: yes

The TestGetResourceTags and `TestGetResourceTagsError functions verify successful tag retrieval and error handling respectively. The TestGetResourceTagsWithRetry function covers various retry scenarios including success after throttling, server exceptions, and mixed transient errors. It also tests non-transient error handling and multiple throttling retry scenarios. The tests verify retry behavior, error message formatting, attempt counting, and different error type handling.

Description for the changelog

Add Exponential/Backoff retry to GetResourceTags

Additional Information

Does this PR include breaking model changes? If so, Have you added transformation functions?

Does this PR include the addition of new environment variables in the README?

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@harishxr harishxr requested a review from a team as a code owner July 11, 2025 07:04
@harishxr harishxr changed the title [WIP]Add Exponential/Backoff retry to GetResourceTags Add Exponential/Backoff retry to GetResourceTags Jul 11, 2025
@harishxr harishxr merged commit f913eb3 into aws:dev Jul 15, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants