networkmanager: the watcher's health is its unit's state

The sign-in process is judged by its unit being active, on the machine without the bus,
and NetworkManager's service keeps no state and no health again. The watcher exits
non-zero when it cannot subscribe once the system bus came back, so its unit shows
failing; uplink_health stays a tool that reads and no longer gives the names again.

Builds: design 08 sign-in-page §11, §13, §14, §23, §24, §25, §27; lead answer C-2c (hq 6752a5cf)
This commit is contained in:
jochen
2026-11-24 21:53:29 +01:00
parent 55a90d963e
commit 397e627b02
9 changed files with 59 additions and 80 deletions
@@ -194,8 +194,7 @@ func watch([]string) error {
}
w := newWatcher(f)
go serveSocket(l, w.askLoop)
w.run(nil)
return nil
return w.run(nil)
}
// askLoop hands one ask of the socket to the loop and waits for its answer.
@@ -206,8 +205,10 @@ func (w *Watcher) askLoop(ask string) (any, error) {
return r.answer, r.err
}
// run is the watcher's loop, until stop closes: it subscribes, then acts on what it hears, one thing at a time.
func (w *Watcher) run(stop <-chan struct{}) {
// run is the watcher's loop, until stop closes: it subscribes, then acts on what it hears, one thing at a time. It ends
// with an error when it cannot subscribe again once the system bus's socket came back, so the process exits non-zero
// and its unit shows failing, the watcher's health (design 08 sign-in-page §11; lead answer C-2c).
func (w *Watcher) run(stop <-chan struct{}) error {
if w.asks == nil {
w.asks = make(chan asked)
}
@@ -223,7 +224,7 @@ func (w *Watcher) run(stop <-chan struct{}) {
select {
case <-stop:
w.unsubscribe()
return
return nil
case s, ok := <-w.signals:
if !ok {
journal("the system bus connection dropped; subscribing again when its socket is there")
@@ -239,6 +240,10 @@ func (w *Watcher) run(stop <-chan struct{}) {
case <-w.socketAt:
w.socketAt = nil
w.subscribe()
if !w.state.Subscribed {
w.unsubscribe()
return errors.New("the system bus came back and the watcher could not subscribe on it")
}
case p := <-made:
w.strange(p)
case end := <-w.ends: