From 61b5c3c6b4f8df78449c6f7da1137fcf6a409a0c Mon Sep 17 00:00:00 2001 From: Yanhua Li Date: Mon, 13 Jun 2022 13:46:25 -0700 Subject: [PATCH] Fixing Bug 2095917: Nutanix set osDisk with diskSizeGB rather than diskSizeMiB --- data/data/install.openshift.io_installconfigs.yaml | 14 +++++++------- pkg/asset/machines/nutanix/machines.go | 2 +- pkg/asset/machines/worker.go | 2 +- pkg/types/nutanix/machinepool.go | 8 ++++---- pkg/types/nutanix/validation/machinepool.go | 4 ++-- pkg/types/nutanix/validation/machinepool_test.go | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/data/data/install.openshift.io_installconfigs.yaml b/data/data/install.openshift.io_installconfigs.yaml index fdf3e44c255..b7eb6c7366e 100644 --- a/data/data/install.openshift.io_installconfigs.yaml +++ b/data/data/install.openshift.io_installconfigs.yaml @@ -459,9 +459,9 @@ spec: osDisk: description: OSDisk defines the storage for instance. properties: - diskSizeMiB: - description: DiskSizeMiB defines the size of disk in - MiB. + diskSizeGiB: + description: DiskSizeGiB defines the size of disk in + GiB. format: int64 type: integer type: object @@ -1089,8 +1089,8 @@ spec: osDisk: description: OSDisk defines the storage for instance. properties: - diskSizeMiB: - description: DiskSizeMiB defines the size of disk in MiB. + diskSizeGiB: + description: DiskSizeGiB defines the size of disk in GiB. format: int64 type: integer type: object @@ -2347,8 +2347,8 @@ spec: osDisk: description: OSDisk defines the storage for instance. properties: - diskSizeMiB: - description: DiskSizeMiB defines the size of disk in MiB. + diskSizeGiB: + description: DiskSizeGiB defines the size of disk in GiB. format: int64 type: integer type: object diff --git a/pkg/asset/machines/nutanix/machines.go b/pkg/asset/machines/nutanix/machines.go index dc002213ced..e525cc820a1 100644 --- a/pkg/asset/machines/nutanix/machines.go +++ b/pkg/asset/machines/nutanix/machines.go @@ -93,7 +93,7 @@ func provider(clusterID string, platform *nutanix.Platform, mpool *nutanix.Machi Type: machinev1.NutanixIdentifierUUID, UUID: &platform.PrismElements[0].UUID, }, - SystemDiskSize: resource.MustParse(fmt.Sprintf("%dMi", mpool.OSDisk.DiskSizeMiB)), + SystemDiskSize: resource.MustParse(fmt.Sprintf("%dGi", mpool.OSDisk.DiskSizeGiB)), }, nil } diff --git a/pkg/asset/machines/worker.go b/pkg/asset/machines/worker.go index 4fd2a92486e..459e88c5085 100644 --- a/pkg/asset/machines/worker.go +++ b/pkg/asset/machines/worker.go @@ -177,7 +177,7 @@ func defaultNutanixMachinePoolPlatform() nutanixtypes.MachinePool { NumCoresPerSocket: 1, MemoryMiB: 16384, OSDisk: nutanixtypes.OSDisk{ - DiskSizeMiB: decimalRootVolumeSize * 1024, + DiskSizeGiB: decimalRootVolumeSize, }, } } diff --git a/pkg/types/nutanix/machinepool.go b/pkg/types/nutanix/machinepool.go index 0b1e22b3876..57792e9349e 100644 --- a/pkg/types/nutanix/machinepool.go +++ b/pkg/types/nutanix/machinepool.go @@ -30,10 +30,10 @@ type MachinePool struct { // OSDisk defines the disk for a virtual machine. type OSDisk struct { - // DiskSizeMiB defines the size of disk in MiB. + // DiskSizeGiB defines the size of disk in GiB. // // +optional - DiskSizeMiB int64 `json:"diskSizeMiB,omitempty"` + DiskSizeGiB int64 `json:"diskSizeGiB,omitempty"` } // Set sets the values from `required` to `p`. @@ -54,7 +54,7 @@ func (p *MachinePool) Set(required *MachinePool) { p.MemoryMiB = required.MemoryMiB } - if required.OSDisk.DiskSizeMiB != 0 { - p.OSDisk.DiskSizeMiB = required.OSDisk.DiskSizeMiB + if required.OSDisk.DiskSizeGiB != 0 { + p.OSDisk.DiskSizeGiB = required.OSDisk.DiskSizeGiB } } diff --git a/pkg/types/nutanix/validation/machinepool.go b/pkg/types/nutanix/validation/machinepool.go index 4ea34480af4..bbdd19bff51 100644 --- a/pkg/types/nutanix/validation/machinepool.go +++ b/pkg/types/nutanix/validation/machinepool.go @@ -9,8 +9,8 @@ import ( // ValidateMachinePool checks that the specified machine pool is valid. func ValidateMachinePool(p *nutanix.MachinePool, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} - if p.DiskSizeMiB < 0 { - allErrs = append(allErrs, field.Invalid(fldPath.Child("diskSizeMiB"), p.DiskSizeMiB, "storage disk size must be positive")) + if p.DiskSizeGiB < 0 { + allErrs = append(allErrs, field.Invalid(fldPath.Child("diskSizeGiB"), p.DiskSizeGiB, "storage disk size must be positive")) } if p.MemoryMiB < 0 { allErrs = append(allErrs, field.Invalid(fldPath.Child("memoryMiB"), p.MemoryMiB, "memory size must be positive")) diff --git a/pkg/types/nutanix/validation/machinepool_test.go b/pkg/types/nutanix/validation/machinepool_test.go index fcdebc87ee9..cb690ea4548 100644 --- a/pkg/types/nutanix/validation/machinepool_test.go +++ b/pkg/types/nutanix/validation/machinepool_test.go @@ -23,10 +23,10 @@ func TestValidateMachinePool(t *testing.T) { name: "negative disk size", pool: &nutanix.MachinePool{ OSDisk: nutanix.OSDisk{ - DiskSizeMiB: -1, + DiskSizeGiB: -1, }, }, - expectedErrMsg: `^test-path\.diskSizeMiB: Invalid value: -1: storage disk size must be positive$`, + expectedErrMsg: `^test-path\.diskSizeGiB: Invalid value: -1: storage disk size must be positive$`, }, { name: "negative CPUs", pool: &nutanix.MachinePool{