diff --git a/provider/oci/environ.go b/provider/oci/environ.go index 9d62f9b745e..933dc93348f 100644 --- a/provider/oci/environ.go +++ b/provider/oci/environ.go @@ -678,7 +678,7 @@ func ensureShapeConfig( // VM.Standard.A1.Flex, if we set 2 Ocpus OCI will set 12GB of // memory (default is 6GB per core). if constraints.HasMem() { - mem := float32(*constraints.Mem) + mem := float32(*constraints.Mem / 1024) instanceDetails.ShapeConfig.MemoryInGBs = &mem } } diff --git a/provider/oci/environ_test.go b/provider/oci/environ_test.go index bde27aa20f0..6f0b3f3fe3a 100644 --- a/provider/oci/environ_test.go +++ b/provider/oci/environ_test.go @@ -78,7 +78,7 @@ func (s *environSuite) TestEnsureShapeConfig(c *gc.C) { maxMem: makeUint64Pointer(512 * 1024), cpuCores: 1, mem: 1024, - constraints: "mem=64", + constraints: "mem=64G", want: &ociCore.LaunchInstanceShapeConfigDetails{ Ocpus: makeFloat32Pointer(float32(instances.MinCpuCores)), MemoryInGBs: makeFloat32Pointer(64), @@ -90,7 +90,7 @@ func (s *environSuite) TestEnsureShapeConfig(c *gc.C) { maxMem: makeUint64Pointer(512 * 1024), cpuCores: 1, mem: 1024, - constraints: "cores=31 mem=64", + constraints: "cores=31 mem=64G", want: &ociCore.LaunchInstanceShapeConfigDetails{ Ocpus: makeFloat32Pointer(31), MemoryInGBs: makeFloat32Pointer(64), diff --git a/provider/oci/images.go b/provider/oci/images.go index e89c1d8723e..a36fc5d2b4a 100644 --- a/provider/oci/images.go +++ b/provider/oci/images.go @@ -334,17 +334,13 @@ func instanceTypes(cli ComputeClient, compartmentID, imageID *string) ([]instanc // OcpuOptions will not be nil and they indicate the maximum // and minimum values. We assign the max memory and cpu cores // values to the instance type in that case. - if val.MemoryOptions != nil { - if val.MemoryOptions.MaxInGBs != nil { - maxMem := uint64(*val.MemoryOptions.MaxInGBs) * 1024 - newType.MaxMem = &maxMem - } + if val.MemoryOptions != nil && val.MemoryOptions.MaxInGBs != nil { + maxMem := uint64(*val.MemoryOptions.MaxInGBs) * 1024 + newType.MaxMem = &maxMem } - if val.OcpuOptions != nil { - if val.OcpuOptions.Max != nil { - maxCpuCores := uint64(*val.OcpuOptions.Max) - newType.MaxCpuCores = &maxCpuCores - } + if val.OcpuOptions != nil && val.OcpuOptions.Max != nil { + maxCpuCores := uint64(*val.OcpuOptions.Max) + newType.MaxCpuCores = &maxCpuCores } types = append(types, newType) }