Skip to content

Commit

Permalink
Revert "diskmetrics: set exec timeout explicitly"
Browse files Browse the repository at this point in the history
This reverts commit 0bfcabc.
  • Loading branch information
rouming committed Oct 9, 2023
1 parent 0bfcabc commit 026c749
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions pkg/pillar/diskmetrics/diskmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,14 @@ 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

if _, err := os.Stat(diskfile); err != nil {
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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 026c749

Please sign in to comment.