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

Added OnDemand and Spot Price models addressing #131 #486

Closed
wants to merge 43 commits into from

Conversation

mrcrgl
Copy link

@mrcrgl mrcrgl commented Nov 23, 2017

No description provided.

…vity of the offer provided by the aws pricing api
# Conflicts:
#	cluster-autoscaler/cloudprovider/aws/ec2_instance_types.go
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 23, 2017
@mrcrgl mrcrgl changed the title Issue/131 Added OnDemand and Spot Price models addressing #131 Nov 23, 2017
@mrcrgl
Copy link
Author

mrcrgl commented Nov 23, 2017

Re-opened PR #484
Related to: #131


import "strconv"

// stringRefToFloat64 converts fields of type *float64 to float64 (fallback to zero value if nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

string to float?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it's used when transforming AWS API DTO's to local ones.
For instance at this place: https://github.com/kubernetes/autoscaler/pull/486/files#diff-fc9a082c5fda90baeac6f105e7a018b9R61

Would you suggest to not put it in a function?

Copy link

Choose a reason for hiding this comment

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

i think @mwielgus was referring to the comment.

Copy link

Choose a reason for hiding this comment

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

To be more specific, I believe this is the change wanted:

of type *float64 to float64 => of type *string to float64


// stringRefToFloat64 converts fields of type *float64 to float64 (fallback to zero value if nil)
// it's mostly used to handle aws api responds nicely
func stringRefToFloat64(p *string) (float64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the point of using *string. Strings are already pointers (slices).

Copy link
Author

Choose a reason for hiding this comment

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

It's the way AWS API's are designed, all values are pointers in their DTO's to carry the information whether the value is provided or not.
do you think it's more transparent for the reader to make that conversion on caller side?

Copy link

Choose a reason for hiding this comment

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

There is a package aws.String which lets you do all these type of conversion. You can use it instead of *string. https://docs.aws.amazon.com/sdk-for-go/api/aws/


// EC2LaunchConfiguration holds AWS EC2 Launch Configuration information
type EC2LaunchConfiguration struct {
HasSpotMarkedBid bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add comments to the fields.

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please email the CNCF helpdesk: [email protected]

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 23, 2017
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Nov 23, 2017
@mwielgus
Copy link
Contributor

mwielgus commented Nov 23, 2017

This PR is HUGE and not reviewable in the current form.

Please:

  • Provide a detailed explanation what are you doing and how to get the price for both regular and spot instances, so that your code can be validated against the description.

  • Consider splitting the PR into smaller PRs. PRs that are <200 LOC are MUCH easier to understand.
    Maybe spot / non spot. Maybe submit some utils first.

}

func newLCFakeService(
name string,
Copy link
Contributor

Choose a reason for hiding this comment

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

single line

}
type cases []testCase

var (
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for var, just :=


// EC2AutoscalingGroup holds AWS Autoscaling Group information
type EC2AutoscalingGroup struct {
Name string
Copy link
Contributor

Choose a reason for hiding this comment

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

Comments


// InstanceInfo holds AWS EC2 instance information
type InstanceInfo struct {
InstanceType string
Copy link
Contributor

Choose a reason for hiding this comment

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

Comments.

type instanceInfoService struct {
client httpClient
cache instanceInfoCache
mu sync.RWMutex
Copy link
Contributor

Choose a reason for hiding this comment

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

don't use single/two letter names for field in struct.
moreover you can do
type xxxx struct {
sync.RwMutex // <<<NO FIELD NAME.
}
and then just xxx.Lock().


type productOffers map[string]productOffer

type productOffer struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get these from some official library?

Copy link
Author

Choose a reason for hiding this comment

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

I didn't find anything about it, just started here (https://aws.amazon.com/blogs/aws/new-aws-price-list-api/) and moved over

Copy link

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Good point, I'll check that

Copy link
Contributor

Choose a reason for hiding this comment

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

Has this been checked?

Copy link
Author

Choose a reason for hiding this comment

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

Not yet in detail, I need to find some time. Bug briefly checked that it could be replaced without too many code changes.

Copy link

Choose a reason for hiding this comment

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

+1 on using the pricing API

}

type productPriceDimension struct {
RateCode string `json:"rateCode"`
Copy link
Contributor

Choose a reason for hiding this comment

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

either all privte or all public.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here and elsewhere.

Copy link
Author

Choose a reason for hiding this comment

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

In my opinion, the struct productPriceDimension is just a local DTO used to represent the json structure. Therefore, it's not part of packages api and doesn't need to be kept stable/backward compatible. Unfortunately, the marshaller is not able to read private fields of foreign structs.
This is the reason why I've decided to make it like this. Does that work for you?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, if we are super sure that this cannot be done with the official library.

@mwielgus
Copy link
Contributor

cc: @mumoshu @sethpollack

@mrcrgl
Copy link
Author

mrcrgl commented Nov 23, 2017

@mwielgus thank you for the feedback concerning the PR size. I consider to create some kind of documentation how the code was meant to be structured and how it should work.

@mwielgus
Copy link
Contributor

mwielgus commented Mar 1, 2019

@Jeffwan - How do we proceed on this?

@mwielgus
Copy link
Contributor

Inactivity warning. Please conclude the review and PR fixes.

@mwielgus
Copy link
Contributor

Second inactivity warning.

@mrcrgl
Copy link
Author

mrcrgl commented Mar 27, 2019

@mwielgus I wrote you on Slack

@mwielgus
Copy link
Contributor

@mrcrgl I answered you on Slack :).

@ylallemant
Copy link

@mwielgus we will attend the AWS Special Interest Group meeting next Friday to discus this PR and the necessary steps to get it merged

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please email the CNCF helpdesk: [email protected]

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 3, 2019
@mwielgus
Copy link
Contributor

mwielgus commented Apr 3, 2019

@ylallemant Cool! Good luck :).

@happilymarrieddad
Copy link

Is this going to be a thing? That would save so much money!

@ghost
Copy link

ghost commented Apr 6, 2019

Hi @happilymarrieddad - we've discussed this yesterday at the sig-aws meeting. People seem interested in getting this merged (especially us) but it might require a bit more time, that being said we've been running this code in production for close to 2 years. As we mentioned in the meeting, the only major downside of running it right now is that you have to manually scale if an ASG would have the lowest price but the instance type is not available. This happens maybe 2-3 times a year.

@bhack
Copy link

bhack commented Apr 6, 2019

@drewhemm
Copy link
Contributor

Hi guys,

I just opened PR 1886 to add support for ASG MixedInstancesPolicy. Whilst it doesn't attempt to perform calculations on the different costs of on-demand and spot instances, what it does allow is for a LaunchTemplate to have an instance type defined, but that can be overridden when creating the ASG.

There are more details in the PR conversation.

@mwielgus
Copy link
Contributor

Inactivity warning. Please proceed with the review or this PR will be closed.

1 similar comment
@mwielgus
Copy link
Contributor

mwielgus commented May 1, 2019

Inactivity warning. Please proceed with the review or this PR will be closed.

@happilymarrieddad
Copy link

Oh man, I hope someone, when they get a chance, gets this moving. I'm super excited about it!

@mcrute
Copy link

mcrute commented May 3, 2019

@mrcrgl I'm going to pick this up from @Jeffwan from the AWS side. Would you mind rebasing and updating this PR?

@ghost
Copy link

ghost commented May 3, 2019

cc: @ylallemant

@losipiuk
Copy link
Contributor

This PR is very stale. Closing for now due to inactivity. Feel free to reopen if there is followup work planned on this.

@losipiuk losipiuk closed this May 14, 2019
@bhack
Copy link

bhack commented May 14, 2019

I don't understand aws sig approach on this.
Are Amazon aws sig members against this? Is this going to conflict the pricing model?

@max-rocket-internet
Copy link

A lot has changed since 2017. It's not really related to the cluster-autoscaler itself, but like @drewhemm mentioned, with AWS Launch Templates and instance type overrides on the autoscaling group, the usability of spot instances with k8s on AWS has increased a lot. With this configuration the ASG will choose a selection of the cheapest spot instance types and spread them across AZs. Here's example configuration in Terraform using AWS EKS. This won't make everyone happy but it is a vast improvement for many people who were are waiting for this feature 🙂

@ghost
Copy link

ghost commented May 14, 2019

🙄

@losipiuk
Copy link
Contributor

I don't understand aws sig approach on this.
Are Amazon aws sig members against this? Is this going to conflict the pricing model?

We are not. We just not have enough context on details of implementation of AWS cloud provider.
As I said. Feel free to reopen. But we need an active AWS CP contributor to take ownership of that and make actual in depth code review.

@mrcrgl
Copy link
Author

mrcrgl commented May 14, 2019

I’m really disappointed about this. We’ve invested many days of work into this change and were more than patient with the review. At the end, you are telling that this PR is laying too long? But why is it so hard getting a review from someone who’s responsible?

This is not the way you earn motivated contributors.

@Jeffwan
Copy link
Contributor

Jeffwan commented May 15, 2019

I don't understand aws sig approach on this.
Are Amazon aws sig members against this? Is this going to conflict the pricing model?

@bhack

We're not, we did encourage people to come to sig-autoscaling and sig-aws to bring more use cases and feedbacks. One concern was price model in this PR is a hack way and it may not work for all the cases, the other one was lot of users said they don't like to manage many spot ASGs.

At the same time, as @max-rocket-internet said, Launch Template provides capability to bring onDemand and Spot instances in one ASG group. ASG guarantees users have cheapest spot instance type all the time. PR changes is here. #1886. docs #1983 To achieve most of users want from this PR, MixedInstancePolicy is another option.

@Jeffwan
Copy link
Contributor

Jeffwan commented May 15, 2019

I’m really disappointed about this. We’ve invested many days of work into this change and were more than patient with the review. At the end, you are telling that this PR is laying too long? But why is it so hard getting a review from someone who’s responsible?

This is not the way you earn motivated contributors.

I feel really sorry this PR stays here for long time and need rebase and rebase all the time. In the past, I think CA didn't have active AWS CP contributors.. AWS EKS only has <1 yr history, we are trying to put more efforts here and help address users problem. Community development definitely needs to engage powers from all contributors.

I am writing a doc to compare MixedInstancePolicy vs Native Spot vs Spot Fleet for this use case.
Let's see if there's a good solution to address all the spot requirements and I will share with all in two weeks. At the same time, please check PR #1886 and #1983 and see if they can meet your needs, If you need more info, I can record a demo for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cluster-autoscaler area/provider/aws Issues or PRs related to aws provider cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.