Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(portal): 修复门户中节点计数重复的问题(这个分支要等适配器版本才能合并) #1370

Merged
merged 23 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/silver-pianos-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@scow/scheduler-adapter-protos": minor
"@scow/portal-server": minor
"@scow/portal-web": patch
---

修复了门户系统中节点在不同集群中重复计数的问题
1 change: 0 additions & 1 deletion apps/mis-server/src/bl/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,3 @@ export async function unblockUserInAccount(
accountName, userId,
}, logger);
}

17 changes: 15 additions & 2 deletions apps/portal-server/src/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export const staticConfigServiceServer = plugin((server) => {
return [ { partitions: availablePartitions } ];
},


getClusterConfigFiles: async ({ logger }) => {

const clusterConfigs = getClusterConfigs(undefined, logger, ["hpc"]);
Expand Down Expand Up @@ -102,11 +101,25 @@ export const runtimeConfigServiceServer = plugin((server) => {
const minRequiredApiVersion: ApiVersion = { major: 1, minor: 4, patch: 0 };
// 检验调度器的API版本是否符合要求,不符合要求报错
await checkSchedulerApiVersion(client, minRequiredApiVersion);
return await asyncClientCall(client.config, "getClusterInfo", {});
return await asyncClientCall(client.config, "getClusterInfo", request);
},
);

return [reply];
},

getClusterNodesInfo: async ({ request, logger }) => {
const { nodeNames,cluster } = request;

const reply = await callOnOne(
cluster,
logger,
async (client) => await asyncClientCall(client.config, "getClusterNodesInfo", {
usaveh marked this conversation as resolved.
Show resolved Hide resolved
nodeNames: nodeNames || [],
}),
);

return [{ nodes: reply.nodes }];
},
});
});
207 changes: 123 additions & 84 deletions apps/portal-web/src/apis/api.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,45 +63,46 @@ export const job: JobInfo = {
};

