diff --git a/frontend/providers/applaunchpad/src/constants/editApp.ts b/frontend/providers/applaunchpad/src/constants/editApp.ts index 238f68b741f..6cf0e2a1915 100644 --- a/frontend/providers/applaunchpad/src/constants/editApp.ts +++ b/frontend/providers/applaunchpad/src/constants/editApp.ts @@ -60,6 +60,7 @@ export const defaultEditVal: AppEditType = { }, storeList: [], volumes: [], + volumeMounts: [], gpu: { manufacturers: 'nvidia', type: '', diff --git a/frontend/providers/applaunchpad/src/mock/apps.ts b/frontend/providers/applaunchpad/src/mock/apps.ts index e9f23ef9bd4..af76efe453a 100644 --- a/frontend/providers/applaunchpad/src/mock/apps.ts +++ b/frontend/providers/applaunchpad/src/mock/apps.ts @@ -240,6 +240,7 @@ export const MOCK_PODS: PodDetailType[] = [ export const MOCK_APP_DETAIL: AppDetailType = { kind: 'deployment', volumes: [], + volumeMounts: [], crYamlList: [], id: '4bd50c41-149e-4da5-89d5-0308b9dd75c6', createTime: '2022/1/22', diff --git a/frontend/providers/applaunchpad/src/types/app.d.ts b/frontend/providers/applaunchpad/src/types/app.d.ts index 01b862b69ef..cbdd42666ca 100644 --- a/frontend/providers/applaunchpad/src/types/app.d.ts +++ b/frontend/providers/applaunchpad/src/types/app.d.ts @@ -10,7 +10,8 @@ import type { V1Pod, SinglePodMetrics, V1StatefulSet, - V1Volume + V1Volume, + V1VolumeMount } from '@kubernetes/client-node'; import { MonitorDataResult } from './monitor'; @@ -110,6 +111,7 @@ export interface AppEditType { }[]; labels: { [key: string]: string }; volumes: V1Volume[]; + volumeMounts: V1VolumeMount[]; kind: 'deployment' | 'statefulset'; } diff --git a/frontend/providers/applaunchpad/src/utils/adapt.ts b/frontend/providers/applaunchpad/src/utils/adapt.ts index ba3e3001f19..8de20127fa6 100644 --- a/frontend/providers/applaunchpad/src/utils/adapt.ts +++ b/frontend/providers/applaunchpad/src/utils/adapt.ts @@ -250,6 +250,19 @@ export const adaptAppDetail = async (configs: DeployKindsType[]): Promise { + const volumeMounts = appDeploy?.spec?.template?.spec?.containers?.[0]?.volumeMounts || []; + const configMapKeys = Object.keys(deployKindsMap.ConfigMap?.data || {}); + const storeNames = + deployKindsMap.StatefulSet?.spec?.volumeClaimTemplates?.map( + (template) => template.metadata?.name + ) || []; + + return volumeMounts.filter( + (mount) => !configMapKeys.includes(mount.name) && !storeNames.includes(mount.name) + ); + }; + return { labels: appDeploy?.metadata?.labels || {}, crYamlList: configs, @@ -373,6 +386,7 @@ export const adaptAppDetail = async (configs: DeployKindsType[]): Promise !volume.configMap) || [], kind: appDeploy?.kind?.toLowerCase() as 'deployment' | 'statefulset', @@ -398,7 +412,8 @@ export const adaptEditAppData = (app: AppDetailType): AppEditType => { 'gpu', 'labels', 'kind', - 'volumes' + 'volumes', + 'volumeMounts' ]; const res: Record = {}; diff --git a/frontend/providers/applaunchpad/src/utils/deployYaml2Json.ts b/frontend/providers/applaunchpad/src/utils/deployYaml2Json.ts index 2e244d0de8a..497ac2bc578 100644 --- a/frontend/providers/applaunchpad/src/utils/deployYaml2Json.ts +++ b/frontend/providers/applaunchpad/src/utils/deployYaml2Json.ts @@ -169,7 +169,7 @@ export const json2DeployCr = (data: AppEditType, type: 'deployment' | 'statefuls containers: [ { ...commonContainer, - volumeMounts: [...configMapVolumeMounts] + volumeMounts: [...(data?.volumeMounts || []), ...configMapVolumeMounts] } ], ...gpuMap, @@ -202,6 +202,7 @@ export const json2DeployCr = (data: AppEditType, type: 'deployment' | 'statefuls { ...commonContainer, volumeMounts: [ + ...(data?.volumeMounts || []), ...configMapVolumeMounts, ...data.storeList.map((item) => ({ name: item.name,