Merge pull request #2581 from roidelapluie/fixnilinapi

API: Only pass cluster peer if empty
This commit is contained in:
Julien Pivotto 2021-05-17 13:27:40 +02:00 committed by GitHub
commit 8373b35b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -335,11 +335,19 @@ func run() int {
return disp.Groups(routeFilter, alertFilter)
}
// An interface value that holds a nil concrete value is non-nil.
// Therefore we explicly pass an empty interface, to detect if the
// cluster is not enabled in notify.
var clusterPeer cluster.ClusterPeer
if peer != nil {
clusterPeer = peer
}
api, err := api.New(api.Options{
Alerts: alerts,
Silences: silences,
StatusFunc: marker.Status,
Peer: peer,
Peer: clusterPeer,
Timeout: *httpTimeout,
Concurrency: *getConcurrency,
Logger: log.With(logger, "component", "api"),