Skip to content

Commit

Permalink
fix: 根据适配器修改响应接口
Browse files Browse the repository at this point in the history
  • Loading branch information
usaveh committed Jul 30, 2024
1 parent 8aa45de commit 2a41eaf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 0 additions & 1 deletion apps/portal-server/src/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const staticConfigServiceServer = plugin((server) => {
return [{ clusterConfigs: clusterConfigsProto }];
},


});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import { typeboxRouteSchema } from "@ddadaal/next-typed-api-routes-runtime";
import { asyncUnaryCall } from "@ddadaal/tsgrpc-client";
import { ConfigServiceClient } from "@scow/protos/build/portal/config";
import { NodeInfo_NodeState } from "@scow/protos/build/portal/config";
import { Static, Type } from "@sinclair/typebox";
import { authenticate } from "src/auth/server";
import { getClient } from "src/utils/client";
Expand All @@ -21,7 +22,7 @@ import { route } from "src/utils/route";
export const NodeInfo = Type.Object({
nodeName: Type.String(),
partitions: Type.Array(Type.String()),
state: Type.String(),
state: Type.Enum(NodeInfo_NodeState),
cpuCoreCount: Type.Number(),
allocCpuCoreCount: Type.Number(),
idleCpuCoreCount: Type.Number(),
Expand Down
6 changes: 3 additions & 3 deletions apps/portal-web/src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ export const DashboardPage: NextPage<Props> = requireAuth(() => true)(() => {
// 去除被重复计算的节点
duplicateNodes.forEach((duplicateNode) => {
const conunt = duplicateNode.partitions.length - 1;
aggregatedData.runningNodeCount -= (duplicateNode?.state === "ALLOC") ? conunt : 0;
aggregatedData.idleNodeCount -= duplicateNode?.state.includes("IDLE") ? conunt : 0;
aggregatedData.runningNodeCount -= (duplicateNode?.state === 2) ? conunt : 0;
aggregatedData.idleNodeCount -= duplicateNode?.state === 1 ? conunt : 0;
aggregatedData.notAvailableNodeCount -=
(!duplicateNode?.state.includes("IDLE") && duplicateNode?.state !== "ALLOC")
(duplicateNode?.state !== 1 && duplicateNode?.state !== 2)
? conunt : 0;
aggregatedData.cpuCoreCount -= conunt * (duplicateNode?.cpuCoreCount ?? 0);
aggregatedData.runningCpuCount -= conunt * (duplicateNode?.allocCpuCoreCount ?? 0);
Expand Down
11 changes: 10 additions & 1 deletion protos/portal/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@ message GetClusterInfoResponse {
}

message NodeInfo {

enum NodeState {
UNKNOWN = 0;
IDLE = 1;
RUNNING = 2;
NOT_AVAILABLE = 3;
}

string node_name = 1;
repeated string partitions = 2;
string state = 3;
NodeState state = 3;
uint32 cpu_core_count = 4;
uint32 alloc_cpu_core_count = 5;
uint32 idle_cpu_core_count = 6;
Expand All @@ -67,6 +75,7 @@ message NodeInfo {
uint32 idle_gpu_count = 12;
}


message GetClusterNodesInfoRequest {
// if the value of node_names = [], request all nodes info
string cluster = 1;
Expand Down

0 comments on commit 2a41eaf

Please sign in to comment.