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

GCE: Always add boot disk annotations to templates #5004

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cluster-autoscaler/cloudprovider/gce/gce_price_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ 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]
if val, ok := node.Labels[bootDiskTypeLabel]; ok {
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]
Expand Down
6 changes: 3 additions & 3 deletions cluster-autoscaler/cloudprovider/gce/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions cluster-autoscaler/cloudprovider/gce/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down