Skip to content

Commit

Permalink
testiso: improve error when QEMU is terminated
Browse files Browse the repository at this point in the history
Right now when QEMU gets killed during a testiso run, the error is:

    FAIL: pxe-offline-install (bios + metal) (1m10.277s)
        Got EOF from completion channel, coreos-installer-test-OK expected

This is accurate but doesn't hint well enough at the underlying cause.
Rework the two spots in which we wait for virtio-serial strings to also
check if QEMU was killed to provide a better error. E.g.:

    FAIL: pxe-install (bios + metal) (34.483s)
        QEMU unexpectedly exited while waiting awaiting completion: process killed

Related: coreos/fedora-coreos-tracker#1339
  • Loading branch information
jlebon committed Nov 11, 2022
1 parent 6402ac8 commit effac8e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mantle/cmd/kola/testiso.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,12 @@ func awaitCompletion(ctx context.Context, inst *platform.QemuInstance, outdir st
}
go func() {
err := inst.Wait()
// only one Wait() gets process data, so also manually check for signal
if err == nil && inst.Signaled() {
err = errors.New("process killed")
}
if err != nil {
errchan <- err
errchan <- errors.Wrapf(err, "QEMU unexpectedly exited while awaiting completion")
}
time.Sleep(1 * time.Minute)
errchan <- fmt.Errorf("QEMU exited; timed out waiting for completion")
Expand All @@ -549,6 +553,10 @@ func awaitCompletion(ctx context.Context, inst *platform.QemuInstance, outdir st
l, err := r.ReadString('\n')
if err != nil {
if err == io.EOF {
// this may be from QEMU getting killed or exiting; wait a bit
// to give a chance for .Wait() above to feed the channel with a
// better error
time.Sleep(1 * time.Second)
errchan <- fmt.Errorf("Got EOF from completion channel, %s expected", exp)
} else {
errchan <- errors.Wrapf(err, "reading from completion channel")
Expand Down
15 changes: 15 additions & 0 deletions mantle/platform/metal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"os"
"path/filepath"
"strings"
"time"

coreosarch "github.com/coreos/stream-metadata-go/arch"
"github.com/pkg/errors"
Expand Down Expand Up @@ -435,11 +436,25 @@ func (t *installerRun) completePxeSetup(kargs []string) error {

func switchBootOrderSignal(qinst *QemuInstance, bootstartedchan *os.File, booterrchan *chan error) {
*booterrchan = make(chan error)
go func() {
err := qinst.Wait()
// only one Wait() gets process data, so also manually check for signal
if err == nil && qinst.Signaled() {
err = errors.New("process killed")
}
if err != nil {
*booterrchan <- errors.Wrapf(err, "QEMU unexpectedly exited while waiting for %s", bootStartedSignal)
}
}()
go func() {
r := bufio.NewReader(bootstartedchan)
l, err := r.ReadString('\n')
if err != nil {
if err == io.EOF {
// this may be from QEMU getting killed or exiting; wait a bit
// to give a chance for .Wait() above to feed the channel with a
// better error
time.Sleep(1 * time.Second)
*booterrchan <- fmt.Errorf("Got EOF from boot started channel, %s expected", bootStartedSignal)
} else {
*booterrchan <- errors.Wrapf(err, "reading from boot started channel")
Expand Down

0 comments on commit effac8e

Please sign in to comment.