fix: 资源池详情相关接口改造

main
youys 4 days ago
parent 40ea6db1bb
commit 47808327f6

@ -71,6 +71,8 @@ message ContainerReply {
string shixun_name = 21;
string role = 22;
string username = 23;
float requested_cpu_cores = 24;
int64 requested_memory = 25;
}
message ContainersReply {

@ -151,6 +151,7 @@ message ResourcePoolListData{
int64 total_memory = 7; // kb
int64 disk_size = 8;
repeated Nodes node_list = 9;
string link_url = 10;
}
message ResourcePoolListRequest {

@ -18,3 +18,4 @@ database:
dataSourceName: testeducoder:TEST@123@tcp(testeducoder-public.mysql.polardb.rds.aliyuncs.com:3306)/hami?parseTime=true&loc=Local
web_domain: http://172.16.100.14
big_model_resource_pool_name: "大模型资源池"
big_model_resource_pool_link_url: "https://www.baidu.com"

@ -17,3 +17,4 @@ create table nodes(
update_time timestamp default current_timestamp on update current_timestamp
);
INSERT INTO hami.resource_pool (pool_name) VALUES ('大模型资源池');

@ -22,6 +22,8 @@ type Container struct {
NodeUID string
Namespace string
TpiID string
RequestedCpuCores float32
RequestedMemory int64
}
type PodInfo struct {

@ -93,6 +93,7 @@ func (r *podRepo) addPod(pod *corev1.Pod, nodeID string, devices biz.PodDevices)
r.mutex.Lock()
defer r.mutex.Unlock()
ctrs := r.fetchContainerInfo(pod)
pi := &biz.PodInfo{Name: pod.Name, UID: pod.UID, Namespace: pod.Namespace, NodeID: nodeID, Devices: devices, Ctrs: ctrs, Labels: pod.Labels}
r.pods[pod.UID] = pi
r.allPods = append(r.allPods, pi)
@ -148,6 +149,8 @@ func (r *podRepo) fetchContainerInfo(pod *corev1.Pod) []*biz.Container {
Namespace: pod.Namespace,
CreateTime: r.GetCreateTime(pod),
ContainerDevices: bizContainerDevices[i],
RequestedCpuCores: float32(ctr.Resources.Requests.Cpu().MilliValue()) / 1000,
RequestedMemory: ctr.Resources.Requests.Memory().Value(),
}
if len(bizContainerDevices[i]) > 0 {
c.Priority = bizContainerDevices[i][0].Priority

@ -3,6 +3,8 @@ package service
import (
"context"
"fmt"
"github.com/go-kratos/kratos/v2/log"
"slices"
"sort"
"strings"
pb "vgpu/api/v1"
@ -31,18 +33,44 @@ func (s *CardService) GetAllGPUs(ctx context.Context, req *pb.GetAllGpusReq) (*p
var res = &pb.GPUsReply{List: []*pb.GPUReply{}}
for _, device := range deviceInfos {
gpu := &pb.GPUReply{}
nodeName := strings.Trim(filters.NodeName, " ")
if nodeName != "" && nodeName != device.NodeName {
//nodeName := strings.Trim(filters.NodeName, " ")
//if nodeName != "" && nodeName != device.NodeName {
// continue
//}
//deviceType := strings.Trim(filters.Type, " ")
//if deviceType != "" && deviceType != device.Type {
// continue
//}
//deviceUid := strings.Trim(filters.Uid, " ")
//if deviceUid != "" && deviceUid != device.Id {
// continue
//}
nodeNames := strings.Trim(filters.NodeName, " ")
if nodeNames != "" {
names := strings.Split(nodeNames, "|")
log.Info("GetAllGPUs names: ", names)
if !slices.Contains(names, device.NodeName) {
continue
}
deviceType := strings.Trim(filters.Type, " ")
if deviceType != "" && deviceType != device.Type {
}
deviceTypes := strings.Trim(filters.Type, " ")
if deviceTypes != "" {
types := strings.Split(deviceTypes, "|")
log.Info("GetAllGPUs types: ", types)
if !slices.Contains(types, device.Type) {
continue
}
deviceUid := strings.Trim(filters.Uid, " ")
if deviceUid != "" && deviceUid != device.Id {
}
deviceUids := strings.Trim(filters.Uid, " ")
if deviceUids != "" {
uids := strings.Split(deviceUids, "|")
log.Info("GetAllGPUs uids: ", uids)
if !slices.Contains(uids, device.NodeUid) {
continue
}
}
gpu.Uuid = device.Id
gpu.NodeName = device.NodeName
gpu.Type = device.Type

@ -40,18 +40,55 @@ func (s *ContainerService) GetAllContainers(ctx context.Context, req *pb.GetAllC
}
var res = &pb.ContainersReply{Items: []*pb.ContainerReply{}}
for _, container := range containers {
if filters.Name != "" && !strings.Contains(container.Name, filters.Name) {
//if filters.Name != "" && !strings.Contains(container.Name, filters.Name) {
// continue
//}
//if filters.NodeName != "" && filters.NodeName != container.NodeName {
// continue
//}
//if filters.Status != "" && filters.Status != container.Status {
// continue
//}
//if filters.NodeUid != "" && filters.NodeUid != container.NodeUID {
// continue
//}
names := strings.Trim(filters.Name, " ")
if names != "" {
nameList := strings.Split(names, "|")
log.Info("GetAllContainers names: ", nameList)
if !slices.Contains(nameList, container.Name) {
continue
}
if filters.NodeName != "" && filters.NodeName != container.NodeName {
}
nodeNames := strings.Trim(filters.NodeName, " ")
if nodeNames != "" {
names := strings.Split(nodeNames, "|")
log.Info("GetAllContainers node names: ", names)
if !slices.Contains(names, container.NodeName) {
continue
}
if filters.Status != "" && filters.Status != container.Status {
}
statuses := strings.Trim(filters.Status, " ")
if statuses != "" {
statusList := strings.Split(statuses, "|")
log.Info("GetAllContainers statuses: ", statusList)
if !slices.Contains(statusList, container.Status) {
continue
}
if filters.NodeUid != "" && filters.NodeUid != container.NodeUID {
}
nodeUids := strings.Trim(filters.NodeUid, " ")
if nodeUids != "" {
uids := strings.Split(nodeUids, "|")
log.Info("GetAllContainers node UIDs: ", uids)
if !slices.Contains(uids, container.NodeUID) {
continue
}
}
priority := strings.Trim(filters.Priority, " ")
if priority != "" {
if (priority == "0" && container.Priority == "1") ||
@ -140,6 +177,8 @@ func (s *ContainerService) GetContainer(ctx context.Context, req *pb.GetContaine
ctrReply.NodeUid = container.NodeUID
ctrReply.Namespace = container.Namespace
ctrReply.Priority = container.Priority
ctrReply.RequestedCpuCores = container.RequestedCpuCores
ctrReply.RequestedMemory = container.RequestedMemory
for _, containerDevice := range container.ContainerDevices {
if req.DeviceId != "" && req.DeviceId != containerDevice.UUID {
continue

@ -155,6 +155,10 @@ func (s *ResourcePoolService) List(ctx context.Context, req *pb.ResourcePoolList
}
data = append(data, &poolData)
}
listData := data[0]
linkUrl, _ := database.Get("big_model_resource_pool_link_url")
listData.LinkUrl = linkUrl.(string)
return &pb.ResourcePoolListResponse{Data: data}, nil
}

@ -119,6 +119,11 @@ components:
type: string
username:
type: string
requestedCpuCores:
type: number
format: float
requestedMemory:
type: string
ContainersReply:
type: object
properties:

Loading…
Cancel
Save