From 7dd660aa3232cc21bdd6026a48fd78a754c438c7 Mon Sep 17 00:00:00 2001 From: Andrei Stan Date: Tue, 7 May 2024 20:04:32 +0300 Subject: [PATCH] fix(logs): Tail logs from already exited unikernel In the case of Xen, on fast applications, the logs would have been called when the machine was already in the exit state. Signed-off-by: Andrei Stan --- internal/cli/kraft/logs/logs.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/cli/kraft/logs/logs.go b/internal/cli/kraft/logs/logs.go index 17bf6d296..c731eeee1 100644 --- a/internal/cli/kraft/logs/logs.go +++ b/internal/cli/kraft/logs/logs.go @@ -167,7 +167,9 @@ func (opts *LogOptions) Run(ctx context.Context, args []string) error { if err != nil { errGroup = append(errGroup, err) } - if opts.Follow && machine.Status.State == machineapi.MachineStateRunning { + + // Sometimes the kernel can boot and exit faster than we can start tailing the logs + if opts.Follow && (machine.Status.State == machineapi.MachineStateRunning || machine.Status.State == machineapi.MachineStateExited) { observations.Add(machine) go func(machine *machineapi.Machine) { defer func() {