From 3f15d72586500ff9524ede0959f214e8139e70da Mon Sep 17 00:00:00 2001 From: youys <1272586223@qq.com> Date: Wed, 6 Aug 2025 16:13:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AD=97=E6=AE=B5=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- k8s.yml | 13 ++ server/api/v1/container.proto | 2 +- server/api/v1/resource_pool.proto | 3 +- server/internal/service/container.go | 2 +- server/openapi.yaml | 325 +++++++-------------------- 5 files changed, 98 insertions(+), 247 deletions(-) diff --git a/k8s.yml b/k8s.yml index 0f39f1a..5adb29d 100644 --- a/k8s.yml +++ b/k8s.yml @@ -148,3 +148,16 @@ spec: type: NodePort +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: hami-webui-clusterrolebinding-nsz4n +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: 'system:controller:node-controller' +subjects: + - kind: ServiceAccount + name: hami-webui + namespace: kube-system \ No newline at end of file diff --git a/server/api/v1/container.proto b/server/api/v1/container.proto index 9a52511..b9756f6 100644 --- a/server/api/v1/container.proto +++ b/server/api/v1/container.proto @@ -61,7 +61,7 @@ message ContainerReply { string end_time = 11; string pod_uid = 12; string node_uid = 13; - repeated string resource_pool = 14; + repeated string resource_pools = 14; string flavor = 15; string priority = 16; string namespace = 17; diff --git a/server/api/v1/resource_pool.proto b/server/api/v1/resource_pool.proto index 858d4b9..f7576c9 100644 --- a/server/api/v1/resource_pool.proto +++ b/server/api/v1/resource_pool.proto @@ -62,7 +62,8 @@ service ResourcePool { rpc GetDetail (ResourcePoolDetailRequest) returns (ResourcePoolDetailResponse) { option (google.api.http) = { - post: "/v1/resource/pool/detail" + post: "/v1/resource/pool/detail", + body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "资源池详情"; diff --git a/server/internal/service/container.go b/server/internal/service/container.go index 9a17f03..296c4e3 100644 --- a/server/internal/service/container.go +++ b/server/internal/service/container.go @@ -97,7 +97,7 @@ func (s *ContainerService) GetAllContainers(ctx context.Context, req *pb.GetAllC return nil, err } - containerReply.ResourcePool = resourcePoolNames + containerReply.ResourcePools = resourcePoolNames resourcePoolName, err := database.Get("big_model_resource_pool_name") if err != nil { return nil, err diff --git a/server/openapi.yaml b/server/openapi.yaml index bf312da..fbfd7a2 100644 --- a/server/openapi.yaml +++ b/server/openapi.yaml @@ -3,82 +3,24 @@ openapi: 3.0.3 info: - title: ResourcePool API + title: Container API version: 0.0.1 paths: - /v1/available/nodes: + /v1/container: get: tags: - - ResourcePool - operationId: ResourcePool_GetAvailableNodes - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/AvailableNodesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/resource/pool/create: - post: - tags: - - ResourcePool - operationId: ResourcePool_Create - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ResourcePoolCreateRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/BaseResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/resource/pool/delete: - post: - tags: - - ResourcePool - operationId: ResourcePool_Delete - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ResourcePoolDeleteRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/BaseResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/resource/pool/detail: - post: - tags: - - ResourcePool - operationId: ResourcePool_GetDetail + - Container + operationId: Container_GetContainer parameters: - - name: poolId + - name: name + in: query + schema: + type: string + - name: podUid + in: query + schema: + type: string + - name: deviceId in: query schema: type: string @@ -88,65 +30,23 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ResourcePoolDetailResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/resource/pool/list: - get: - tags: - - ResourcePool - operationId: ResourcePool_List - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/ResourcePoolListResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/Status' - /v1/resource/pool/removeNode: - post: - tags: - - ResourcePool - operationId: ResourcePool_RemoveNode - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/RemoveNodeRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/BaseResponse' + $ref: '#/components/schemas/ContainerReply' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/Status' - /v1/resource/pool/update: + /v1/containers: post: tags: - - ResourcePool - operationId: ResourcePool_Update + - Container + operationId: Container_GetAllContainers requestBody: content: application/json: schema: - $ref: '#/components/schemas/ResourcePoolUpdateRequest' + $ref: '#/components/schemas/GetAllContainersReq' required: true responses: "200": @@ -154,7 +54,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/BaseResponse' + $ref: '#/components/schemas/ContainersReply' default: description: Default error response content: @@ -163,177 +63,114 @@ paths: $ref: '#/components/schemas/Status' components: schemas: - AvailableNodesInfo: - type: object - properties: - nodeName: - type: string - cpuCores: - type: string - gpuNum: - type: string - gpuMemory: - type: string - totalMemory: - type: string - diskSize: - type: string - nodeIp: - type: string - AvailableNodesResponse: - type: object - properties: - data: - type: array - items: - $ref: '#/components/schemas/AvailableNodesInfo' - BaseResponse: + ContainerReply: type: object properties: - code: - type: integer - format: int32 - message: + name: type: string - data: - type: object - GoogleProtobufAny: - type: object - properties: - '@type': + status: type: string - description: The type of the serialized message. - additionalProperties: true - description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. - Nodes: - type: object - properties: - nodeIp: + appName: type: string nodeName: type: string - PoolNodeReply: - type: object - properties: - ip: - type: string - isSchedulable: - type: boolean - isReady: - type: boolean - type: - type: array - items: - type: string - vgpuUsed: + allocatedDevices: type: integer format: int32 - vgpuTotal: + allocatedCores: type: integer format: int32 - coreUsed: + allocatedMem: type: integer format: int32 - coreTotal: - type: string - memoryUsed: - type: string - memoryTotal: + type: type: string - uid: + createTime: type: string - name: + startTime: type: string - cardCnt: - type: integer - format: int32 - osImage: + endTime: type: string - operatingSystem: + podUid: type: string - kernelVersion: + nodeUid: type: string - containerRuntimeVersion: + resourcePools: + type: array + items: + type: string + flavor: type: string - kubeletVersion: + priority: type: string - kubeProxyVersion: + namespace: type: string - architecture: + deviceIds: + type: array + items: + type: string + podName: type: string - creationTimestamp: + taskType: type: string - diskSize: + shixunName: type: string - nodeId: + role: type: string - RemoveNodeRequest: - type: object - properties: - nodeId: + username: type: string - ResourcePoolCreateRequest: + ContainersReply: type: object properties: - poolName: - type: string - nodes: + items: type: array items: - $ref: '#/components/schemas/Nodes' - ResourcePoolDeleteRequest: - type: object - properties: - poolId: - type: string - ResourcePoolDetailResponse: + $ref: '#/components/schemas/ContainerReply' + GetAllContainersReq: type: object properties: - list: - type: array - items: - $ref: '#/components/schemas/PoolNodeReply' - ResourcePoolListData: + filters: + $ref: '#/components/schemas/GetAllContainersReq_Filters' + pageSize: + $ref: '#/components/schemas/GetAllContainersReq_PageSize' + GetAllContainersReq_Filters: type: object properties: - poolId: - type: string - poolName: + name: type: string - cpuCores: + nodeName: type: string - nodeNum: + status: type: string - gpuNum: + deviceId: type: string - availableMemory: + nodeUid: type: string - totalMemory: + resourceGroup: type: string - diskSize: + priority: type: string - nodeList: - type: array - items: - $ref: '#/components/schemas/Nodes' - ResourcePoolListResponse: + GetAllContainersReq_PageSize: type: object properties: - data: - type: array - items: - $ref: '#/components/schemas/ResourcePoolListData' - ResourcePoolUpdateRequest: + pageSize: + type: integer + format: int32 + pageNo: + type: integer + format: int32 + sort: + type: string + sortField: + type: string + GoogleProtobufAny: type: object properties: - poolId: - type: string - poolName: + '@type': type: string - nodes: - type: array - items: - $ref: '#/components/schemas/Nodes' + description: The type of the serialized message. + additionalProperties: true + description: Contains an arbitrary serialized message along with a @type that describes the type of the serialized message. Status: type: object properties: @@ -351,4 +188,4 @@ components: description: A list of messages that carry the error details. There is a common set of message types for APIs to use. description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' tags: - - name: ResourcePool + - name: Container