Skip to content

Commit

Permalink
Fix memory divisors (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
regadas authored Aug 6, 2021
1 parent 3461372 commit f4aad12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions controllers/flinkcluster_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ func calHeapSize(memSize int64, offHeapMin int64, offHeapRatio int64) int64 {
}
heapSizeCalculated := memSize - offHeapSize
if heapSizeCalculated > 0 {
divisor := resource.MustParse("1M")
divisor := resource.MustParse("1Mi")
heapSizeQuantity := resource.NewQuantity(heapSizeCalculated, resource.DecimalSI)
heapSizeMB = convertResourceMemoryToInt64(*heapSizeQuantity, divisor)
}
Expand All @@ -1034,7 +1034,7 @@ func calHeapSize(memSize int64, offHeapMin int64, offHeapRatio int64) int64 {

func calProcessMemorySize(memSize, ratio int64) int64 {
size := int64(math.Ceil(float64((memSize * ratio)) / 100))
divisor := resource.MustParse("1M")
divisor := resource.MustParse("1Mi")
quantity := resource.NewQuantity(size, resource.DecimalSI)
return convertResourceMemoryToInt64(*quantity, divisor)
}
Expand Down
10 changes: 5 additions & 5 deletions controllers/flinkcluster_converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ jobmanager.rpc.address: flinkjobcluster-sample-jobmanager
jobmanager.rpc.port: 6123
query.server.port: 6125
rest.port: 8081
taskmanager.heap.size: 474m
taskmanager.heap.size: 452m
taskmanager.numberOfTaskSlots: 1
taskmanager.rpc.port: 6122
`
Expand Down Expand Up @@ -1118,8 +1118,8 @@ func TestCalFlinkHeapSize(t *testing.T) {

flinkHeapSize := calFlinkHeapSize(cluster)
expectedFlinkHeapSize := map[string]string{
"jobmanager.heap.size": "474m", // get values calculated with limit - memoryOffHeapMin
"taskmanager.heap.size": "3222m", // get values calculated with limit - limit * memoryOffHeapRatio / 100
"jobmanager.heap.size": "452m", // get values calculated with limit - memoryOffHeapMin
"taskmanager.heap.size": "3072m", // get values calculated with limit - limit * memoryOffHeapRatio / 100
}
assert.Assert(t, len(flinkHeapSize) == 2)
assert.DeepEqual(
Expand Down Expand Up @@ -1185,8 +1185,8 @@ func TestCalFlinkMemoryProcessSize(t *testing.T) {

flinkHeapSize := calFlinkMemoryProcessSize(cluster)
expectedFlinkHeapSize := map[string]string{
"jobmanager.memory.process.size": "859m",
"taskmanager.memory.process.size": "3436m",
"jobmanager.memory.process.size": "820m",
"taskmanager.memory.process.size": "3277m",
}
assert.Assert(t, len(flinkHeapSize) == 2)
assert.DeepEqual(
Expand Down

0 comments on commit f4aad12

Please sign in to comment.