diff --git a/cluster-autoscaler/cloudprovider/gce/gce_price_model.go b/cluster-autoscaler/cloudprovider/gce/gce_price_model.go index 68dae383e3d..9ee9f438e34 100644 --- a/cluster-autoscaler/cloudprovider/gce/gce_price_model.go +++ b/cluster-autoscaler/cloudprovider/gce/gce_price_model.go @@ -96,7 +96,7 @@ 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.Error("Boot disk size is not found for node %s, using default size %v", node.Name, DefaultBootDiskSize) + klog.Errorf("Boot disk size is not found for node %s, using default size %v", node.Name, DefaultBootDiskSize) bootDiskSize = DefaultBootDiskSize } bootDiskType := node.Annotations[BootDiskTypeAnnotation] @@ -104,7 +104,7 @@ func (model *GcePriceModel) NodePrice(node *apiv1.Node, startTime time.Time, end bootDiskType = val } if bootDiskType == "" { - klog.Error("Boot disk type is not found for node %s, using default type %s", node.Name, DefaultBootDiskType) + klog.Errorf("Boot disk type is not found for node %s, using default type %s", node.Name, DefaultBootDiskType) bootDiskType = DefaultBootDiskType } bootDiskPrice := model.PriceInfo.BootDiskPricePerHour()[bootDiskType] diff --git a/cluster-autoscaler/cloudprovider/gce/templates.go b/cluster-autoscaler/cloudprovider/gce/templates.go index 46be651db46..9aabf204694 100644 --- a/cluster-autoscaler/cloudprovider/gce/templates.go +++ b/cluster-autoscaler/cloudprovider/gce/templates.go @@ -193,12 +193,13 @@ func (t *GceTemplateBuilder) BuildNodeFromTemplate(mig Mig, template *gce.Instan klog.Errorf("Couldn't extract architecture from kube-env for MIG %q, falling back to %q. Error: %v", mig.Id(), arch, err) } + addBootDiskAnnotations(&node, template.Properties) var ephemeralStorage int64 = -1 - if !isBootDiskEphemeralStorageWithInstanceTemplateDisabled(kubeEnvValue) { - addBootDiskAnnotations(&node, template.Properties) + // ephemeral storage is backed up by boot disk ephemeralStorage, err = getBootDiskEphemeralStorageFromInstanceTemplateProperties(template.Properties) } else { + // ephemeral storage is backed up by local ssd addAnnotation(&node, EphemeralStorageLocalSsdAnnotation, strconv.FormatBool(true)) } @@ -780,7 +781,6 @@ func addBootDiskAnnotations(node *apiv1.Node, instanceProperties *gce.InstancePr if instanceProperties.Disks == nil { return } - for _, disk := range instanceProperties.Disks { if disk != nil && disk.InitializeParams != nil { if disk.Boot { diff --git a/cluster-autoscaler/cloudprovider/gce/templates_test.go b/cluster-autoscaler/cloudprovider/gce/templates_test.go index 470c0ba6011..7773d57ebc9 100644 --- a/cluster-autoscaler/cloudprovider/gce/templates_test.go +++ b/cluster-autoscaler/cloudprovider/gce/templates_test.go @@ -159,6 +159,7 @@ func TestBuildNodeFromTemplateSetsResources(t *testing.T) { kubeEnv: "AUTOSCALER_ENV_VARS: os_distribution=cos;os=linux;ephemeral_storage_local_ssd_count=2\n", physicalCpu: 8, physicalMemory: 200 * units.MiB, + bootDiskSizeGiB: 300, ephemeralStorageLocalSSDCount: 2, attachedLocalSSDCount: 2, expectedErr: false,