Skip to content

Commit

Permalink
feat: 优化应用升级逻辑,避免镜像拉取成功之前容器被删除
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 committed Jun 21, 2024
1 parent ee0aa53 commit e78594c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions backend/app/service/app_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"regexp"
"strconv"
"strings"
"time"

"github.com/docker/docker/api/types"

Expand Down Expand Up @@ -610,17 +611,13 @@ func upgradeInstall(req request.AppInstallUpgrade) error {
upErr = err
return
}
dockerCli, err := composeV2.NewClient()
if err != nil {
upErr = err
return
}
defer dockerCli.Close()
for _, image := range images {
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)
return
} else {
global.LOG.Infof(i18n.GetMsgByKey("PullImageSuccess"))
}
Expand Down

0 comments on commit e78594c

Please sign in to comment.