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 ephemeral storage pricing to GCE expander #4911

Merged

Conversation

yaroslava-serdiuk
Copy link
Contributor

Which component this PR applies to?

cluster-autoscaler

What type of PR is this?

/kind feature

What this PR does / why we need it:

Improve scale-up decisions

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 24, 2022
@yaroslava-serdiuk yaroslava-serdiuk force-pushed the ephemeral-storagae branch 6 times, most recently from 9b0f889 to 42ad8d9 Compare May 25, 2022 09:26
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 25, 2022
Copy link
Member

@x13n x13n left a comment

Choose a reason for hiding this comment

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

I'm not convinced passing all this information through annotations is the way to go. I think this may be problematic if there are annotations provided on actual nodes, perhaps partially missing, leading to incorrect scaling decisions. An alternative would be to just allow GcePriceModel to extract information from instance templates directly. WDYT?

cluster-autoscaler/cloudprovider/gce/gce_cloud_provider.go Outdated Show resolved Hide resolved
cluster-autoscaler/main.go Outdated Show resolved Hide resolved
cluster-autoscaler/config/autoscaling_options.go Outdated Show resolved Hide resolved

localSsdCount, err := getLocalSsdCount(template.Properties)
ephemeralStorageLocalSsdCount := ephemeralStorageLocalSSDCount(kubeEnvValue)
if err == nil && ephemeralStorageLocalSsdCount > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

This used to be inside else branch, which guaranteed ephemeralStorage is only calculated once. Now it may be calculated twice. Why refactor it that way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I actually need to add annotations for boot disk and local ssd (which I added in following commits) and I add annotation after parsing info getBootDiskEphemeralStorageFromInstanceTemplateProperties() function . In the original order information about boot disk is not parsed from kube-env if ephemeral storage is backed up with local ssd.

ephemeralStorage, err = getLocalSSDEphemeralStorageFromInstanceTemplateProperties(template.Properties, ssdCount)
} else if !isBootDiskEphemeralStorageWithInstanceTemplateDisabled(kubeEnvValue) {

if !isBootDiskEphemeralStorageWithInstanceTemplateDisabled(kubeEnvValue) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we get rid of the double negation here? if isBootDiskEphemeralStorageWithInstanceTemplateEnabled(kubeEnvValue) would be a bit easier to read. Alternatively, just rename the function to isLocalSSDEphemeralStorageWithInstanceTemplateEnabled, which is what this function is actually checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but there is a reason why it is named this way. By default ephemeral storage is backed up by boot disk and in other cases we disable this option, so here we're checking "BLOCK_EPH_STORAGE_BOOT_DISK" variable in kube-env. I think from this perspective the name is fine.

cluster-autoscaler/cloudprovider/gce/gce_price_info.go Outdated Show resolved Hide resolved
cluster-autoscaler/cloudprovider/gce/gce_price_model.go Outdated Show resolved Hide resolved
cluster-autoscaler/cloudprovider/gce/gce_price_model.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2022
@yaroslava-serdiuk
Copy link
Contributor Author

I'm not convinced passing all this information through annotations is the way to go. I think this may be problematic if there are annotations provided on actual nodes, perhaps partially missing, leading to incorrect scaling decisions. An alternative would be to just allow GcePriceModel to extract information from instance templates directly. WDYT?

To extract information from instance templates directly we need to extend GcePriceModel struct to include GceManager or a part of GceManager.
We can use annotation to pass information about node to node template object, probably it better to introduce annotation like "cluster-autoscaler/" or "cluster-autoscaler/gce/". We already use similar approach to pass/get certain information through labels.
So for me it seems better to parse kube-env at the beginning and use that information later in the loop, rather than extend functionality of GcePriceModel.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 31, 2022
@yaroslava-serdiuk yaroslava-serdiuk force-pushed the ephemeral-storagae branch 5 times, most recently from c55da9d to f5d6734 Compare June 1, 2022 12:30
cluster-autoscaler/cloudprovider/gce/gce_cloud_provider.go Outdated Show resolved Hide resolved
cluster-autoscaler/cloudprovider/gce/gce_price_info.go Outdated Show resolved Hide resolved
cluster-autoscaler/cloudprovider/gce/gce_price_model.go Outdated Show resolved Hide resolved
@@ -159,6 +197,12 @@ func (model *GcePriceModel) getBasePrice(resources apiv1.ResourceList, instanceT
}
price += float64(mem.Value()) / float64(units.GiB) * memPrice * hours

if model.EphemeralStorageSupport {
ephemeralStorage := resources[apiv1.ResourceEphemeralStorage]
ephemeralStoragePrice := model.PriceInfo.LocalSsdPricePerHour()
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment here that this is a simplification to use local ssd price even if ephemeral storage is not backed by local ssd?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually changed the price to the price for pd-standard since it's cheaper.

@yaroslava-serdiuk yaroslava-serdiuk force-pushed the ephemeral-storagae branch 2 times, most recently from 13cfdb0 to 8d6cd12 Compare June 1, 2022 16:00
@x13n
Copy link
Member

x13n commented Jun 2, 2022

LGTM, just one minor comment.

@yaroslava-serdiuk yaroslava-serdiuk force-pushed the ephemeral-storagae branch 2 times, most recently from 9819ebb to cd611ca Compare June 2, 2022 13:25
@x13n
Copy link
Member

x13n commented Jun 2, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 2, 2022
explicitlyConfigured map[GceRef]bool
migAutoDiscoverySpecs []migAutoDiscoveryConfig
reserved *GceReserved
expanderEphemeralStorageSupport bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is actually used anywhere, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, thanks for finding this!

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2022
@towca
Copy link
Collaborator

towca commented Jun 3, 2022

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: towca, yaroslava-serdiuk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 3, 2022
@k8s-ci-robot k8s-ci-robot merged commit 4a97d16 into kubernetes:master Jun 3, 2022
navinjoy pushed a commit to navinjoy/autoscaler that referenced this pull request Oct 26, 2022
…toragae

Add ephemeral storage pricing to GCE expander
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants