From 2185c3d2e099c8bea96d6e2a54a9c134ff247487 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:02:22 +0800 Subject: [PATCH] feat(appstore): Handle container restarting status for App (#7676) --- agent/app/service/app.go | 3 +++ agent/app/service/app_utils.go | 5 +++++ agent/constant/app.go | 1 + agent/i18n/lang/en.yaml | 1 + agent/i18n/lang/zh-Hant.yaml | 1 + agent/i18n/lang/zh.yaml | 1 + frontend/src/components/log-file/index.vue | 2 ++ frontend/src/components/task-log/index.vue | 1 + frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + 11 files changed, 18 insertions(+) diff --git a/agent/app/service/app.go b/agent/app/service/app.go index 6863c6cb4..ca83dac05 100644 --- a/agent/app/service/app.go +++ b/agent/app/service/app.go @@ -518,6 +518,9 @@ func (a AppService) Install(req request.AppInstallCreate) (appInstall *model.App if taskErr := installTask.Execute(); taskErr != nil { appInstall.Status = constant.InstallErr appInstall.Message = taskErr.Error() + if strings.Contains(taskErr.Error(), "Timeout") && strings.Contains(taskErr.Error(), "Pulling") { + appInstall.Message = buserr.New("PullImageTimeout").Error() + appInstall.Message + } _ = appInstallRepo.Save(context.Background(), appInstall) } }() diff --git a/agent/app/service/app_utils.go b/agent/app/service/app_utils.go index 8d5fdac90..ea45df3f1 100644 --- a/agent/app/service/app_utils.go +++ b/agent/app/service/app_utils.go @@ -1338,6 +1338,7 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI exitedCount := 0 pausedCount := 0 runningCount := 0 + restartingCount := 0 total := len(containerNames) for _, name := range containerNames { if con, ok := containers["/"+name]; ok { @@ -1347,6 +1348,8 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI exitNames = append(exitNames, name) case "running": runningCount++ + case "restarting": + restartingCount++ case "paused": pausedCount++ } @@ -1362,6 +1365,8 @@ func synAppInstall(containers map[string]types.Container, appInstall *model.AppI if oldStatus == constant.Running { return } + case restartingCount == total: + appInstall.Status = constant.Restating case pausedCount == total: appInstall.Status = constant.Paused case len(notFoundNames) == total: diff --git a/agent/constant/app.go b/agent/constant/app.go index 5130ec2ee..cec71937b 100644 --- a/agent/constant/app.go +++ b/agent/constant/app.go @@ -16,6 +16,7 @@ const ( UpErr = "UpErr" InstallErr = "InstallErr" Uninstalling = "Uninstalling" + Restating = "Restarting" ContainerPrefix = "1Panel-" diff --git a/agent/i18n/lang/en.yaml b/agent/i18n/lang/en.yaml index acf63c7e1..231624453 100644 --- a/agent/i18n/lang/en.yaml +++ b/agent/i18n/lang/en.yaml @@ -74,6 +74,7 @@ DeleteRuntimePHP: "Delete PHP runtime environment", CustomAppStoreNotConfig: "Please configure the offline package address in the app store settings", CustomAppStoreNotFound: "Failed to retrieve app store package, please check if it exists", CustomAppStoreFileValid: "App store package must be in .tar.gz format" +PullImageTimeout: "Image pull timeout, please check the network and try again" #file diff --git a/agent/i18n/lang/zh-Hant.yaml b/agent/i18n/lang/zh-Hant.yaml index 4c352cd97..aa9db0843 100644 --- a/agent/i18n/lang/zh-Hant.yaml +++ b/agent/i18n/lang/zh-Hant.yaml @@ -75,6 +75,7 @@ DeleteRuntimePHP: "刪除運行環境 PHP 版本", CustomAppStoreNotConfig: "請在應用商店設置離線包地址", CustomAppStoreNotFound: "應用商店包獲取失敗,請檢查是否存在", CustomAppStoreFileValid: "應用商店包需要 .tar.gz 格式" +PullImageTimeout: "拉取鏡像超時,請嘗試增加鏡像加速或更換其他鏡像加速" #file diff --git a/agent/i18n/lang/zh.yaml b/agent/i18n/lang/zh.yaml index afd85ae2d..3776a5764 100644 --- a/agent/i18n/lang/zh.yaml +++ b/agent/i18n/lang/zh.yaml @@ -74,6 +74,7 @@ DeleteRuntimePHP: "删除 PHP 运行环境" CustomAppStoreNotConfig: "请在应用商店设置离线包地址" CustomAppStoreNotFound: "应用商店包获取失败,请检查是否存在" CustomAppStoreFileValid: "应用商店包需要 .tar.gz 格式" +PullImageTimeout: "拉取镜像超时,请尝试增加镜像加速或者更换其他镜像加速" #file ErrFileCanNotRead: "此文件不支持预览" diff --git a/frontend/src/components/log-file/index.vue b/frontend/src/components/log-file/index.vue index 315d09a5c..2c40c6210 100644 --- a/frontend/src/components/log-file/index.vue +++ b/frontend/src/components/log-file/index.vue @@ -35,6 +35,7 @@ import { nextTick, onMounted, onUnmounted, reactive, ref } from 'vue'; import { downloadFile } from '@/utils/util'; import { ReadByLine } from '@/api/modules/files'; import { GlobalStore } from '@/store'; +import bus from '@/global/bus'; const globalStore = GlobalStore(); interface LogProps { @@ -272,6 +273,7 @@ const onCloseLog = async () => { timer = null; isLoading.value = false; emit('update:isReading', false); + bus.emit('refreshTask', true); }; watch( diff --git a/frontend/src/components/task-log/index.vue b/frontend/src/components/task-log/index.vue index c0e08e35a..d8f2af0fd 100644 --- a/frontend/src/components/task-log/index.vue +++ b/frontend/src/components/task-log/index.vue @@ -63,6 +63,7 @@ const openWithResourceID = (taskType: string, taskOperate: string, resourceID: n const handleClose = () => { open.value = false; + bus.emit('refreshTask', true); }; defineExpose({ openWithResourceID, openWithTaskID }); diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 58b9cc17f..d4e0e7c15 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -303,6 +303,7 @@ const message = { healthy: 'Normal', executing: 'Executing', installerr: 'Install Error', + restating: 'Restarting', }, units: { second: 'Second', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 2fc8ea6ee..4ef225a74 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -298,6 +298,7 @@ const message = { healthy: '正常', executing: '執行中', installerr: '安裝失敗', + restating: '重啟中', }, units: { second: '秒', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 53d83ae09..69dae5e30 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -298,6 +298,7 @@ const message = { healthy: '正常', executing: '执行中', installerr: '安装失败', + restating: '重启中', }, units: { second: '秒',