Skip to content
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

Fix potential out of bounds panic #1266

Merged
merged 2 commits into from
Aug 9, 2024

Conversation

dricross
Copy link
Contributor

@dricross dricross commented Aug 1, 2024

Description of the issue

The TestTranslator/WithKubernetes/WithoutClusterName unit test is failing locally due to a panic in backoffSleep on this line: https://github.com/aws/amazon-cloudwatch-agent/blob/main/translator/translate/logs/util/get_eks_cluster_name.go#L117. The call to ec2.DescribeTags to attempt to find the Kubernetes cluster name is failing (due to an environment issue), and it retries 6 times. On the sixth attempt, it attempts to access sleeps[5] which is invalid causing a panic.

This panic behavior would happen outside unit testing if the ec2.DescribeTags call fails more than 5 times.

Description of changes

Maintain behavior of retrying 6 times, but only pull from pre-defined sleep durations on attempts 1-5. On 6th attempt, use default duration.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Create new unit test for function that was panicing. Before changes, the unit test panics regardless of environment configuration. After changes, the unit test does not panic.

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@dricross dricross requested a review from a team as a code owner August 1, 2024 16:44
@dricross dricross force-pushed the fix-backoff-sleep-panic branch from 4d3797a to 93f0920 Compare August 1, 2024 20:08
Copy link
Contributor

github-actions bot commented Aug 9, 2024

This PR was marked stale due to lack of activity.

@github-actions github-actions bot added the Stale label Aug 9, 2024
@dricross dricross merged commit 630e834 into aws:main Aug 9, 2024
6 checks passed
@dricross dricross deleted the fix-backoff-sleep-panic branch August 9, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants