mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-17 20:05:17 +00:00
cli: check for NotFound error during silence import
Check the error type when there is a non-existent silence instead of comparing the text of the error message. Signed-off-by: Paul Gier <pgier@redhat.com>
This commit is contained in:
parent
52f78c5b88
commit
3b9629e294
@ -18,7 +18,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@ -63,7 +62,7 @@ func addSilenceWorker(ctx context.Context, sclient *silence.Client, silencec <-c
|
||||
sid := s.ID
|
||||
params := silence.NewPostSilencesParams().WithContext(ctx).WithSilence(s)
|
||||
postOk, err := sclient.PostSilences(params)
|
||||
if err != nil && strings.Contains(err.Error(), "not found") {
|
||||
if _, ok := err.(*silence.PostSilencesNotFound); ok {
|
||||
// silence doesn't exists yet, retry to create as a new one
|
||||
params.Silence.ID = ""
|
||||
postOk, err = sclient.PostSilences(params)
|
||||
|
Loading…
Reference in New Issue
Block a user