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

aws: check for all possible Terminated states #6166

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

tomwans
Copy link
Contributor

@tomwans tomwans commented Oct 2, 2023

What type of PR is this?
/kind bug

What this PR does / why we need it:
It's possible that an EC2 instance is in the Terminated state for multiple autoscaler loops, so to avoid trying to terminate it more than once and causing the bug seen for this initial fix, we include this check as well.

Also, make the log more verbose and write out what state we found the instance in.

This builds upon this change: #5411

It's possible that an EC2 instance is in the Terminated state for
multiple autoscaler loops, so to avoid trying to terminate it more
than once and causing the bug seen for this initial fix, we include
this check as well.

Also, make the log more verbose and write out what state we found the
instance in.
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 2, 2023
@k8s-ci-robot k8s-ci-robot added area/provider/aws Issues or PRs related to aws provider area/cluster-autoscaler labels Oct 2, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @tomwans!

It looks like this is your first PR to kubernetes/autoscaler 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/autoscaler has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 2, 2023
Copy link
Contributor

@drmorr0 drmorr0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomwans Hi! Thanks for the PR, and also for adding a test in. I'm a bit confused on the test; it seems like there are two instances, and one of them was already in the terminating state? So we expect the instance count to go from 2 -> 1? But at the end we are asserting that the target size is still 2. Maybe I'm missing something, though.

@tomwans
Copy link
Contributor Author

tomwans commented Oct 3, 2023

@drmorr0 thanks for the review. I cleaned up the test a bit, please let me know how it looks now. It just seems like the TerminatingWait test was copy pasted from something else, with light adjustments. The expectedInstanceCount variable is not really relevant, it was just a distraction. I reworded some of that from the Terminated test I added.

If you'd like, I can copy paste this and do the same for the TerminatingWait test, so they look the same. Or, I can just bring them all in to one test and do a table test, which might be fine since we expect the same result out of all the states anyway. I have no preference. What do you think?

@drmorr0
Copy link
Contributor

drmorr0 commented Oct 3, 2023

@drmorr0 thanks for the review. I cleaned up the test a bit, please let me know how it looks now. It just seems like the TerminatingWait test was copy pasted from something else, with light adjustments. The expectedInstanceCount variable is not really relevant, it was just a distraction. I reworded some of that from the Terminated test I added.

If you'd like, I can copy paste this and do the same for the TerminatingWait test, so they look the same. Or, I can just bring them all in to one test and do a table test, which might be fine since we expect the same result out of all the states anyway. I have no preference. What do you think?

@tomwans If you have some time and it's not terribly difficult, putting into a table test would be nice, I guess? But I don't have particularly strong feelings on the matter, so if you don't have time/want to just ship it, I'll stamp it.

@tomwans
Copy link
Contributor Author

tomwans commented Oct 3, 2023

Let's just stamp it out. Theres no other case of table tests in this test file, so it wouldn't be matching conventions anyway.

@drmorr0
Copy link
Contributor

drmorr0 commented Oct 3, 2023

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 3, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: drmorr0, tomwans

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 3, 2023
@k8s-ci-robot k8s-ci-robot merged commit 53ca6b9 into kubernetes:master Oct 3, 2023
tomwans added a commit to lyft/autoscaler that referenced this pull request Oct 9, 2023
Brings in:

kubernetes#5411
kubernetes#6166

But the code is so different I manually brought it up to speed.
tomwans added a commit to lyft/autoscaler that referenced this pull request Oct 11, 2023
bring up AWS patch for termination
Brings in:

kubernetes#5411
kubernetes#6166

But the code is so different I manually brought it up to speed.

Also, I added a patch to make tests pass in the latest version of Go.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster-autoscaler area/provider/aws Issues or PRs related to aws provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants