-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Fix/price multiplier #486
base: master
Are you sure you want to change the base?
Fix/price multiplier #486
Conversation
@@ -120,7 +120,7 @@ func (i *instance) belongsToEnabledASG() bool { | |||
asg.loadLaunchConfiguration() | |||
asg.loadLaunchTemplate() | |||
i.asg = &asg | |||
i.price = i.typeInfo.pricing.onDemand | |||
i.price = i.typeInfo.pricing.onDemand / i.region.conf.OnDemandPriceMultiplier * i.asg.config.OnDemandPriceMultiplier |
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.
Did you test this?
We used to have an issue with this logic(it used to consider the square of the multiplier value instead of the actual value) which I tried to fix a few months ago, but the current fix only considers the parameter from the Lambda environment variables, not from the tag-based ASG overrides.
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, i had a windows ASG (unfortunately) that used a mutiplier (by tag) of 1.3.
It stopped working and AutoSpotting was no more able to launch spot replacement.
After i deployed the PR version, it started working again.
Linux price for t3a.small are:
{'t3a.small': {'memory': 2.0, 'price': 0.0204, 'spot': 1, 'spotprice': 0.0071, 'vcpu': 2}}
Before change:
2022/04/12 12:16:59 instance_queries.go:22: Comparing price spot/instance:
2022/04/12 12:16:59 instance_queries.go:29: Spot price: 0.0071
2022/04/12 12:16:59 instance_queries.go:30: Instance price: 0.0204
2022/04/12 12:16:59 instance_queries.go:333: Comparing current type t3a.small with price 0.0204 with candidate t3a.small with price 0.0071
After change:
2022/04/12 12:29:04 instance_queries.go:22: Comparing price spot/instance:
2022/04/12 12:29:04 instance_queries.go:29: Spot price: 0.0071
2022/04/12 12:29:04 instance_queries.go:30: Instance price: 0.026520000000000002
2022/04/12 12:29:04 instance_queries.go:333: Comparing current type t3a.small with price 0.026520000000000002 with candidate
t3a.small with price 0.0071
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.
right, but what if you also set the value as env var and have the tag as override?
I suspect it will be squared, because the value comes from both tag and env var and gets multiplied twice.
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, i suspect that too.
So we should add a condition to ignore i.region.conf.OnDemandPriceMultiplier
if i.asg.config.OnDemandPriceMultiplier
is != 1
.
Only one multiplier should be taken in account.
What do you think ?
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 recovered my original comment to the commit, maybe can help to figure out why i have done it this way (sincerely i do not remember)
* Specify/override multiplier for the on-demand price on a group
level
As i.price already have been multiplied by the global value, if
specified, i need first to divide it by the same value and then multiply
it by the multiplier specific to the ASG.
We need to do this for both scheduled and event actions.
For event we act in function belongsToEnabledASG.
For schedule we act in launchSpotReplacement.
Need deep testing...
* Specify/override multiplier for the on-demand price on a group
level - fix
in loadConfOnDemandPriceMultiplier need to use
a.config.OnDemandPriceMultiplier in place of
a.region.conf.OnDemandPriceMultiplier
this way a.region.conf.OnDemandPriceMultiplier will conserve the
original global value
Think the key words are:
As i.price already have been multiplied by the global value, if
specified, i need first to divide it by the same value and then multiply
it by the multiplier specific to the ASG.
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.
We calculate region instance ondemand price in method determineInstanceTypeInformation
.
And we multiply it by the global OnDemandPriceMultiplier
:
price.onDemand = it.Pricing[r.name].Linux.OnDemand * cfg.OnDemandPriceMultiplier
We call determineInstanceTypeInformation
for both instance launch event and cron event.
So we need to divide by that global value before multiplying by the OnDemandPriceMultiplier
ASG specific.
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, I'll look into this over the next few days, I want to address this issue somehow.
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.
Taking another look into this, I'll try to sort it out over the next few days.
@@ -5,7 +5,7 @@ go 1.14 | |||
require ( | |||
github.com/aws/aws-lambda-go v1.26.0 | |||
github.com/aws/aws-sdk-go v1.40.39 | |||
github.com/cristim/ec2-instances-info v0.0.0-20210909050335-b239c40fcad0 | |||
github.com/cristim/ec2-instances-info v0.0.0-20220302182402-4b7a873a84cf |
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.
let's keep this dependency change out of this PR.
@@ -7,6 +7,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma | |||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= | |||
github.com/cristim/ec2-instances-info v0.0.0-20210909050335-b239c40fcad0 h1:X6u+vwxB2EQwA8+A7jhkYdNK0oE0p0LuuiPbAezZH+g= | |||
github.com/cristim/ec2-instances-info v0.0.0-20210909050335-b239c40fcad0/go.mod h1:0yCjO4zBzlwWSGh/zGfW2Zq1NX605qCYVBHD1fPXKNs= | |||
github.com/cristim/ec2-instances-info v0.0.0-20220302182402-4b7a873a84cf h1:/0fth76qMtSWpTbkOLRKHX/k6KgUAK6HMbXArUi7dTc= | |||
github.com/cristim/ec2-instances-info v0.0.0-20220302182402-4b7a873a84cf/go.mod h1:0yCjO4zBzlwWSGh/zGfW2Zq1NX605qCYVBHD1fPXKNs= |
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.
also here, let's keep this change out of this PR.
@@ -120,7 +120,7 @@ func (i *instance) belongsToEnabledASG() bool { | |||
asg.loadLaunchConfiguration() | |||
asg.loadLaunchTemplate() | |||
i.asg = &asg | |||
i.price = i.typeInfo.pricing.onDemand | |||
i.price = i.typeInfo.pricing.onDemand / i.region.conf.OnDemandPriceMultiplier * i.asg.config.OnDemandPriceMultiplier |
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, I'll look into this over the next few days, I want to address this issue somehow.
Issue Type
Summary
Since 6938027, OnDemandPriceMultiplier were no more taken in account.
The fix is easy, just restore the multiplier when setting instance price (i.price) inside
belongsToEnabledASG
.(include a commit that change go.mod to use and updated
ec2-instances-info
)Code contribution checklist
code under any software license.
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.