From 026c749b5e7655754173b1f4fb253358dc1133f2 Mon Sep 17 00:00:00 2001 From: Roman Penyaev Date: Mon, 9 Oct 2023 11:25:39 +0200 Subject: [PATCH] Revert "diskmetrics: set exec timeout explicitly" This reverts commit 0bfcabcf5f33bdefa68f18db7ea07861b35daf6c. --- pkg/pillar/diskmetrics/diskmetrics.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/pkg/pillar/diskmetrics/diskmetrics.go b/pkg/pillar/diskmetrics/diskmetrics.go index b9164ef3f33..a31722101c4 100644 --- a/pkg/pillar/diskmetrics/diskmetrics.go +++ b/pkg/pillar/diskmetrics/diskmetrics.go @@ -17,11 +17,6 @@ import ( "github.com/lf-edge/eve/pkg/pillar/types" ) -const qemuExecTimeout = 2 * time.Minute - -// qemuExecLongTimeout is a long timeout for command executions in separate worker thread that don't interfere with the watchdog -const qemuExecLongTimeout = 1000 * time.Second - func GetImgInfo(log *base.LogObject, diskfile string) (*types.ImgInfo, error) { var imgInfo types.ImgInfo @@ -29,7 +24,7 @@ func GetImgInfo(log *base.LogObject, diskfile string) (*types.ImgInfo, error) { return nil, err } output, err := base.Exec(log, "/usr/bin/qemu-img", "info", "-U", "--output=json", - diskfile).WithUnlimitedTimeout(qemuExecLongTimeout).CombinedOutput() + diskfile).CombinedOutput() if err != nil { errStr := fmt.Sprintf("qemu-img failed: %s, %s\n", err, output) @@ -70,7 +65,7 @@ func ResizeImg(ctx context.Context, log *base.LogObject, diskfile string, newsiz return err } output, err := base.Exec(log, "/usr/bin/qemu-img", "resize", diskfile, - strconv.FormatUint(newsize, 10)).WithContext(ctx).WithUnlimitedTimeout(qemuExecLongTimeout).CombinedOutput() + strconv.FormatUint(newsize, 10)).WithContext(ctx).CombinedOutput() if err != nil { errStr := fmt.Sprintf("qemu-img failed: %s, %s\n", err, output) @@ -82,7 +77,7 @@ func ResizeImg(ctx context.Context, log *base.LogObject, diskfile string, newsiz // CreateImg creates empty diskfile with defined format and size func CreateImg(ctx context.Context, log *base.LogObject, diskfile string, format string, size uint64) error { output, err := base.Exec(log, "/usr/bin/qemu-img", "create", "-f", format, diskfile, - strconv.FormatUint(size, 10)).WithContext(ctx).WithUnlimitedTimeout(qemuExecLongTimeout).CombinedOutput() + strconv.FormatUint(size, 10)).WithContext(ctx).CombinedOutput() if err != nil { errStr := fmt.Sprintf("qemu-img failed: %s, %s\n", err, output) @@ -99,7 +94,7 @@ func RolloutImgToBlock(ctx context.Context, log *base.LogObject, diskfile, outpu // writeback cache instead of default unsafe, out of order enabled, skip file creation // Timeout 2 hours args := []string{"convert", "--target-is-zero", "-t", "writeback", "-W", "-n", "-O", outputFormat, diskfile, outputFile} - output, err := base.Exec(log, "/usr/bin/qemu-img", args...).WithContext(ctx).WithUnlimitedTimeout(qemuExecLongTimeout).CombinedOutput() + output, err := base.Exec(log, "/usr/bin/qemu-img", args...).WithContext(ctx).WithUnlimitedTimeout(15 * time.Minute).CombinedOutput() if err != nil { errStr := fmt.Sprintf("qemu-img failed: %s, %s\n", err, output) @@ -118,7 +113,7 @@ func CreateSnapshot(ctx context.Context, log *base.LogObject, diskfile, snapshot cmdBin := "/usr/bin/qemu-img" cmdArgs := []string{"snapshot", "-c", snapshotName, diskfile} log.Noticef("CreateSnapshot: %s %s", cmdBin, strings.Join(cmdArgs, " ")) - output, err := base.Exec(log, cmdBin, cmdArgs...).WithContext(ctx).WithLimitedTimeout(qemuExecTimeout).CombinedOutput() + output, err := base.Exec(log, cmdBin, cmdArgs...).WithContext(ctx).CombinedOutput() if err != nil { errStr := fmt.Sprintf("qemu-img failed: %s, %s\n", err, output) return errors.New(errStr) @@ -136,7 +131,7 @@ func ApplySnapshot(ctx context.Context, log *base.LogObject, diskfile, snapshotN cmdBin := "/usr/bin/qemu-img" cmdArgs := []string{"snapshot", "-a", snapshotName, diskfile} log.Noticef("ApplySnapshot: %s %s", cmdBin, strings.Join(cmdArgs, " ")) - output, err := base.Exec(log, cmdBin, cmdArgs...).WithContext(ctx).WithLimitedTimeout(qemuExecTimeout).CombinedOutput() + output, err := base.Exec(log, cmdBin, cmdArgs...).WithContext(ctx).CombinedOutput() if err != nil { errStr := fmt.Sprintf("qemu-img failed: %s, %s\n", err, output) return errors.New(errStr) @@ -151,7 +146,7 @@ func DeleteSnapshot(ctx context.Context, log *base.LogObject, diskfile, snapshot cmdBin := "/usr/bin/qemu-img" cmdArgs := []string{"snapshot", "-d", snapshotName, diskfile} log.Noticef("DeleteSnapshot: %s %s", cmdBin, strings.Join(cmdArgs, " ")) - output, err := base.Exec(log, cmdBin, cmdArgs...).WithContext(ctx).WithLimitedTimeout(qemuExecTimeout).CombinedOutput() + output, err := base.Exec(log, cmdBin, cmdArgs...).WithContext(ctx).CombinedOutput() if err != nil { errStr := fmt.Sprintf("qemu-img failed: %s, %s\n", err, output) return errors.New(errStr)