diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 593e76e38..9fe09a0d0 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -576,8 +576,14 @@ func upApp(appInstall *model.AppInstall) { if err != nil { return err } + err = composeService.ComposePull() + if err != nil { + appInstall.Status = constant.PullErr + return err + } err = composeService.ComposeUp() if err != nil { + appInstall.Status = constant.Error return err } return @@ -586,8 +592,14 @@ func upApp(appInstall *model.AppInstall) { } } if err := upProject(appInstall); err != nil { - appInstall.Status = constant.Error - appInstall.Message = err.Error() + otherMsg := "" + if strings.Contains(err.Error(), "no such host") { + otherMsg = i18n.GetMsgByKey("ErrNoSuchHost") + ":" + } + if strings.Contains(err.Error(), "timeout") { + otherMsg = i18n.GetMsgByKey("ErrImagePullTimeOut") + ":" + } + appInstall.Message = otherMsg + err.Error() } else { appInstall.Status = constant.Running } @@ -751,7 +763,7 @@ func handleErr(install model.AppInstall, err error, out string) error { func handleInstalled(appInstallList []model.AppInstall, updated bool) ([]response.AppInstalledDTO, error) { var res []response.AppInstalledDTO for _, installed := range appInstallList { - if updated && installed.App.Type == "php" || installed.Status == constant.Installing { + if updated && (installed.App.Type == "php" || installed.Status == constant.Installing) { continue } installDTO := response.AppInstalledDTO{ diff --git a/backend/constant/app.go b/backend/constant/app.go index 93be575a2..bc5b91ccc 100644 --- a/backend/constant/app.go +++ b/backend/constant/app.go @@ -11,6 +11,7 @@ const ( DirNotFound = "DirNotFound" Upgrading = "Upgrading" UpgradeErr = "UpgradeErr" + PullErr = "PullErr" ContainerPrefix = "1Panel-" diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index e6b45a5d1..ea97ca35c 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -40,6 +40,7 @@ ErrHttpReqTimeOut: "Request timed out {{.err}}" ErrHttpReqFailed: "Request failed {{.err}}" ErrHttpReqNotFound: "The file does not exist" ErrNoSuchHost: "Network connection failed" +ErrImagePullTimeOut: 'Image pull timeout' #file ErrFileCanNotRead: "File can not read" diff --git a/backend/i18n/lang/zh-Hant.yaml b/backend/i18n/lang/zh-Hant.yaml index 1a8a57889..09c95cd3f 100644 --- a/backend/i18n/lang/zh-Hant.yaml +++ b/backend/i18n/lang/zh-Hant.yaml @@ -40,6 +40,7 @@ ErrHttpReqTimeOut: "請求超時 {{.err}}" ErrHttpReqFailed: "請求失敗 {{.err}}" ErrHttpReqNotFound: "文件不存在" ErrNoSuchHost: "網路連接失敗" +ErrImagePullTimeOut: "鏡像拉取超時" #file ErrFileCanNotRead: "此文件不支持預覽" diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index 00e785bb6..62e682b74 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -40,6 +40,7 @@ ErrHttpReqTimeOut: "请求超时 {{.err}}" ErrHttpReqFailed: "请求失败 {{.err}}" ErrHttpReqNotFound: "文件不存在" ErrNoSuchHost: "网络连接失败" +ErrImagePullTimeOut: '镜像拉取超时' #file ErrFileCanNotRead: "此文件不支持预览" diff --git a/backend/utils/docker/compose.go b/backend/utils/docker/compose.go index fea310e56..730df21c1 100644 --- a/backend/utils/docker/compose.go +++ b/backend/utils/docker/compose.go @@ -89,6 +89,10 @@ func (s *ComposeService) ComposeBuild() error { return s.Build(context.Background(), s.project, api.BuildOptions{}) } +func (s *ComposeService) ComposePull() error { + return s.Pull(context.Background(), s.project, api.PullOptions{}) +} + func GetComposeProject(projectName, workDir string, yml []byte, env []byte, skipNormalization bool) (*types.Project, error) { var configFiles []types.ConfigFile configFiles = append(configFiles, types.ConfigFile{ diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 7d5b1b238..9a45d07e6 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -209,6 +209,7 @@ const message = { downloaderr: 'Download Error', upgrading: 'Upgrading', upgradeerr: 'Upgrade Error', + pullerr: 'Pull Image Error', }, units: { second: 'Second', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 9b50dc444..e01073129 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -208,6 +208,7 @@ const message = { downloaderr: '下載失敗', upgrading: '升級中', upgradeerr: '升級失敗', + pullerr: '鏡像拉取失敗', }, units: { second: '秒', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index e6074641a..34a2cabf9 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -208,6 +208,7 @@ const message = { downloaderr: '下载失败', upgrading: '升级中', upgradeerr: '升级失败', + pullerr: '镜像拉取失败', }, units: { second: '秒', diff --git a/frontend/src/views/app-store/detail/params/index.vue b/frontend/src/views/app-store/detail/params/index.vue index 3cc7aa2c3..972271ee0 100644 --- a/frontend/src/views/app-store/detail/params/index.vue +++ b/frontend/src/views/app-store/detail/params/index.vue @@ -175,7 +175,7 @@ const handleParams = () => { if (p.type === 'service' || p.type === 'apps') { rules[p.envKey] = [Rules.requiredSelect]; if (p.child) { - p.childProp = p.child.envKey; + p.childProp = propStart.value + p.child.envKey; if (p.child.type === 'service') { rules[p.child.envKey] = [Rules.requiredSelect]; }