Alerting: Fix state cache getOrCreate panic (#33777)

This commit is contained in:
Kyle Brandt 2021-05-06 08:35:52 -04:00 committed by GitHub
parent b5b8877253
commit fae093bbe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,6 +47,8 @@ func (c *cache) getOrCreate(alertRule *ngModels.AlertRule, result eval.Result) *
if _, ok := c.states[alertRule.OrgID]; !ok {
c.states[alertRule.OrgID] = make(map[string]map[string]*State)
}
if _, ok := c.states[alertRule.OrgID][alertRule.UID]; !ok {
c.states[alertRule.OrgID][alertRule.UID] = make(map[string]*State)
}