Merge pull request #5004 from yaroslava-serdiuk/node-temlate-fix
GCE: Always add boot disk annotations to templates
This commit is contained in:
commit
042badcc37
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue