Skip to content

Commit

Permalink
pkg/machine/e2e: improve timeout handling
Browse files Browse the repository at this point in the history
In case of timeouts actually log the command again and make sure to send
SIGABRT to the process as go will create a useful stack strace where we
can see where things are hanging. It also kill the process unlike the
default Eventually().Should(Exit()) call the leaves the process around.

The output will be captured by default in the log so we just see the
stack trace there.

And while at it bump the timout up to 10 mins, we are hitting hard
flakes in CI where machine init takes longer than 5 mins for unknown
reasons but this seems to be good enough.

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Luap99 committed Jul 5, 2024
1 parent cf98506 commit ada4e1a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/machine/e2e/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"slices"
"strconv"
"strings"
"syscall"
"time"

"github.com/containers/podman/v5/pkg/machine"
Expand All @@ -24,7 +25,7 @@ import (
var originalHomeDir = os.Getenv("HOME")

const (
defaultTimeout = 240 * time.Second
defaultTimeout = 10 * time.Minute
)

type machineCommand interface {
Expand Down Expand Up @@ -53,7 +54,16 @@ type machineTestBuilder struct {
// waitWithTimeout waits for a command to complete for a given
// number of seconds
func (ms *machineSession) waitWithTimeout(timeout time.Duration) {
Eventually(ms, timeout).Should(Exit())
Eventually(ms, timeout).Should(Exit(), func() string {
// Note eventually does not kill the command as such the command is leaked forever without killing it
// Also let's use SIGABRT to create a go stack trace so in case there is a deadlock we see it.
ms.Signal(syscall.SIGABRT)
// Give some time to let the command print the output so it is not printed much later
// in the log at the wrong place.
time.Sleep(1 * time.Second)
return fmt.Sprintf("command timed out after %fs: %v",
timeout.Seconds(), ms.Command.Args)
})
}

func (ms *machineSession) Bytes() []byte {
Expand Down

0 comments on commit ada4e1a

Please sign in to comment.