Skip to content

Commit

Permalink
diskmetrics: set exec timeout explicitly
Browse files Browse the repository at this point in the history
for command executions that run in separate worker thread:
set timeout to 1000 seconds (as it was before)

for direct command executions:
set timeout to 400 seconds in order to not trigger the watchdog
and therefore a reboot

Signed-off-by: Christoph Ostarek <christoph@zededa.com>

Backported to 9.4-stable

Signed-off-by: Renê de Souza Pinto <rene@renesp.com.br>
  • Loading branch information
christoph-zededa authored and eriknordmark committed Nov 17, 2023
1 parent a1c6236 commit e0331df
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/pillar/diskmetrics/diskmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ 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).CombinedOutput()
diskfile).WithUnlimitedTimeout(qemuExecLongTimeout).CombinedOutput()
if err != nil {
errStr := fmt.Sprintf("qemu-img failed: %s, %s\n",
err, output)
Expand Down Expand Up @@ -64,7 +69,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).CombinedOutput()
strconv.FormatUint(newsize, 10)).WithContext(ctx).WithUnlimitedTimeout(qemuExecLongTimeout).CombinedOutput()
if err != nil {
errStr := fmt.Sprintf("qemu-img failed: %s, %s\n",
err, output)
Expand All @@ -76,7 +81,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).CombinedOutput()
strconv.FormatUint(size, 10)).WithContext(ctx).WithUnlimitedTimeout(qemuExecLongTimeout).CombinedOutput()
if err != nil {
errStr := fmt.Sprintf("qemu-img failed: %s, %s\n",
err, output)
Expand All @@ -93,7 +98,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(15 * time.Minute).CombinedOutput()
output, err := base.Exec(log, "/usr/bin/qemu-img", args...).WithContext(ctx).WithUnlimitedTimeout(qemuExecLongTimeout).CombinedOutput()
if err != nil {
errStr := fmt.Sprintf("qemu-img failed: %s, %s\n",
err, output)
Expand Down

0 comments on commit e0331df

Please sign in to comment.