Skip to content

Commit

Permalink
fix: vgpu metrics repeated accumulation error
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoyinnan committed Dec 15, 2024
1 parent 087d990 commit 5a02567
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/scheduler/api/devices/nvidia/vgpu/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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))
}

0 comments on commit 5a02567

Please sign in to comment.