-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Generate EC2 Instance Type list in runtime #2249
Conversation
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.
Tests are failing
FAIL k8s.io/autoscaler/cluster-autoscaler/cloudprovider/aws 0.114s
I will update the test case. |
bf7debb
to
42c0797
Compare
@mwielgus Tests have been fixed. Please have a review. |
/cc @MaciekPytel |
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.
👍
c28fd36
to
eedd1db
Compare
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.
still LGTM.
Sorry for late response. I will clean it up and submit revision |
d0bbe7e
to
27cf672
Compare
/hold |
27cf672
to
9179390
Compare
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.
++ lgtm. Would still prefer a const for the pricing URL, but that's something to do in a follow up.
9179390
to
87a7c28
Compare
87a7c28
to
6389b11
Compare
Move to const in latest change. |
6389b11
to
f52678e
Compare
/hold cancel In the latest change, we expose option to users whose network is restricted to call EC2 pricing service. |
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.
Yup, 👍
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.
Thanks. A few cleanup comments. Looks good otherwise.
var instanceTypes map[string]*InstanceType | ||
if opts.StaticInstanceList { | ||
klog.Warning("Use static EC2 Instance Types, list could be outdated") | ||
instanceTypes = GetStaticEC2InstanceTypes() |
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.
Possibly this method can also return the date when the list was last updated. Then you could add it to warning message to give clear singal how up-to-date data is.
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.
This is great suggestion.
I create a const and add constructions in the doc that everytime the list is updated, people need to update date correspondingly.
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.
Updated logs:
W1014 17:25:22.612552 75153 aws_cloud_provider.go:354] Use static EC2 Instance Types and list could be outdated. Last update time: 2019-10-14
I1014 17:25:22.612701 75153 reflector.go:120] Starting reflector *v1.PersistentVolumeClaim (0s) from k8s.io/client-go/informers/factory.go:134
|
||
func TestGetCurrentAwsRegionWithRegionEnv(t *testing.T) { | ||
region := "us-west-2" | ||
os.Setenv("AWS_REGION", region) |
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.
To be more correct please change to:
if oldRegion, found := os.LookupEnv("AWS_REGION"); found {
defer os.Setenv("AWS_REGION", oldRegion)
} else {
defer os.Unsetenv("AWS_REGION")
}
os.Setenv("AWS_REGION", region)
Possibly not needed if we have just above two places. Yet you may consider writing a short wrapper with signature:
func withEnv(variable string, variableValue string, f func())
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.
Great! This is precise. I make the changes. I didn't see any other place test env here. I will do refactor if I see more tests with similar setups.
f52678e
to
7eb8645
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: losipiuk 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 |
Any chance of this making it over to the 1.14-1.16 branches? I've got a couple of clusters I want to build on t5a instances which aren't in the static list. |
@Jeffwan can you look into porting to the older branches please? |
@jaypipes I mark this as a backport candidate in next release. |
#2240
We have some discussion here. #2231
Consider the case not all k8s clusters has network to aws pricing API, I still keep the static instance type list. If network is not accessible, it will fall back to static dict.
dynamic loading will reuse code snippet from gen.go
I am trying reach out to folks who worked on this, not sure if we have any internal IP like EC2 metadata service. If so, we can use that and assume it can always get updated list in the same network.
@jaypipes