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

EC2 Waiter waitUntilInstanceRunning Hanging When DescribeInstancesRequest Empty #5095

Open
Petersoj opened this issue Apr 11, 2024 · 5 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue service:ec2

Comments

@Petersoj
Copy link

Describe the bug

The following code hangs indefinitely when there are no pending EC2 instances and only running EC2 instances. Adding both pending and running to the filter works properly, but intuitively, it seems like when DescribeInstancesRequest returns no instances, the waiter should return or fail, not wait indefinitely.

ec2Client.waiter().waitUntilInstanceRunning(DescribeInstancesRequest.builder()
         .filters(Filter.builder()
                 .name("instance-state-name")
                 .values("pending")
                 .build())
         .build());

Expected Behavior

The waitUntilInstanceRunning call to return immediately when the DescribeInstancesRequest yields no instances.

Current Behavior

The waitUntilInstanceRunning call with the aforementioned DescribeInstancesRequest and running EC2 instance states hangs and waits indefinitely.

Reproduction Steps

See description.

Possible Solution

When the DescribeInstancesRequest given to the waitUntilInstanceRunning yields an empty result (no instances), the waiter should succeed and return immediately. This may have unintended consequences so perhaps it should just fail or the WaiterOverrideConfiguration could have an option to allow empty results from the DescribeInstancesRequest.

Additional Information/Context

No response

AWS Java SDK version used

2.25.15

JDK version used

21

Operating System and version

Linux Ubuntu 22.04

@Petersoj Petersoj added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 11, 2024
@bhoradc bhoradc self-assigned this Apr 11, 2024
@bhoradc bhoradc added service:ec2 p2 This is a standard priority issue needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 11, 2024
@bhoradc
Copy link

bhoradc commented Apr 23, 2024

Hi @Petersoj,

Thank you for reporting the issue. I am able to reproduce the scenario. I will take this forward to discuss with the Java SDK team.

Regards,
Chaitanya

@bhoradc bhoradc added needs-review This issue or PR needs review from the team. and removed needs-reproduction This issue needs reproduction. labels Apr 23, 2024
@Petersoj
Copy link
Author

Petersoj commented Apr 23, 2024

@bhoradc that's great to hear.
And just FYI, when I stated "indefinitely" in my original post, I forgot to mention that I was using a modified WaiterOverrideConfiguration that effectively made the waiter() hang indefinitely. Of course, without the override, the waiter eventually times out and throws based on the default waiter configuration.

@bhoradc
Copy link

bhoradc commented Apr 23, 2024

Yes, that makes sense. Thanks for mentioning it though.

Regards,
Chaitanya

@bhoradc
Copy link

bhoradc commented Apr 25, 2024

Hi @Petersoj,

This happens to be an expected behaviour with the ec2Client.waiter().waitUntilInstanceRunning() when filtered with pending state instances.

The InstanceRunning condition doesn't check or isn't designed to check for the pending state as per the reference.

If you want to independently filter out for pending state instances, you may want to work with waitUntilInstanceStopped() or waitUntilInstanceTerminated().

Please let me know if that helps or if you have further queries.

Regards,
Chaitanya

@bhoradc bhoradc added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. and removed needs-review This issue or PR needs review from the team. labels Apr 25, 2024
@Petersoj
Copy link
Author

Thanks for the info. I understand this is expected behavior, but my objective with this issue is to show how this behavior seems unintuitive and should be changed as noted in my original post.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue service:ec2
Projects
None yet
Development

No branches or pull requests

2 participants