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

Add AWS PV Pricing #107

Merged
merged 5 commits into from
Jun 19, 2019
Merged

Conversation

mda590
Copy link
Contributor

@mda590 mda590 commented Jun 10, 2019

  • Pull in cost data from AWS cost json for EBS volume types
  • Added a CostPerIO field in the PV object to handle io1 volumes which have a per GB price + a per provisioned IO price

Tested in live AWS EKS environment and everything looked good. I am noticing certain cases where the CostPerIO field for io1 volume types is not being filled out - let me know if you have any ideas on that.

cloud/awsprovider.go Outdated Show resolved Hide resolved
@@ -489,7 +515,7 @@ func (aws *AWS) DownloadPricingData() error {
}
aws.ValidPricingKeys[key] = true
aws.ValidPricingKeys[spotKey] = true
} else if strings.HasPrefix(product.Attributes.UsageType, "EBS:Volume") {
} else if strings.Contains(product.Attributes.UsageType, "EBS:Volume") {
key := locationToRegion[product.Attributes.Location] + "," + product.Attributes.UsageType
Copy link
Contributor

Choose a reason for hiding this comment

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

Usagetype would also need its region prefix to be stripped here because the key mapping above doesn't have region, otherwise you would end up with a key like: us-east-2,USE2-EBS:VolumeUsage.sc1 and a lookup key is something like us-east-2,EBS:VolumeUsage.sc1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a commit for this - let me know if you are good with the change I made to handle this or if you were thinking of something else.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest setting the key on L519 here to the stripped value, as the lookup further down on L354 looks up based on pvk.Features(), which returns a key of the format "region,usage type without region". This seems like a cleaner approach, as then there's no need to reconstruct a regional P-IOPS key when you reconstruct the keys on L581.

Also, as is, L596 on to get non P-IOPS data isn't correct, as the key hasn't been made regional.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mda590 as discussed I'll go ahead and merge this and follow it with a fix to support non us-east1 regions. Thank you for this!

cloud/awsprovider.go Outdated Show resolved Hide resolved
@@ -489,7 +515,7 @@ func (aws *AWS) DownloadPricingData() error {
}
aws.ValidPricingKeys[key] = true
aws.ValidPricingKeys[spotKey] = true
} else if strings.HasPrefix(product.Attributes.UsageType, "EBS:Volume") {
} else if strings.Contains(product.Attributes.UsageType, "EBS:Volume") {
key := locationToRegion[product.Attributes.Location] + "," + product.Attributes.UsageType
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest setting the key on L519 here to the stripped value, as the lookup further down on L354 looks up based on pvk.Features(), which returns a key of the format "region,usage type without region". This seems like a cleaner approach, as then there's no need to reconstruct a regional P-IOPS key when you reconstruct the keys on L581.

Also, as is, L596 on to get non P-IOPS data isn't correct, as the key hasn't been made regional.

@AjayTripathy AjayTripathy merged commit dbc4481 into opencost:master Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants