fix: cluster apis

This commit is contained in:
jialin
2025-09-16 11:26:17 +08:00
parent f04f1f828f
commit 632f206228
34 changed files with 578 additions and 329 deletions
+6
View File
@@ -5,6 +5,12 @@ export const WORKERS_API = '/workers';
export const GPU_DEVICES_API = '/gpu-devices';
export const MODEL_FILES_API = '/model-files';
export async function downloadWorkerPrivateKey(id: string | number) {
return request(`${WORKERS_API}/${id}/privatekey`, {
method: 'GET'
});
}
export async function queryWorkersList<T extends Record<string, any>>(
params: Global.SearchParams & T
) {
@@ -47,6 +47,7 @@ const AddWorker: React.FC<ViewModalProps> = (props) => {
return commandCode?.registerWorker({
server: registrationInfo.server_url || origin,
tag: tag,
image: registrationInfo.image,
token: registrationInfo.token || '${token}',
workerip: '${workerip}'
});
@@ -10,6 +10,7 @@ import React, { useEffect, useState } from 'react';
import {
WORKERS_API,
deleteWorker,
downloadWorkerPrivateKey,
queryWorkersList,
updateWorker
} from '../apis';
@@ -144,6 +145,9 @@ const Workers: React.FC = () => {
if (val === 'details') {
handleViewDetail(record);
}
if (val === 'download_ssh_key') {
downloadWorkerPrivateKey(record.id);
}
});
const renderEmpty = (type?: string) => {
+32 -21
View File
@@ -5,7 +5,8 @@ export const WorkerStatusMap = {
not_ready: 'not_ready',
unreachable: 'unreachable',
provisioning: 'provisioning',
deleting: 'deleting'
deleting: 'deleting',
error: 'error'
};
export const WorkerStatusMapValue = {
@@ -13,7 +14,8 @@ export const WorkerStatusMapValue = {
[WorkerStatusMap.not_ready]: 'Not Ready',
[WorkerStatusMap.unreachable]: 'Unreachable',
[WorkerStatusMap.provisioning]: 'Provisioning',
[WorkerStatusMap.deleting]: 'Deleting'
[WorkerStatusMap.deleting]: 'Deleting',
[WorkerStatusMap.error]: 'Error'
};
export const status: any = {
@@ -21,21 +23,22 @@ export const status: any = {
[WorkerStatusMap.not_ready]: StatusMaps.error,
[WorkerStatusMap.unreachable]: StatusMaps.error,
[WorkerStatusMap.provisioning]: StatusMaps.transitioning,
[WorkerStatusMap.deleting]: StatusMaps.warning
[WorkerStatusMap.deleting]: StatusMaps.warning,
[WorkerStatusMap.error]: StatusMaps.error
};
export const addWorkerGuide: Record<string, any> = {
mac: {
getToken: 'cat /var/lib/gpustack/token',
registerWorker(params: { server: string; token: string }) {
return `curl -sfL https://get.gpustack.ai | sh -s - --server-url ${params.server} --registration ${params.token}`;
return `curl -sfL https://get.gpustack.ai | sh -s - --server-url ${params.server} --registration-token ${params.token}`;
}
},
win: {
getToken:
'Get-Content -Path (Join-Path -Path $env:APPDATA -ChildPath "gpustack\\token") -Raw',
registerWorker(params: { server: string; token: string }) {
return `Invoke-Expression "& { $((Invoke-WebRequest -Uri 'https://get.gpustack.ai' -UseBasicParsing).Content) } --server-url '${params.server}' --registration '${params.token}'"`;
return `Invoke-Expression "& { $((Invoke-WebRequest -Uri 'https://get.gpustack.ai' -UseBasicParsing).Content) } --server-url '${params.server}' --registration-token '${params.token}'"`;
}
},
cuda: {
@@ -45,6 +48,7 @@ export const addWorkerGuide: Record<string, any> = {
server: string;
tag: string;
token: string;
image: string;
workerip: string;
}) {
return `docker run -d --name gpustack \\
@@ -53,8 +57,8 @@ export const addWorkerGuide: Record<string, any> = {
--network=host \\
--ipc=host \\
-v gpustack-data:/var/lib/gpustack \\
gpustack/gpustack:${params.tag} \\
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
${params.image} \\
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
}
},
npu: {
@@ -65,6 +69,7 @@ export const addWorkerGuide: Record<string, any> = {
tag: string;
token: string;
workerip: string;
image: string;
}) {
return `docker run -d --name gpustack \\
--restart=unless-stopped \\
@@ -81,8 +86,8 @@ export const addWorkerGuide: Record<string, any> = {
--network=host \\
--ipc=host \\
-v gpustack-data:/var/lib/gpustack \\
gpustack/gpustack:${params.tag} \\
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
${params.image} \\
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
}
},
npu310p: {
@@ -93,6 +98,7 @@ export const addWorkerGuide: Record<string, any> = {
tag: string;
token: string;
workerip: string;
image: string;
}) {
return `docker run -d --name gpustack \\
--restart=unless-stopped \\
@@ -109,8 +115,8 @@ export const addWorkerGuide: Record<string, any> = {
--network=host \\
--ipc=host \\
-v gpustack-data:/var/lib/gpustack \\
gpustack/gpustack:${params.tag}-310p \\
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
${params.image} -310p \\
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
}
},
musa: {
@@ -121,14 +127,15 @@ export const addWorkerGuide: Record<string, any> = {
tag: string;
token: string;
workerip: string;
image: string;
}) {
return `docker run -d --name gpustack \\
--restart=unless-stopped \\
--network=host \\
--ipc=host \\
-v gpustack-data:/var/lib/gpustack \\
gpustack/gpustack:${params.tag} \\
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
${params.image} \\
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
}
},
cpu: {
@@ -139,13 +146,14 @@ export const addWorkerGuide: Record<string, any> = {
tag: string;
token: string;
workerip: string;
image: string;
}) {
return `docker run -d --name gpustack \\
--restart=unless-stopped \\
--network=host \\
-v gpustack-data:/var/lib/gpustack \\
gpustack/gpustack:${params.tag} \\
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
${params.image} \\
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
}
},
rocm: {
@@ -154,6 +162,7 @@ export const addWorkerGuide: Record<string, any> = {
tag: string;
token: string;
workerip: string;
image: string;
}) {
return `docker run -d --name gpustack \\
--restart=unless-stopped \\
@@ -165,8 +174,8 @@ export const addWorkerGuide: Record<string, any> = {
--cap-add=SYS_PTRACE \\
--security-opt seccomp=unconfined \\
-v gpustack-data:/var/lib/gpustack \\
gpustack/gpustack:${params.tag} \\
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
${params.image} \\
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
}
},
dcu: {
@@ -175,6 +184,7 @@ export const addWorkerGuide: Record<string, any> = {
tag: string;
token: string;
workerip: string;
image: string;
}) {
return `docker run -d --name gpustack \\
--restart=unless-stopped \\
@@ -188,8 +198,8 @@ export const addWorkerGuide: Record<string, any> = {
--cap-add=SYS_PTRACE \\
--security-opt seccomp=unconfined \\
-v gpustack-data:/var/lib/gpustack \\
gpustack/gpustack:${params.tag} \\
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
${params.image} \\
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
}
},
corex: {
@@ -198,6 +208,7 @@ export const addWorkerGuide: Record<string, any> = {
tag: string;
token: string;
workerip: string;
image: string;
}) {
return `docker run -d --name gpustack \\
-v /lib/modules:/lib/modules \\
@@ -209,8 +220,8 @@ export const addWorkerGuide: Record<string, any> = {
--network=host \\
--ipc=host \\
-v gpustack-data:/var/lib/gpustack \\
gpustack/gpustack:${params.tag} \\
--server-url ${params.server} --registration ${params.token} --worker-ip ${params.workerip}`;
${params.image} \\
--server-url ${params.server} --registration-token ${params.token} --worker-ip ${params.workerip}`;
}
},
container: {
+2
View File
@@ -66,6 +66,8 @@ export interface ListItem {
ip: string;
cluster_id: number;
state_message: string;
ssh_key_id: string;
progress: string;
status: {
cpu: {
total: number;
@@ -1,14 +1,13 @@
import AutoTooltip from '@/components/auto-tooltip';
import DropdownButtons from '@/components/drop-down-buttons';
import IconFont from '@/components/icon-font';
import LabelsCell from '@/components/label-cell';
import ProgressBar from '@/components/progress-bar';
import InfoColumn from '@/components/simple-table/info-column';
import StatusTag from '@/components/status-tag';
import { convertFileSize } from '@/utils';
import {
CodeOutlined,
DeleteOutlined,
DownloadOutlined,
EditOutlined,
FileTextOutlined,
InfoCircleOutlined
@@ -18,7 +17,7 @@ import { Tooltip } from 'antd';
import { ColumnsType } from 'antd/lib/table';
import _ from 'lodash';
import { useMemo } from 'react';
import { WorkerStatusMap, WorkerStatusMapValue, status } from '../config';
import { WorkerStatusMapValue, status } from '../config';
import { Filesystem, GPUDeviceItem, ListItem } from '../config/types';
const ActionList = [
@@ -29,12 +28,17 @@ const ActionList = [
icon: <FileTextOutlined></FileTextOutlined>
},
{
label: 'common.button.logs',
locale: false,
key: 'logs',
icon: <IconFont type="icon-logs" />
label: 'resources.worker.download.privatekey',
key: 'download_ssh_key',
icon: <DownloadOutlined />
},
{ label: 'Terminal', locale: false, key: 'terminal', icon: <CodeOutlined /> },
// {
// label: 'common.button.logs',
// locale: false,
// key: 'logs',
// icon: <IconFont type="icon-logs" />
// },
// { label: 'Terminal', locale: false, key: 'terminal', icon: <CodeOutlined /> },
{
label: 'common.button.delete',
key: 'delete',
@@ -45,8 +49,8 @@ const ActionList = [
const setActions = (row: ListItem) => {
return ActionList.filter((action) => {
if (action.key === 'details' && row.state === WorkerStatusMap.ready) {
return true;
if (action.key === 'download_ssh_key') {
return !!row.ssh_key_id;
}
return true;
});
@@ -224,6 +228,7 @@ const useWorkerColumns = ({
render: (_, record) => (
<StatusTag
maxTooltipWidth={400}
suffix={record.progress}
statusValue={{
status: status[record.state] as any,
text: WorkerStatusMapValue[record.state],