Skip to content

Commit

Permalink
Fix memory allocation bug in FsExporter
Browse files Browse the repository at this point in the history
  • Loading branch information
gshaibi committed Apr 2, 2024
1 parent 064cf86 commit 7211148
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/status-exporter/export/fs/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ func (e *FsExporter) export(nodeTopology *topology.NodeTopology) {
log.Printf("Exporting pod %s gpu stats to filesystem", podUuid)

path := fmt.Sprintf("runai/proc/pod/%s/metrics/gpu/%d", podUuid, gpuIdx)
if err := os.MkdirAll(filepath.Dir(path), 0644); err != nil {
if err := os.MkdirAll(path, 0644); err != nil {
log.Printf("Failed creating directory for pod %s: %s", podUuid, err.Error())
}

if err := writeFile(filepath.Join(path, "utilization.sm"), []byte(strconv.Itoa(gpuUsageStatus.Utilization.Random()))); err != nil {
log.Printf("Failed exporting utilization for pod %s: %s", podUuid, err.Error())
}

if err := writeFile(filepath.Join(path, "memory.allocated"), []byte(strconv.Itoa(gpuUsageStatus.FbUsed))); err != nil {
if err := writeFile(filepath.Join(path, "memory.allocated"), []byte(strconv.Itoa(mbToBytes(gpuUsageStatus.FbUsed)))); err != nil {
log.Printf("Failed exporting memory for pod %s: %s", podUuid, err.Error())
}
}
Expand All @@ -72,3 +72,7 @@ func writeFile(path string, content []byte) error {
}
return nil
}

func mbToBytes(mb int) int {
return mb * 1024 * 1024
}

0 comments on commit 7211148

Please sign in to comment.