-
-
Notifications
You must be signed in to change notification settings - Fork 310
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
Implement support for handling instance termination protection #275
Conversation
2313114
to
303477e
Compare
I managed to write some tests and refactor the code a bit in the process, still needs to be tested against real AWS infrastructure. |
- determine instance termination protection only when we are about to replace the on-demand instances, to avoid unnecessary API calls when scanning instances on all Lambda function runs - write tests for instance termination protection and scale-in protection - define instanceMap type as map[string]*instance - fix tests after refactoring the instance scanning logic in a previous commit
6ea8662
to
b29813a
Compare
I tested it against real infrastructure and it works pretty well. |
Last chance to review this, I will merge it as it is on Friday unless I get any objections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most minor nits, the rest looks good to me.
Refactorings look nice, instanceMap makes things more readable.
Also, gofmt had minor complaints, that you might want to address.
Edit:
- thanks for review!
- I couldn't reproduce the gofmt issues
$ make fmt-check
ok all files passed go fmt
core/autoscaling.go
Outdated
@@ -335,11 +335,11 @@ func (a *autoScalingGroup) process() { | |||
logger.Println("No spot instances were found for ", a.name) | |||
|
|||
// find any given on-demand instance and try to replace it with a spot one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could consider adding 'unprotected' before 'on-demand'. The function below has a nice explaining name, so that could be enough to not need the more specific comment.
There is one more case of this throughout the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
I deleted the comments, they should only explain why are we doing some harder to grasp things, not mention once again what are we're doing, which should be seen clearly in the code itself.
@lenucksi thanks for the review, I'll try to address these issues and I hope I can finally merge this tomorrow. |
Issue Type
Summary
This implements handling of the instance termination protection flag, requested as part of #267.
Current status:
region.scanInstances()
function, which wasn't tested before, and are currently failing. I could use some help on getting them pass, since this is a bit harder to mock because of the pagination.ec2.DescribeInstanceAttribute
API calls, one per each instance, so it may need to be configurable for people who don't want to do all these calls. I think we should also do these calls only for on-demand instances running in ASGs, but this scope filtering is not implemented yet.Code contribution checklist
to it.
guidelines.
test coverage doesn't decrease.
make full-test
.variables which are also passed as parameters to the
CloudFormation
and
Terraform
stacks defined as infrastructure code.
support per-group overrides using tags.
configurations.
proven to work using log output from various test runs.
appropriate) and formatted consistently to the existing log output.
new configuration options for both stack parameters and tag overrides.
contribution actually resolves it.