Skip to content

Commit

Permalink
fix: log out after context timeout
Browse files Browse the repository at this point in the history
Still try to output the logs when the error which triggered is due
to context timeout so that the user has a better chance to debug the
issue.
  • Loading branch information
stevenh committed Jul 14, 2024
1 parent 53b0ddf commit 2a36987
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,15 @@ func (c *DockerContainer) applyLifecycleHooks(ctx context.Context, logError bool

if err := errors.Join(errs...); err != nil {
if logError {
c.printLogs(ctx, err)
select {
case <-ctx.Done():
// Context has timed out so need a new context to get logs.
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
c.printLogs(ctx, err)
default:
c.printLogs(ctx, err)
}
}

return err
Expand Down

0 comments on commit 2a36987

Please sign in to comment.