-
Notifications
You must be signed in to change notification settings - Fork 432
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
Estimate GCP VM pricing #776
Estimate GCP VM pricing #776
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.
Great job @PumpkinSeed I've shared some comments below once addressed we can move forward with the PR :)
providers/gcp/compute/instances.go
Outdated
} | ||
|
||
var opts = gcpcomputepricing.Opts{ | ||
Commitment: gcpcomputepricing.OnDemand, // TODO decide this based on normal or Spot instance |
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.
could we pass this as a param to the calculateCost
function instead of hardcoding it here? :)
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, this is why the TODO is there. But I need to figure out which field will return that value from the VM instance's 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.
if its not doable we can set OnDemand
by default and in a future release we can allow user to change instance type (ondemand or spot) from the Komiser dashboard
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 just needed to check where the instance stores that information (whether it is preemptible or not). I found it, so I just modified it. It won't be 100% accurate, because it can be 1 year or 3 year commitment as well, but until that it is good to go.
Cool, as soon as I will have time, I will do the changes. I agree that it would be much easier to maintain. |
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 lot @PumpkinSeed for the feature and for introducing tests as well :)
Resolve: #652
The price calculation of the GCP VM instances are a very complex thing, but it can be broken down to smaller pieces. The first piece is to calculate the price of the machine type what the instance originated. This solution get the actual pricing from the
https://www.gstatic.com/cloud-site-ux/pricing/data/gcp-compute.json
and start the calculation with the number of CPUs and memory under a certain machine type.