mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
0ce1ccd6f9
AM config applied via API would use the PostableUserConfig as the AM raw config and also the hash used to decide when the AM config has changed. However, when applied via the periodic sync the PostableApiAlertingConfig would be used instead. This leads to two issues: - Inconsistent hash comparisons when modifying the AM causing redundant applies. - GetStatus assumed the raw config was PostableUserConfig causing the endpoint to return correctly after a new config is applied via API and then nothing once the periodic sync runs. Note: Technically, the upstream GrafanaAlertamanger GetStatus shouldn't be returning PostableUserConfig or PostableApiAlertingConfig, but instead GettableStatus. However, this issue required changes elsewhere and is out of scope.
23 lines
690 B
Go
23 lines
690 B
Go
package notifier
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
|
)
|
|
|
|
// TODO: We no longer do apimodels at this layer, move it to the API.
|
|
func (am *alertmanager) GetStatus() apimodels.GettableStatus {
|
|
config := &apimodels.PostableApiAlertingConfig{}
|
|
status := am.Base.GetStatus() // TODO: This should return a GettableStatus, for now it returns PostableApiAlertingConfig.
|
|
if status == nil {
|
|
return *apimodels.NewGettableStatus(config)
|
|
}
|
|
|
|
if err := json.Unmarshal(status, config); err != nil {
|
|
am.logger.Error("Unable to unmarshall alertmanager config", "Err", err)
|
|
}
|
|
|
|
return *apimodels.NewGettableStatus(config)
|
|
}
|