From e47a9304f4291884d0631e950f0767138cfe6a52 Mon Sep 17 00:00:00 2001 From: jialin Date: Thu, 28 May 2026 14:10:41 +0800 Subject: [PATCH] fix: cluster worker_config refill --- .../components/cluster-form.tsx | 4 +- .../config/worker-config.docker.json | 106 +++++++++++++++ .../config/worker-config.json | 117 ---------------- .../config/worker-config.kubernetes.json | 125 ++++++++++++++++++ .../config/yaml-template.ts | 5 + .../step-forms/advance-config.tsx | 15 ++- .../gpu-service/templates/config/index.tsx | 1 + 7 files changed, 252 insertions(+), 121 deletions(-) create mode 100644 src/pages/cluster-management/config/worker-config.docker.json delete mode 100644 src/pages/cluster-management/config/worker-config.json create mode 100644 src/pages/cluster-management/config/worker-config.kubernetes.json diff --git a/src/pages/cluster-management/components/cluster-form.tsx b/src/pages/cluster-management/components/cluster-form.tsx index 9918a27f..ef3aea03 100644 --- a/src/pages/cluster-management/components/cluster-form.tsx +++ b/src/pages/cluster-management/components/cluster-form.tsx @@ -119,8 +119,8 @@ const ClusterForm: React.FC = forwardRef( if (!Array.isArray(creds)) return values; const fixed = creds.map((c: any) => ({ ...c, - username: c?.username ? c.username : null, - password: c?.password ? c.password : null + username: c?.username || null, + password: c?.password || null })); return { ...values, diff --git a/src/pages/cluster-management/config/worker-config.docker.json b/src/pages/cluster-management/config/worker-config.docker.json new file mode 100644 index 00000000..1085a696 --- /dev/null +++ b/src/pages/cluster-management/config/worker-config.docker.json @@ -0,0 +1,106 @@ +{ + "type": "object", + "additionalProperties": false, + "properties": { + "debug": { + "type": "boolean", + "description": "Enable debug mode" + }, + "cache_dir": { + "type": "string", + "description": "Cache directory path" + }, + "log_dir": { + "type": "string", + "description": "Log directory path" + }, + "bin_dir": { + "type": "string", + "description": "Binary directory path" + }, + "system_default_container_registry": { + "type": "string", + "description": "Default container registry" + }, + "image_name_override": { + "type": "string", + "description": "Override image name" + }, + "image_repo": { + "type": "string", + "description": "Container image repository" + }, + "huggingface_token": { + "type": "string", + "description": "Hugging Face access token" + }, + "disable_worker_metrics": { + "type": "boolean", + "description": "Disable worker metrics collection" + }, + "worker_port": { + "type": "integer", + "minimum": 1, + "maximum": 65535, + "description": "Worker service port" + }, + "worker_metrics_port": { + "type": "integer", + "minimum": 1, + "maximum": 65535, + "description": "Worker metrics port" + }, + "service_port_range": { + "type": "string", + "pattern": "^\\d+-\\d+$", + "description": "Service port range, e.g. 30000-31000" + }, + "ray_port_range": { + "type": "string", + "pattern": "^\\d+-\\d+$", + "description": "Ray port range, e.g. 20000-20100" + }, + "system_reserved": { + "type": "object", + "description": "System reserved resources", + "properties": { + "ram": { + "type": "number", + "minimum": 0, + "description": "Reserved RAM in GiB" + }, + "vram": { + "type": "number", + "minimum": 0, + "description": "Reserved VRAM in GiB" + } + } + }, + "resources": { + "type": "object", + "description": "Additional resource definitions", + "additionalProperties": {} + }, + "pipx_path": { + "type": "string", + "description": "pipx installation path" + }, + "tools_download_base_url": { + "type": "string", + "description": "Base URL for downloading tools" + }, + "enable_hf_transfer": { + "type": "boolean", + "description": "Enable Hugging Face transfer acceleration" + }, + "enable_hf_xet": { + "type": "boolean", + "description": "Enable Hugging Face Xet support" + }, + "proxy_mode": { + "type": "string", + "enum": ["worker", "system", "disabled"], + "description": "Proxy mode" + } + } +} diff --git a/src/pages/cluster-management/config/worker-config.json b/src/pages/cluster-management/config/worker-config.json deleted file mode 100644 index 6b19e254..00000000 --- a/src/pages/cluster-management/config/worker-config.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "type": "object", - "properties": { - "worker_config": { - "type": "object", - "additionalProperties": false, - "properties": { - "debug": { - "type": "boolean", - "description": "Enable debug mode" - }, - "cache_dir": { - "type": "string", - "description": "Cache directory path" - }, - "log_dir": { - "type": "string", - "description": "Log directory path" - }, - "bin_dir": { - "type": "string", - "description": "Binary directory path" - }, - "system_default_container_registry": { - "type": "string", - "description": "Default container registry" - }, - "image_name_override": { - "type": "string", - "description": "Override image name" - }, - "image_repo": { - "type": "string", - "description": "Container image repository" - }, - "gateway_mode": { - "type": "string", - "description": "Gateway mode", - "enum": ["worker", "gateway", "disabled", "auto"] - }, - "gateway_kubeconfig": { - "type": "string", - "description": "Path to kubeconfig used by gateway" - }, - "gateway_concurrency": { - "type": "integer", - "minimum": 0, - "description": "Gateway concurrency limit" - }, - "service_discovery_name": { - "type": "string", - "description": "Service discovery name" - }, - "namespace": { - "type": "string", - "description": "Kubernetes namespace" - }, - "huggingface_token": { - "type": "string", - "description": "Hugging Face access token" - }, - "disable_worker_metrics": { - "type": "boolean", - "description": "Disable worker metrics collection" - }, - "worker_port": { - "type": "integer", - "minimum": 1, - "maximum": 65535, - "description": "Worker service port" - }, - "worker_metrics_port": { - "type": "integer", - "minimum": 1, - "maximum": 65535, - "description": "Worker metrics port" - }, - "service_port_range": { - "type": "string", - "pattern": "^\\d+-\\d+$", - "description": "Service port range, e.g. 30000-31000" - }, - "ray_port_range": { - "type": "string", - "pattern": "^\\d+-\\d+$", - "description": "Ray port range, e.g. 20000-20100" - }, - "resources": { - "type": "object", - "description": "Additional resource definitions", - "additionalProperties": {} - }, - "pipx_path": { - "type": "string", - "description": "pipx installation path" - }, - "tools_download_base_url": { - "type": "string", - "description": "Base URL for downloading tools" - }, - "enable_hf_transfer": { - "type": "boolean", - "description": "Enable Hugging Face transfer acceleration" - }, - "enable_hf_xet": { - "type": "boolean", - "description": "Enable Hugging Face Xet support" - }, - "proxy_mode": { - "type": "string", - "enum": ["worker", "system", "disabled"], - "description": "Proxy mode" - } - } - } - } -} diff --git a/src/pages/cluster-management/config/worker-config.kubernetes.json b/src/pages/cluster-management/config/worker-config.kubernetes.json new file mode 100644 index 00000000..b6f6db24 --- /dev/null +++ b/src/pages/cluster-management/config/worker-config.kubernetes.json @@ -0,0 +1,125 @@ +{ + "type": "object", + "additionalProperties": false, + "properties": { + "debug": { + "type": "boolean", + "description": "Enable debug mode" + }, + "cache_dir": { + "type": "string", + "description": "Cache directory path" + }, + "log_dir": { + "type": "string", + "description": "Log directory path" + }, + "system_default_container_registry": { + "type": "string", + "description": "Default container registry" + }, + "image_name_override": { + "type": "string", + "description": "Override image name" + }, + "image_repo": { + "type": "string", + "description": "Container image repository" + }, + "operator_image": { + "type": "string", + "description": "GPUStack operator image, format: :", + "examples": ["gpustack/gpustack-operator:"] + }, + "gpu_instances_access_static_address": { + "type": "string", + "description": "Static address used to access GPU instances" + }, + "gateway_mode": { + "type": "string", + "description": "Gateway mode", + "enum": ["worker", "gateway", "disabled", "auto"] + }, + "gateway_kubeconfig": { + "type": "string", + "description": "Path to kubeconfig used by gateway" + }, + "gateway_concurrency": { + "type": "integer", + "minimum": 0, + "description": "Gateway concurrency limit" + }, + "service_discovery_name": { + "type": "string", + "description": "Service discovery name" + }, + "namespace": { + "type": "string", + "description": "Kubernetes namespace" + }, + "huggingface_token": { + "type": "string", + "description": "Hugging Face access token" + }, + "disable_worker_metrics": { + "type": "boolean", + "description": "Disable worker metrics collection" + }, + "worker_port": { + "type": "integer", + "minimum": 1, + "maximum": 65535, + "description": "Worker service port" + }, + "worker_metrics_port": { + "type": "integer", + "minimum": 1, + "maximum": 65535, + "description": "Worker metrics port" + }, + "service_port_range": { + "type": "string", + "pattern": "^\\d+-\\d+$", + "description": "Service port range, e.g. 30000-31000" + }, + "ray_port_range": { + "type": "string", + "pattern": "^\\d+-\\d+$", + "description": "Ray port range, e.g. 20000-20100" + }, + "system_reserved": { + "type": "object", + "description": "System reserved resources", + "properties": { + "ram": { + "type": "number", + "minimum": 0, + "description": "Reserved RAM in GiB" + }, + "vram": { + "type": "number", + "minimum": 0, + "description": "Reserved VRAM in GiB" + } + } + }, + "resources": { + "type": "object", + "description": "Additional resource definitions", + "additionalProperties": {} + }, + "enable_hf_transfer": { + "type": "boolean", + "description": "Enable Hugging Face transfer acceleration" + }, + "enable_hf_xet": { + "type": "boolean", + "description": "Enable Hugging Face Xet support" + }, + "proxy_mode": { + "type": "string", + "enum": ["worker", "system", "disabled"], + "description": "Proxy mode" + } + } +} diff --git a/src/pages/cluster-management/config/yaml-template.ts b/src/pages/cluster-management/config/yaml-template.ts index 9eeaa8ec..61b5327a 100644 --- a/src/pages/cluster-management/config/yaml-template.ts +++ b/src/pages/cluster-management/config/yaml-template.ts @@ -56,6 +56,11 @@ export const kubernetesConfig = `# This is a template for worker_config. # system_default_container_registry: "docker.io" # image_name_override: "gpustack/gpustack:dev" # image_repo: "gpustack/gpustack" +# operator_image: "gpustack/gpustack-operator: + +# ========= GPU instances =========== + +# gpu_instances_access_static_address: # ========= service & networking =========== diff --git a/src/pages/cluster-management/step-forms/advance-config.tsx b/src/pages/cluster-management/step-forms/advance-config.tsx index e1ff7ce3..399f50b6 100644 --- a/src/pages/cluster-management/step-forms/advance-config.tsx +++ b/src/pages/cluster-management/step-forms/advance-config.tsx @@ -14,7 +14,8 @@ import { ClusterFormData as FormData, ClusterListItem as ListItem } from '../config/types'; -import schema from '../config/worker-config.json'; +import dockerSchema from '../config/worker-config.docker.json'; +import kubernetesSchema from '../config/worker-config.kubernetes.json'; import { dockerConfig, kubernetesConfig } from '../config/yaml-template'; const Title = styled.div` @@ -40,6 +41,8 @@ const ClusterAdvanceConfig: React.FC<{ const editorRef = React.useRef(null); const { isDarkTheme } = useUserSettings(); const [fileContent, setFileContent] = React.useState(''); + const schema = + provider === ProviderValueMap.Kubernetes ? kubernetesSchema : dockerSchema; useImperativeHandle(ref, () => ({ getYamlValue: () => { @@ -62,8 +65,16 @@ const ClusterAdvanceConfig: React.FC<{ ? kubernetesConfig : dockerConfig ); + } else if (action === PageAction.EDIT) { + const workerConfig = currentData?.worker_config; + const content = + workerConfig || + (provider === ProviderValueMap.Kubernetes + ? kubernetesConfig + : dockerConfig); + setFileContent(content as string); } - }, [provider, action]); + }, [provider, action, currentData?.worker_config]); return ( <> diff --git a/src/pages/gpu-service/templates/config/index.tsx b/src/pages/gpu-service/templates/config/index.tsx index 87366e17..a61b71ec 100644 --- a/src/pages/gpu-service/templates/config/index.tsx +++ b/src/pages/gpu-service/templates/config/index.tsx @@ -96,6 +96,7 @@ export const templateActions = [ label: 'common.button.edit', key: 'edit', locale: true, + access: 'canSeeAdmin', icon: icons.EditOutlined }, {