diff --git a/internal/agent/recover.go b/internal/agent/recover.go index f7d08d8..d87fafa 100644 --- a/internal/agent/recover.go +++ b/internal/agent/recover.go @@ -21,15 +21,20 @@ func (a *Agent) Recover(ctx context.Context) error { return fmt.Errorf("list services: %w", err) } - // Get the list of currently running containers from podman. - running, err := a.listAllContainers(ctx) + // Get the list of containers across runtimes. Only those actually in the + // "running" state count as up — a stopped/exited container or a dead + // unikernel VM (whose state dir still exists, so it is listed) must be + // recovered, not skipped. + listed, err := a.listAllContainers(ctx) if err != nil { a.Logger.Warn("cannot list containers, assuming none running", "err", err) - running = nil + listed = nil } runningSet := make(map[string]bool) - for _, c := range running { - runningSet[c.Name] = true + for _, c := range listed { + if c.State == "running" { + runningSet[c.Name] = true + } } var recovered, skipped, already int