From e75a7697cde8cb43b7057b84897e56014b58b5a8 Mon Sep 17 00:00:00 2001 From: Yaroslava Serdiuk Date: Tue, 4 Oct 2022 15:24:50 +0000 Subject: [PATCH] Remove units for default boot disk size --- cluster-autoscaler/cloudprovider/gce/gce_price_model.go | 8 ++++---- .../cloudprovider/gce/gce_price_model_test.go | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/gce/gce_price_model.go b/cluster-autoscaler/cloudprovider/gce/gce_price_model.go index 80eaf63c92c4..087039ad0a2f 100644 --- a/cluster-autoscaler/cloudprovider/gce/gce_price_model.go +++ b/cluster-autoscaler/cloudprovider/gce/gce_price_model.go @@ -49,8 +49,8 @@ const ( bootDiskTypeLabel = "cloud.google.com/gke-boot-disk" ) -// DefaultBootDiskSize is 100 GB. -const DefaultBootDiskSize = 100 * units.GB +// DefaultBootDiskSizeGB is 100 GB. +const DefaultBootDiskSizeGB = 100 // NodePrice returns a price of running the given node for a given period of time. // All prices are in USD. @@ -95,8 +95,8 @@ func (model *GcePriceModel) NodePrice(node *apiv1.Node, startTime time.Time, end // Boot disk price bootDiskSize, _ := strconv.ParseInt(node.Annotations[BootDiskSizeAnnotation], 10, 64) if bootDiskSize == 0 { - klog.Errorf("Boot disk size is not found for node %s, using default size %v", node.Name, DefaultBootDiskSize) - bootDiskSize = DefaultBootDiskSize + klog.Errorf("Boot disk size is not found for node %s, using default size %v", node.Name, DefaultBootDiskSizeGB) + bootDiskSize = DefaultBootDiskSizeGB } bootDiskType := node.Annotations[BootDiskTypeAnnotation] if val, ok := node.Labels[bootDiskTypeLabel]; ok { diff --git a/cluster-autoscaler/cloudprovider/gce/gce_price_model_test.go b/cluster-autoscaler/cloudprovider/gce/gce_price_model_test.go index 2d9268ce5b52..272366410414 100644 --- a/cluster-autoscaler/cloudprovider/gce/gce_price_model_test.go +++ b/cluster-autoscaler/cloudprovider/gce/gce_price_model_test.go @@ -213,6 +213,12 @@ func TestGetNodePrice(t *testing.T) { priceComparisonCoefficient: 1, expanderSupport: true, }, + "node with default boot disk is cheaper that node with more expensive boot disk type": { + cheaperNode: testNode(t, "cheapNode", "", 8000, 30*units.GiB, "", 0, false, false), + expensiveNode: testNodeEphemeralStorage(t, "expensiveNode", false, 0, "pd-ssd", 100, false), + priceComparisonCoefficient: 1, + expanderSupport: true, + }, } for tn, tc := range cases {