Count a unit as found only when the machine runs it or starts it at boot, so a packaged unit nothing ran is not held (hq ADR 0103, found by the adoption bed)

This commit is contained in:
2026-09-22 18:47:48 +02:00
parent bde5e3461c
commit 60bb3d895c
2 changed files with 33 additions and 4 deletions
+10 -3
View File
@@ -95,9 +95,16 @@ func lookBefore(ctx context.Context, sys system.System, d *declaration.Declarati
if known.Recorded(string(declaration.TypeService), res.Unit) {
continue
}
// A unit the service manager cannot find is not there; one it can read is, whatever
// state it is in.
if _, err := sys.ServiceState(ctx, run, res.Unit); err == nil {
// Found is what the machine runs: a unit that is running or starts at boot. A unit
// file a package merely ships — a template instance nothing ever started, say the
// private network's own wg-quick@mesh0 — is not a predecessor's service, and holding
// it kept the private network from ever coming up (found by the adoption bed).
state, err := sys.ServiceState(ctx, run, res.Unit)
if err != nil {
continue
}
boot, _ := sys.ServiceBoot(ctx, run, res.Unit)
if state == "running" || boot == "enabled" {
seen["unit:"+res.Unit] = true
}
case *declaration.Container: