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

Generate EC2 Instance Type list in runtime #2249

Merged
merged 1 commit into from
Oct 15, 2019

Conversation

Jeffwan
Copy link
Contributor

@Jeffwan Jeffwan commented Aug 12, 2019

#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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 12, 2019
Copy link
Contributor

@mwielgus mwielgus left a 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

@Jeffwan
Copy link
Contributor Author

Jeffwan commented Aug 14, 2019

Tests are failing

FAIL	k8s.io/autoscaler/cluster-autoscaler/cloudprovider/aws	0.114s

I will update the test case.

@Jeffwan
Copy link
Contributor Author

Jeffwan commented Aug 19, 2019

@mwielgus Tests have been fixed. Please have a review.

@Jeffwan
Copy link
Contributor Author

Jeffwan commented Aug 19, 2019

/cc @MaciekPytel

Copy link
Contributor

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

👍

cluster-autoscaler/cloudprovider/aws/aws_util_test.go Outdated Show resolved Hide resolved
@Jeffwan Jeffwan force-pushed the dynamic_ec2_list branch 2 times, most recently from c28fd36 to eedd1db Compare August 21, 2019 14:06
Copy link
Contributor

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

still LGTM.

cluster-autoscaler/cloudprovider/aws/aws_util.go Outdated Show resolved Hide resolved
@stefansedich
Copy link
Contributor

@Jeffwan any idea when this one might get in? We are aiming to move to g4dn instances and would be great to get either this or #2401 merged!

@Jeffwan
Copy link
Contributor Author

Jeffwan commented Oct 2, 2019

Sorry for late response. I will clean it up and submit revision

@Jeffwan Jeffwan force-pushed the dynamic_ec2_list branch 2 times, most recently from d0bbe7e to 27cf672 Compare October 9, 2019 22:01
@Jeffwan
Copy link
Contributor Author

Jeffwan commented Oct 9, 2019

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 9, 2019
Copy link
Contributor

@jaypipes jaypipes left a 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.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 10, 2019
@Jeffwan
Copy link
Contributor Author

Jeffwan commented Oct 10, 2019

++ lgtm. Would still prefer a const for the pricing URL, but that's something to do in a follow up.

Move to const in latest change.

@Jeffwan
Copy link
Contributor Author

Jeffwan commented Oct 10, 2019

/hold cancel

In the latest change, we expose option to users whose network is restricted to call EC2 pricing service.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 10, 2019
Copy link
Contributor

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

Yup, 👍

@Jeffwan Jeffwan requested review from losipiuk and mwielgus October 11, 2019 19:02
Copy link
Contributor

@losipiuk losipiuk left a 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()
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

@Jeffwan Jeffwan Oct 15, 2019

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

cluster-autoscaler/cloudprovider/aws/aws_util_test.go Outdated Show resolved Hide resolved

func TestGetCurrentAwsRegionWithRegionEnv(t *testing.T) {
region := "us-west-2"
os.Setenv("AWS_REGION", region)
Copy link
Contributor

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())

Copy link
Contributor Author

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.

cluster-autoscaler/FAQ.md Outdated Show resolved Hide resolved
@losipiuk
Copy link
Contributor

/lgtm
/approve
Thanks!

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

[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 /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 15, 2019
@k8s-ci-robot k8s-ci-robot merged commit 31b5118 into kubernetes:master Oct 15, 2019
@cablespaghetti
Copy link
Contributor

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.

@jaypipes
Copy link
Contributor

@Jeffwan can you look into porting to the older branches please?

@Jeffwan
Copy link
Contributor Author

Jeffwan commented Dec 26, 2019

@jaypipes I mark this as a backport candidate in next release.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants