package main // A node whose packages are over the bus's cap is unhealthy, naming the size (novox/hq ADR 0507 ยง2, acceptance // 1840/AC3): `installed.` keeps its last value, which is no longer the node's, and the module's health says // so until the keeper writes it again and deletes the mark. import ( "encoding/json" "fmt" ) // InstalledHealth is the health of this node's `installed` key: unhealthy while `.not-current` is there, // with its size and since when; ok false when there is nothing to say (the key is current, or the state cannot // be read here, which the keeper's own log says). func (m *Machine) InstalledHealth() (Health, bool) { if m.States == nil || m.Node == "" { return Health{}, false } e, err := m.States(StateInstalled).Get(NotCurrentKey(m.Node)) if err != nil { return Health{Why: "the node's packages on the bus could not be read: " + err.Error()}, true } if e == nil { return Health{}, false } var nc NotCurrent if err := json.Unmarshal(e.Value, &nc); err != nil { return Health{Why: fmt.Sprintf("installed.%s is marked not current, and its mark is not readable: %v", m.Node, err)}, true } return Health{Why: fmt.Sprintf("the node's packages come to %d bytes, over the bus's cap of %d on a value, since %s: "+ "installed.%s keeps an older list", nc.Bytes, ValueCap, nc.Since.Format("2006-01-02 15:04 MST"), m.Node)}, true }