fix: Fix the problem of snapshot timeout (#8555)

This commit is contained in:
ssongliu 2025-05-06 18:35:36 +08:00 committed by GitHub
parent 3c81aced62
commit 74708dfa7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View file

@ -370,7 +370,7 @@ func snapAppImage(snap snapHelper, req dto.SnapshotCreate, targetDir string) err
snap.Task.Log(strings.Join(imageList, " "))
if len(imageList) != 0 {
snap.Task.Logf("docker save %s | gzip -c > %s", strings.Join(imageList, " "), path.Join(targetDir, "images.tar.gz"))
std, err := cmd.RunDefaultWithStdoutBashCf("docker save %s | gzip -c > %s", strings.Join(imageList, " "), path.Join(targetDir, "images.tar.gz"))
std, err := cmd.NewCommandMgr(cmd.WithTimeout(10*time.Minute)).RunWithStdoutBashCf("docker save %s | gzip -c > %s", strings.Join(imageList, " "), path.Join(targetDir, "images.tar.gz"))
if err != nil {
snap.Task.LogFailedWithErr(i18n.GetMsgByKey("SnapDockerSave"), errors.New(std))
return errors.New(std)

View file

@ -6,6 +6,7 @@ import (
"os"
"path"
"strings"
"time"
"github.com/1Panel-dev/1Panel/agent/app/repo"
@ -314,7 +315,7 @@ func recoverAppData(src string, itemHelper *snapRecoverHelper) error {
itemHelper.Task.Log(i18n.GetMsgByKey("RecoverAppEmpty"))
return nil
}
std, err := cmd.RunDefaultWithStdoutBashCf("docker load < %s", path.Join(src, "images.tar.gz"))
std, err := cmd.NewCommandMgr(cmd.WithTimeout(10*time.Minute)).RunWithStdoutBashCf("docker load < %s", path.Join(src, "images.tar.gz"))
if err != nil {
itemHelper.Task.LogFailedWithErr(i18n.GetMsgByKey("RecoverAppImage"), errors.New(std))
return fmt.Errorf("docker load images failed, err: %v", err)