From d40f88784da2498e01991961ee2a283da443027e Mon Sep 17 00:00:00 2001 From: HUAHUAI23 Date: Sat, 20 Jul 2024 03:17:52 +0000 Subject: [PATCH] ok --- .../dedicated-database-task.service.ts | 20 ++++++++++++++-- .../AddDependenceModal/index.tsx | 24 +++++++++---------- .../functions/mods/DependencePanel/index.tsx | 12 +++++----- .../UseTemplate/UseTemplateModal.tsx | 18 ++++++++++---- 4 files changed, 50 insertions(+), 24 deletions(-) diff --git a/server/src/database/dedicated-database/dedicated-database-task.service.ts b/server/src/database/dedicated-database/dedicated-database-task.service.ts index b0b4b08..cbe59fd 100644 --- a/server/src/database/dedicated-database/dedicated-database-task.service.ts +++ b/server/src/database/dedicated-database/dedicated-database-task.service.ts @@ -76,7 +76,13 @@ export class DedicatedDatabaseTaskService { const waitingTime = Date.now() - data.updatedAt.getTime() if (!manifest || manifest.spec.componentSpecs[0].replicas === 0) { - await this.dbService.applyDeployManifest(region, user, appid) + try { + await this.dbService.applyDeployManifest(region, user, appid) + } catch (error) { + this.logger.error( + `apply dedicated database ${appid} yaml error:\n ${error.message}`, + ) + } await this.relock(appid, waitingTime) return } @@ -329,7 +335,17 @@ export class DedicatedDatabaseTaskService { await this.dbService.getKubeBlockOpsRequestManifest(region, user, appid) if (!OpsRequestManifest) { - await this.dbService.applyKubeBlockOpsRequestManifest(region, user, appid) + try { + await this.dbService.applyKubeBlockOpsRequestManifest( + region, + user, + appid, + ) + } catch (error) { + this.logger.error( + `apply dedicated database restart ${appid} yaml error:\n ${error.message}`, + ) + } await this.relock(appid, waitingTime) return } diff --git a/web/src/pages/app/functions/mods/DependencePanel/AddDependenceModal/index.tsx b/web/src/pages/app/functions/mods/DependencePanel/AddDependenceModal/index.tsx index cfbebbf..20a9d13 100644 --- a/web/src/pages/app/functions/mods/DependencePanel/AddDependenceModal/index.tsx +++ b/web/src/pages/app/functions/mods/DependencePanel/AddDependenceModal/index.tsx @@ -82,22 +82,22 @@ const AddDependenceModal = () => { const addPackageMutation = useAddPackageMutation(() => { onClose(); - globalStore.updateCurrentApp( - globalStore.currentApp!, - globalStore.currentApp!.state === APP_STATUS.Stopped - ? APP_STATUS.Running - : APP_STATUS.Restarting, - ); + if (globalStore.currentApp!.state === APP_STATUS.Stopped) { + globalStore.updateCurrentApp(globalStore.currentApp!, APP_STATUS.Running); + } + if (globalStore.currentApp.state === APP_STATUS.Running) { + globalStore.updateCurrentApp(globalStore.currentApp!, APP_STATUS.Restarting, true); + } }); const editPackageMutation = useEditPackageMutation(() => { onClose(); - globalStore.updateCurrentApp( - globalStore.currentApp!, - globalStore.currentApp!.state === APP_STATUS.Stopped - ? APP_STATUS.Running - : APP_STATUS.Restarting, - ); + if (globalStore.currentApp!.state === APP_STATUS.Stopped) { + globalStore.updateCurrentApp(globalStore.currentApp!, APP_STATUS.Running); + } + if (globalStore.currentApp.state === APP_STATUS.Running) { + globalStore.updateCurrentApp(globalStore.currentApp!, APP_STATUS.Restarting, true); + } }); const packageSearchQuery = usePackageSearchQuery(name, (data) => { diff --git a/web/src/pages/app/functions/mods/DependencePanel/index.tsx b/web/src/pages/app/functions/mods/DependencePanel/index.tsx index 3ff54de..038b3be 100644 --- a/web/src/pages/app/functions/mods/DependencePanel/index.tsx +++ b/web/src/pages/app/functions/mods/DependencePanel/index.tsx @@ -27,12 +27,12 @@ export default function DependenceList() { const globalStore = useGlobalStore((state: State) => state); const delPackageMutation = useDelPackageMutation(() => { - globalStore.updateCurrentApp( - globalStore.currentApp!, - globalStore.currentApp!.state === APP_STATUS.Stopped - ? APP_STATUS.Running - : APP_STATUS.Restarting, - ); + if (globalStore.currentApp!.state === APP_STATUS.Stopped) { + globalStore.updateCurrentApp(globalStore.currentApp!, APP_STATUS.Running); + } + if (globalStore.currentApp.state === APP_STATUS.Running) { + globalStore.updateCurrentApp(globalStore.currentApp!, APP_STATUS.Restarting, true); + } }); const { t } = useTranslation(); diff --git a/web/src/pages/functionTemplate/Mods/TemplateInfo/UseTemplate/UseTemplateModal.tsx b/web/src/pages/functionTemplate/Mods/TemplateInfo/UseTemplate/UseTemplateModal.tsx index 19fe0f4..24dbe4a 100644 --- a/web/src/pages/functionTemplate/Mods/TemplateInfo/UseTemplate/UseTemplateModal.tsx +++ b/web/src/pages/functionTemplate/Mods/TemplateInfo/UseTemplate/UseTemplateModal.tsx @@ -73,10 +73,20 @@ const UseTemplateModal = (props: { children: any; templateId: string; packageLis }); if (isAnyPackageNotInDependencyList && packageList.length > 0) { - updateAppStateMutation.mutate({ - appid: appItem.appid, - state: appItem.phase === APP_STATUS.Stopped ? APP_STATUS.Running : APP_STATUS.Restarting, - }); + if (appItem.phase === APP_STATUS.Stopped) { + updateAppStateMutation.mutate({ + appid: appItem.appid, + state: APP_STATUS.Running, + }); + } + + if (appItem.phase === APP_STATUS.Running) { + updateAppStateMutation.mutate({ + appid: appItem.appid, + state: APP_STATUS.Restarting, + onlyRuntimeFlag: true, + }); + } } if (!res.error) {