-
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
Added OnDemand and Spot Price models addressing #131 #486
Conversation
…vity of the offer provided by the aws pricing api
# Conflicts: # cluster-autoscaler/cloudprovider/aws/ec2_instance_types.go
|
||
import "strconv" | ||
|
||
// stringRefToFloat64 converts fields of type *float64 to float64 (fallback to zero value if nil) |
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.
string to float?
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.
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?
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.
i think @mwielgus was referring to the comment.
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 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) { |
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.
What is the point of using *string. Strings are already pointers (slices).
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.
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?
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.
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 |
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.
Please add comments to the fields.
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.
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. |
This PR is HUGE and not reviewable in the current form. Please:
|
} | ||
|
||
func newLCFakeService( | ||
name string, |
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.
single line
} | ||
type cases []testCase | ||
|
||
var ( |
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.
no need for var, just :=
|
||
// EC2AutoscalingGroup holds AWS Autoscaling Group information | ||
type EC2AutoscalingGroup struct { | ||
Name string |
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.
Comments
|
||
// InstanceInfo holds AWS EC2 instance information | ||
type InstanceInfo struct { | ||
InstanceType string |
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.
Comments.
type instanceInfoService struct { | ||
client httpClient | ||
cache instanceInfoCache | ||
mu sync.RWMutex |
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.
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 { |
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.
Can we get these from some official library?
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.
I didn't find anything about it, just started here (https://aws.amazon.com/blogs/aws/new-aws-price-list-api/) and moved over
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.
Is the same of http://docs.aws.amazon.com/sdk-for-go/api/service/pricing/?
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 point, I'll check that
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.
Has this been checked?
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.
Not yet in detail, I need to find some time. Bug briefly checked that it could be replaced without too many code changes.
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.
+1 on using the pricing API
} | ||
|
||
type productPriceDimension struct { | ||
RateCode string `json:"rateCode"` |
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.
either all privte or all public.
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.
Here and elsewhere.
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.
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?
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.
ok
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.
ok, if we are super sure that this cannot be done with the official library.
cc: @mumoshu @sethpollack |
@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. |
@Jeffwan - How do we proceed on this? |
Inactivity warning. Please conclude the review and PR fixes. |
Second inactivity warning. |
@mwielgus I wrote you on Slack |
@mrcrgl I answered you on Slack :). |
@mwielgus we will attend the AWS Special Interest Group meeting next Friday to discus this PR and the necessary steps to get it merged |
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.
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. |
@ylallemant Cool! Good luck :). |
Is this going to be a thing? That would save so much money! |
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. |
In the meantime https://github.com/AutoSpotting/AutoSpotting |
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. |
Inactivity warning. Please proceed with the review or this PR will be closed. |
1 similar comment
Inactivity warning. Please proceed with the review or this PR will be closed. |
Oh man, I hope someone, when they get a chance, gets this moving. I'm super excited about it! |
cc: @ylallemant |
This PR is very stale. Closing for now due to inactivity. Feel free to reopen if there is followup work planned on this. |
I don't understand aws sig approach on this. |
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 🙂 |
🙄 |
We are not. We just not have enough context on details of implementation of AWS cloud provider. |
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. |
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. |
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. |
No description provided.