From 26847e778e8beb68be25a8d5bfb5edc7172f2d14 Mon Sep 17 00:00:00 2001 From: yaroslavborbat Date: Thu, 12 Sep 2024 12:01:23 +0300 Subject: [PATCH 1/3] round up Signed-off-by: yaroslavborbat --- .../pkg/controller/vm/internal/statistic.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go b/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go index 017301e7a..9eefcde05 100644 --- a/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go +++ b/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go @@ -18,6 +18,7 @@ package internal import ( "context" + "math" "sort" "strconv" "time" @@ -138,6 +139,7 @@ func (h *StatisticHandler) syncResources(changed *virtv2.VirtualMachine, memoryOverhead := memoryPodRequest.DeepCopy() memoryOverhead.Sub(memoryKVVMIRequest) + memoryOverhead = *resource.NewQuantity(int64(math.Ceil(float64(memoryOverhead.Value())/1024))*1024, resource.BinarySI) resources = virtv2.ResourcesStatus{ CPU: virtv2.CPUStatus{ From f2c500ac94e0d8adee4c5ae969396adfda523bc8 Mon Sep 17 00:00:00 2001 From: yaroslavborbat Date: Thu, 12 Sep 2024 12:11:54 +0300 Subject: [PATCH 2/3] change to mi Signed-off-by: yaroslavborbat --- .../pkg/controller/vm/internal/statistic.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go b/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go index 9eefcde05..3a70735ac 100644 --- a/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go +++ b/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go @@ -139,7 +139,8 @@ func (h *StatisticHandler) syncResources(changed *virtv2.VirtualMachine, memoryOverhead := memoryPodRequest.DeepCopy() memoryOverhead.Sub(memoryKVVMIRequest) - memoryOverhead = *resource.NewQuantity(int64(math.Ceil(float64(memoryOverhead.Value())/1024))*1024, resource.BinarySI) + mi := int64(1024 * 1024) + memoryOverhead = *resource.NewQuantity(int64(math.Ceil(float64(memoryOverhead.Value()/mi)))*mi, resource.BinarySI) resources = virtv2.ResourcesStatus{ CPU: virtv2.CPUStatus{ From a4d443d4493e25798089c1b19c5797e669f4d76d Mon Sep 17 00:00:00 2001 From: yaroslavborbat Date: Thu, 12 Sep 2024 15:00:35 +0300 Subject: [PATCH 3/3] fix Signed-off-by: yaroslavborbat --- .../pkg/controller/vm/internal/statistic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go b/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go index 3a70735ac..77890b11e 100644 --- a/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go +++ b/images/virtualization-artifact/pkg/controller/vm/internal/statistic.go @@ -140,7 +140,7 @@ func (h *StatisticHandler) syncResources(changed *virtv2.VirtualMachine, memoryOverhead := memoryPodRequest.DeepCopy() memoryOverhead.Sub(memoryKVVMIRequest) mi := int64(1024 * 1024) - memoryOverhead = *resource.NewQuantity(int64(math.Ceil(float64(memoryOverhead.Value()/mi)))*mi, resource.BinarySI) + memoryOverhead = *resource.NewQuantity(int64(math.Ceil(float64(memoryOverhead.Value())/float64(mi)))*mi, resource.BinarySI) resources = virtv2.ResourcesStatus{ CPU: virtv2.CPUStatus{