Merge pull request #17 from Nimbus318/fix/mig-task-resource-allocation

fix: associate resource allocation between MIG-enabled cards and tasks
main
霓漠Nimbus 7 months ago committed by GitHub
commit e476101395
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,6 +4,7 @@ import (
"context" "context"
"github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/log"
k8stypes "k8s.io/apimachinery/pkg/types" k8stypes "k8s.io/apimachinery/pkg/types"
"strings"
"time" "time"
) )
@ -76,7 +77,7 @@ func ContainersStatisticsInfo(containers []*Container, deviceId string) (int32,
var memory int32 = 0 var memory int32 = 0
for _, t := range containers { for _, t := range containers {
for _, cd := range t.ContainerDevices { for _, cd := range t.ContainerDevices {
if deviceId != "" && cd.UUID != deviceId { if deviceId != "" && !strings.HasPrefix(cd.UUID, deviceId) {
continue continue
} }
vGPU = vGPU + 1 vGPU = vGPU + 1

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"math" "math"
"strings"
"time" "time"
pb "vgpu/api/v1" pb "vgpu/api/v1"
"vgpu/internal/biz" "vgpu/internal/biz"
@ -163,7 +164,7 @@ func (s *MetricsGenerator) GenerateContainerMetrics(ctx context.Context) error {
var memory int32 = 0 var memory int32 = 0
var provider string = "" var provider string = ""
for _, cd := range c.ContainerDevices { for _, cd := range c.ContainerDevices {
if device.AliasId != "" && device.AliasId != cd.UUID { if device.AliasId != "" && !strings.HasPrefix(cd.UUID, device.AliasId) {
continue continue
} }
vGPU = vGPU + 1 vGPU = vGPU + 1

Loading…
Cancel
Save