Clear an old pass on a wait, and say a change of waits (review of #78)
A resource that passed, then waited, then failed once after its grace was still stated healthy from the old pass; and a change of what it waits for alone raised no change event, so the controller could miss it.
This commit is contained in:
@@ -368,7 +368,8 @@ func (j *Judge) Look(ctx context.Context) (Statement, bool) {
|
||||
seen[r.ID] = true
|
||||
st.Resources = append(st.Resources, State{Resource: k.Resource, State: k.State, Reason: k.Reason, Since: k.Since,
|
||||
Streak: k.Streak, Restarts: k.Counted, Waits: waitsOf(k)})
|
||||
word := k.State + "/" + k.Reason
|
||||
// What it waits for is part of what is said: a change of waits alone is a change.
|
||||
word := k.State + "/" + k.Reason + "/" + waitsWord(waitsOf(k))
|
||||
if j.said[r.ID] != word {
|
||||
changed = true
|
||||
j.said[r.ID] = word
|
||||
@@ -579,3 +580,12 @@ func waitsOf(k *kept) []health.Wait {
|
||||
}
|
||||
return append([]health.Wait(nil), k.Waits...)
|
||||
}
|
||||
|
||||
// waitsWord is a resource's waits in one comparable word.
|
||||
func waitsWord(ws []health.Wait) string {
|
||||
var b strings.Builder
|
||||
for _, w := range ws {
|
||||
b.WriteString(w.Part + "|" + w.Secret + "|" + w.Setting + "|" + w.What + ";")
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user