From 5a0256783ada6b435ba62b2de10727f2d78dd9d5 Mon Sep 17 00:00:00 2001 From: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com> Date: Sun, 15 Dec 2024 23:54:33 +0800 Subject: [PATCH] fix: vgpu metrics repeated accumulation error --- pkg/scheduler/api/devices/nvidia/vgpu/metrics.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/scheduler/api/devices/nvidia/vgpu/metrics.go b/pkg/scheduler/api/devices/nvidia/vgpu/metrics.go index 4d5287e1db..7a30889ab4 100644 --- a/pkg/scheduler/api/devices/nvidia/vgpu/metrics.go +++ b/pkg/scheduler/api/devices/nvidia/vgpu/metrics.go @@ -102,9 +102,9 @@ func (gs *GPUDevices) AddPodMetrics(index int, PodName string) { usage := gs.Device[index].PodMap[PodName] VGPUPodMemoryAllocated.WithLabelValues(UUID, NodeName, PodName).Set(float64(usage.UsedMem)) VGPUPodCoreAllocated.WithLabelValues(UUID, NodeName, PodName).Set(float64(usage.UsedCore)) - VGPUDevicesSharedNumber.WithLabelValues(UUID, NodeName).Inc() + VGPUDevicesSharedNumber.WithLabelValues(UUID, NodeName).Set(float64(gs.Device[index].UsedNum)) VGPUDevicesAllocatedCores.WithLabelValues(UUID, NodeName).Set(float64(gs.Device[index].UsedCore)) - VGPUDevicesAllocatedMemory.WithLabelValues(UUID, NodeName).Add(float64(gs.Device[index].UsedMem)) + VGPUDevicesAllocatedMemory.WithLabelValues(UUID, NodeName).Set(float64(gs.Device[index].UsedMem)) } func (gs *GPUDevices) SubPodMetrics(index int, PodName string) { @@ -118,7 +118,7 @@ func (gs *GPUDevices) SubPodMetrics(index int, PodName string) { VGPUPodMemoryAllocated.DeleteLabelValues(UUID, NodeName, PodName) VGPUPodCoreAllocated.DeleteLabelValues(UUID, NodeName, PodName) } - VGPUDevicesSharedNumber.WithLabelValues(UUID, NodeName).Dec() - VGPUDevicesAllocatedCores.WithLabelValues(UUID, NodeName).Sub(float64(gs.Device[index].UsedCore)) - VGPUDevicesAllocatedMemory.WithLabelValues(UUID, NodeName).Sub(float64(gs.Device[index].UsedMem)) + VGPUDevicesSharedNumber.WithLabelValues(UUID, NodeName).Set(float64(gs.Device[index].UsedNum)) + VGPUDevicesAllocatedCores.WithLabelValues(UUID, NodeName).Set(float64(gs.Device[index].UsedCore)) + VGPUDevicesAllocatedMemory.WithLabelValues(UUID, NodeName).Set(float64(gs.Device[index].UsedMem)) }