mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
feat: 优化应用升级逻辑,避免镜像拉取成功之前容器被删除 (#5525)
This commit is contained in:
parent
ee0aa532d7
commit
f2350d0a65
@ -14,6 +14,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
|
||||||
@ -610,17 +611,13 @@ func upgradeInstall(req request.AppInstallUpgrade) error {
|
|||||||
upErr = err
|
upErr = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dockerCli, err := composeV2.NewClient()
|
|
||||||
if err != nil {
|
|
||||||
upErr = err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer dockerCli.Close()
|
|
||||||
for _, image := range images {
|
for _, image := range images {
|
||||||
global.LOG.Infof(i18n.GetMsgWithName("PullImageStart", image, nil))
|
global.LOG.Infof(i18n.GetMsgWithName("PullImageStart", image, nil))
|
||||||
if err = dockerCli.PullImage(image, true); err != nil {
|
if out, err := cmd.ExecWithTimeOut("docker pull "+image, 20*time.Minute); err != nil {
|
||||||
|
if out != "" {
|
||||||
|
err = errors.New(out)
|
||||||
|
}
|
||||||
upErr = buserr.WithNameAndErr("ErrDockerPullImage", "", err)
|
upErr = buserr.WithNameAndErr("ErrDockerPullImage", "", err)
|
||||||
return
|
|
||||||
} else {
|
} else {
|
||||||
global.LOG.Infof(i18n.GetMsgByKey("PullImageSuccess"))
|
global.LOG.Infof(i18n.GetMsgByKey("PullImageSuccess"))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user