loop: let config turn a nudge rule off
The kuma service_down nudge cannot name the service. mavpoll folds the whole monitor_status gauge into one boolean fact keyed `service_down`, and the phraser names a service only when the fact key is the service name, so the message is always the generic "a service on homesrv is down". Every fifteen minutes, with nothing to act on. A fact per monitor is the real fix and it is filed as Vikunja #444; this is what to do until then. `disabled_rules` in mavend.json subtracts from loop.DefaultRules by name. Config only subtracts — rules stay code, the set stays canonical and ordered as written. A disabled rule is not gathered for either, since the gatherer derives its key set from the rules it was given. Unknown names are ignored so deleting a rule cannot brick a config that still lists it, and the boot log says what was dropped, because a rule that vanishes silently looks exactly like a rule that is broken. Deploy turns service_down off. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TrVSBKe3RFDF4fGYKWYQnX
This commit is contained in:
+14
-2
@@ -236,7 +236,7 @@ func run(args []string) error {
|
||||
coreFor := func() ipc.CoreAPI { return newIntakeAPI(ipc.NewStoreAPI(st), evBus, time.Now) }
|
||||
|
||||
if !locked {
|
||||
rules = loop.DefaultRules()
|
||||
rules = wireRules(cfg)
|
||||
gatherer = loop.NewGatherer(st, rules)
|
||||
if cfg.QuietHours != nil {
|
||||
gatherer.SetQuietHours(cfg.QuietHours.Start, cfg.QuietHours.End)
|
||||
@@ -508,7 +508,7 @@ func run(args []string) error {
|
||||
}
|
||||
|
||||
// Wire everything.
|
||||
rules = loop.DefaultRules()
|
||||
rules = wireRules(cfg)
|
||||
gatherer = loop.NewGatherer(st, rules)
|
||||
if cfg.QuietHours != nil {
|
||||
gatherer.SetQuietHours(cfg.QuietHours.Start, cfg.QuietHours.End)
|
||||
@@ -810,3 +810,15 @@ func waitWorkers(wg *sync.WaitGroup, d time.Duration) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// wireRules builds the nudge rule set, minus anything config turned off. The
|
||||
// drop is logged because a rule vanishing silently is indistinguishable from a
|
||||
// rule that is broken, and the next person to wonder why she stopped nudging
|
||||
// should find the answer in the boot log.
|
||||
func wireRules(cfg *config.Config) []loop.Rule {
|
||||
rules, dropped := loop.RulesExcept(cfg.DisabledRules)
|
||||
for _, name := range dropped {
|
||||
log.Printf("loop: rule %q disabled by config", name)
|
||||
}
|
||||
return rules
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user