export const mockApi: MockApi<typeof api> = {

getQuickEntries:async () => ({ quickEntries: [
{
id:"submitJob",
name:"submitJob",
entry:{
$case:"pageLink",
pageLink:{
path: "/jobs/submit",
icon:"PlusCircleOutlined",
getQuickEntries: async () => ({
quickEntries: [
{
id: "submitJob",
name: "submitJob",
entry: {
$case: "pageLink",
pageLink: {
path: "/jobs/submit",
icon: "PlusCircleOutlined",
},
},
},
},
{
id:"runningJob",
name:"runningJobs",
entry:{
$case:"pageLink",
pageLink:{
path: "/jobs/runningJobs",
icon:"BookOutlined",
{
id: "runningJob",
name: "runningJobs",
entry: {
$case: "pageLink",
pageLink: {
path: "/jobs/runningJobs",
icon: "BookOutlined",
},
},
},
},
{
id:"allJobs",
name:"allJobs",
entry:{
$case:"pageLink",
pageLink:{
path: "/jobs/allJobs",
icon:"BookOutlined",
{
id: "allJobs",
name: "allJobs",
entry: {
$case: "pageLink",
pageLink: {
path: "/jobs/allJobs",
icon: "BookOutlined",
},
},
},
},
]}),
saveQuickEntries:null,
],
}),
saveQuickEntries: null,
getClusterInfo: null,
getClusterRunningInfo:null,
getClusterRunningInfo: null,
listAvailableTransferClusters: null,

checkAppConnectivity: async () => ({
Expand All @@ -112,7 +113,7 @@ export const mockApi: MockApi<typeof api> = {

listAvailableApps: async () => ({
apps: [
{ id: "vscode", name: "VSCode", logoPath:"/apps/VSCode.svg" },
{ id: "vscode", name: "VSCode", logoPath: "/apps/VSCode.svg" },
{ id: "emacs", name: "Emacs" },
{ id: "jupyter", name: "jupyter" },
],
Expand Down Expand Up @@ -141,33 +142,50 @@ export const mockApi: MockApi<typeof api> = {
wms: [{ name: "cinnamon", wm: "Cinnamon" }, { name: "gnome", wm: "GNOME" }],
}),

getAppSessions: async () => ({ sessions: [
{ jobId: 100, sessionId: "123", appId: "vscode", appName:"vscode", state: "PENDING", reason: "resource",
submitTime: new Date().toISOString(), host: "192.168.88.100", port: 1000, dataPath: "/test",
timeLimit: "01:00:00", runningTime: "" },
{ jobId: 101, sessionId: "124", appId: "vscode", appName:"vscode", state: "RUNNING",
submitTime: new Date().toISOString(), dataPath: "/test",
timeLimit: "1-01:00:00", runningTime: "01:50" },
{ jobId: 102, sessionId: "125", appId: "vscode", appName:"vscode", state: "RUNNING",
submitTime: new Date().toISOString(), host: "192.168.88.100", port: 10000, dataPath: "/test",
timeLimit: "INVALID", runningTime: "01:55" },
]}),
getAppSessions: async () => ({
sessions: [
{
jobId: 100, sessionId: "123", appId: "vscode", appName: "vscode", state: "PENDING", reason: "resource",
submitTime: new Date().toISOString(), host: "192.168.88.100", port: 1000, dataPath: "/test",
timeLimit: "01:00:00", runningTime: "",
},
{
jobId: 101, sessionId: "124", appId: "vscode", appName: "vscode", state: "RUNNING",
submitTime: new Date().toISOString(), dataPath: "/test",
timeLimit: "1-01:00:00", runningTime: "01:50",
},
{
jobId: 102, sessionId: "125", appId: "vscode", appName: "vscode", state: "RUNNING",
submitTime: new Date().toISOString(), host: "192.168.88.100", port: 10000, dataPath: "/test",
timeLimit: "INVALID", runningTime: "01:55",
},
],
}),

getAppMetadata: async () => ({
appName: "test",
appCustomFormAttributes: [
{ type: "NUMBER", label: "版本", name: "version", required: false,
placeholder: "选择版本", defaultValue: 123, select: []},
{ type: "TEXT", label: "文字", name: "text", required: false,
placeholder: "提示信息", defaultValue: 555, select: []},
{ type: "TEXT", label: "其他sbatch参数", name: "sbatchOptions",
required: true, placeholder: "比如:--gpus gres:2 --time 10", select: []},
{ type: "SELECT", label: "选项", name: "option", required: false,
{
type: "NUMBER", label: "版本", name: "version", required: false,
placeholder: "选择版本", defaultValue: 123, select: [],
},
{
type: "TEXT", label: "文字", name: "text", required: false,
placeholder: "提示信息", defaultValue: 555, select: [],
},
{
type: "TEXT", label: "其他sbatch参数", name: "sbatchOptions",
required: true, placeholder: "比如:--gpus gres:2 --time 10", select: [],
},
{
type: "SELECT", label: "选项", name: "option", required: false,
placeholder: "提示信息", defaultValue: "version2", select: [
{ label: "版本1", value: "version1" },
{ label: "版本2", value: "version2" },
]},
]}),
],
},
],
}),

connectToApp: async ({ body: { sessionId } }) => sessionId === "124"
? {
Expand All @@ -183,8 +201,8 @@ export const mockApi: MockApi<typeof api> = {
}
: {
host: "127.0.0.1", port: 3000, password: "123", type: "vnc",
}
,
},


getJobTemplate: async () => ({
template: {
Expand All @@ -199,16 +217,18 @@ export const mockApi: MockApi<typeof api> = {
output: "job.%j.out",
errorOutput: "job.%j.err",
workingDirectory: "/nfs/jobs/123",
maxTimeUnit: TimeUnit.MINUTES,
maxTimeUnit: TimeUnit.MINUTES,
},
}),

listJobTemplates: async () => ({ results: [{
id: "123-sample-apple",
comment: "1234",
submitTime: new Date().toString(),
jobName: "sample-apple",
}]}),
listJobTemplates: async () => ({
results: [{
id: "123-sample-apple",
comment: "1234",
submitTime: new Date().toString(),
jobName: "sample-apple",
}],
}),

deleteJobTemplate: async () => null,

Expand Down Expand Up @@ -277,30 +297,49 @@ export const mockApi: MockApi<typeof api> = {
checkTransferKey: null,

getAvailablePartitionsForCluster: async () => ({ partitions: []}),
getClusterConfigFiles: async () => ({ clusterConfigs: {
hpc01: {
displayName: "hpc01Name",
priority: 1,
adapterUrl: "0.0.0.0:0000",
proxyGateway: undefined,
loginNodes: [{ "address": "localhost:22222", "name": "login" }],
loginDesktop: undefined,
turboVncPath: undefined,
crossClusterFileTransfer: undefined,
hpc: { enabled: true },
ai: { enabled: false },
k8s: undefined,
getClusterConfigFiles: async () => ({
clusterConfigs: {
hpc01: {
displayName: "hpc01Name",
priority: 1,
adapterUrl: "0.0.0.0:0000",
proxyGateway: undefined,
loginNodes: [{ "address": "localhost:22222", "name": "login" }],
loginDesktop: undefined,
turboVncPath: undefined,
crossClusterFileTransfer: undefined,
hpc: { enabled: true },
ai: { enabled: false },
k8s: undefined,
},
},
} }),

getClustersRuntimeInfo: async () => ({ results: [{
clusterId: "hpc01",
activationStatus: ClusterActivationStatus.ACTIVATED,
operatorId: undefined,
operatorName: undefined,
comment: "",
}]}),
}),

getClustersRuntimeInfo: async () => ({
results: [{
clusterId: "hpc01",
activationStatus: ClusterActivationStatus.ACTIVATED,
operatorId: undefined,
operatorName: undefined,
comment: "",
}],
}),
getClusterNodesInfo: async () => ({
nodeInfo: [{
gpuCount: 1,
state: 1,
partitions: ["linux","compute"],
cpuCoreCount: 1,
idleGpuCount: 1,
nodeName: "h1",
allocCpuCoreCount: 1,
idleCpuCoreCount: 1,
totalMemMb: 0.23,
allocMemMb: 0.32,
idleMemMb: 0.5,
allocGpuCount: 0.5,
}],
}),
};


Expand Down
2 changes: 2 additions & 0 deletions apps/portal-web/src/apis/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type { AuthCallbackSchema } from "src/pages/api/auth/callback";
import type { LogoutSchema } from "src/pages/api/auth/logout";
import type { ValidateTokenSchema } from "src/pages/api/auth/validateToken";
import type { GetClusterRunningInfoSchema } from "src/pages/api/dashboard/getClusterInfo";
import type { GetClusterNodesInfoSchema } from "src/pages/api/dashboard/getClusterNodesInfo";
import type { GetQuickEntriesSchema } from "src/pages/api/dashboard/getQuickEntries";
import type { SaveQuickEntriesSchema } from "src/pages/api/dashboard/saveQuickEntries";
import type { CreateDesktopSchema } from "src/pages/api/desktop/createDesktop";
Expand Down Expand Up @@ -79,6 +80,7 @@ export const api = {
validateToken: apiClient.fromTypeboxRoute<typeof ValidateTokenSchema>("GET", "/api/auth/validateToken"),
getClusterInfo: apiClient.fromTypeboxRoute<typeof GetClusterInfoSchema>("GET", "/api//cluster"),
getClusterRunningInfo: apiClient.fromTypeboxRoute<typeof GetClusterRunningInfoSchema>("GET", "/api/dashboard/getClusterInfo"),
getClusterNodesInfo: apiClient.fromTypeboxRoute<typeof GetClusterNodesInfoSchema>("GET", "/api/dashboard/getClusterNodesInfo"),
getQuickEntries: apiClient.fromTypeboxRoute<typeof GetQuickEntriesSchema>("GET", "/api/dashboard/getQuickEntries"),
saveQuickEntries: apiClient.fromTypeboxRoute<typeof SaveQuickEntriesSchema>("POST", "/api/dashboard/saveQuickEntries"),
createDesktop: apiClient.fromTypeboxRoute<typeof CreateDesktopSchema>("POST", "/api/desktop/createDesktop"),
Expand Down
2 changes: 1 addition & 1 deletion apps/portal-web/src/i18n/zh_cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ export default {
resourceInfo:"资源信息",
core:"核",
running:"运行中",
idle:"可用",
idle:"空闲",
notAvailable:"不可用",
card:"卡",
job:"作业",
Expand Down
Loading
Loading