陈博文 4 days ago
commit 32e1b36408

@ -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 {

@ -17,4 +17,5 @@ database:
driver: mysql
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_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 ('大模型资源池');

@ -9,19 +9,21 @@ import (
)
type Container struct {
Name string
UUID string
ContainerIdx int
NodeName string
PodUID string
PodName string
ContainerDevices ContainerDevices
Status string
CreateTime time.Time
Priority string
NodeUID string
Namespace string
TpiID string
Name string
UUID string
ContainerIdx int
NodeName string
PodUID string
PodName string
ContainerDevices ContainerDevices
Status string
CreateTime time.Time
Priority string
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)
@ -137,17 +138,19 @@ func (r *podRepo) fetchContainerInfo(pod *corev1.Pod) []*biz.Container {
for i, ctr := range pod.Spec.Containers {
c := &biz.Container{
Name: ctr.Name,
UUID: ctrIdMaps[ctr.Name],
ContainerIdx: i,
NodeName: pod.Spec.NodeName,
PodName: pod.Name,
PodUID: string(pod.UID),
Status: containerStat[ctr.Name],
NodeUID: r.GetNodeUUID(pod),
Namespace: pod.Namespace,
CreateTime: r.GetCreateTime(pod),
ContainerDevices: bizContainerDevices[i],
Name: ctr.Name,
UUID: ctrIdMaps[ctr.Name],
ContainerIdx: i,
NodeName: pod.Spec.NodeName,
PodName: pod.Name,
PodUID: string(pod.UID),
Status: containerStat[ctr.Name],
NodeUID: r.GetNodeUUID(pod),
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,17 +33,43 @@ 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 {
continue
//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 {
continue
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 {
continue
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

@ -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) {
continue
//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 {
continue
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 {
continue
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 {
continue
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