Skip to content

Commit

Permalink
Merge pull request #1519 from mxinden/cut-v0.15.2
Browse files Browse the repository at this point in the history
Cut v0.15.2
  • Loading branch information
mxinden committed Aug 14, 2018
2 parents 8397de1 + e0a1da1 commit d19fae3
Show file tree
Hide file tree
Showing 23 changed files with 484 additions and 172 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,18 @@
## 0.15.2 / 2018-08-14

* [ENHANCEMENT] [amtool] Add support for stdin to check-config (#1431)
* [ENHANCEMENT] Log PagerDuty v1 response on BadRequest (#1481)
* [BUGFIX] Correctly encode query strings in notifiers (#1516)
* [BUGFIX] Add cache control headers to the API responses to avoid IE caching (#1500)
* [BUGFIX] Avoid listener blocking on unsubscribe (#1482)
* [BUGFIX] Fix a bunch of unhandled errors (#1501)
* [BUGFIX] Update PagerDuty API V2 to send full details on resolve (#1483)
* [BUGFIX] Validate URLs at config load time (#1468)
* [BUGFIX] Fix Settle() interval (#1478)
* [BUGFIX] Fix email to be green if only none firing (#1475)
* [BUGFIX] Handle errors in notify (#1474)
* [BUGFIX] Fix templating of hipchat room id (#1463)

## 0.15.1 / 2018-07-10

* [BUGFIX] Fix email template typo in alert-warning style (#1421)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.15.1
0.15.2
5 changes: 3 additions & 2 deletions api/api.go
Expand Up @@ -59,15 +59,16 @@ func init() {
numReceivedAlerts.WithLabelValues("firing")
numReceivedAlerts.WithLabelValues("resolved")

prometheus.Register(numReceivedAlerts)
prometheus.Register(numInvalidAlerts)
prometheus.MustRegister(numReceivedAlerts)
prometheus.MustRegister(numInvalidAlerts)
}

var corsHeaders = map[string]string{
"Access-Control-Allow-Headers": "Accept, Authorization, Content-Type, Origin",
"Access-Control-Allow-Methods": "GET, DELETE, OPTIONS",
"Access-Control-Allow-Origin": "*",
"Access-Control-Expose-Headers": "Date",
"Cache-Control": "no-cache, no-store, must-revalidate",
}

// Enables cross-site script calls.
Expand Down
12 changes: 12 additions & 0 deletions cli/check_config.go
Expand Up @@ -15,6 +15,7 @@ package cli

import (
"fmt"
"os"

"github.com/prometheus/alertmanager/config"
"github.com/prometheus/alertmanager/template"
Expand Down Expand Up @@ -47,6 +48,17 @@ func (c *checkConfigCmd) checkConfig(ctx *kingpin.ParseContext) error {
}

func CheckConfig(args []string) error {
if len(args) == 0 {
stat, err := os.Stdin.Stat()
if err != nil {
kingpin.Fatalf("Failed to stat standard input: %v", err)
}
if (stat.Mode() & os.ModeCharDevice) != 0 {
kingpin.Fatalf("Failed to read from standard input")
}
args = []string{os.Stdin.Name()}
}

failed := 0

for _, arg := range args {
Expand Down
6 changes: 2 additions & 4 deletions cli/format/format_extended.go
Expand Up @@ -54,8 +54,7 @@ func (formatter *ExtendedFormatter) FormatSilences(silences []types.Silence) err
silence.Comment,
)
}
w.Flush()
return nil
return w.Flush()
}

func (formatter *ExtendedFormatter) FormatAlerts(alerts []*client.ExtendedAlert) error {
Expand All @@ -73,8 +72,7 @@ func (formatter *ExtendedFormatter) FormatAlerts(alerts []*client.ExtendedAlert)
alert.GeneratorURL,
)
}
w.Flush()
return nil
return w.Flush()
}

func (formatter *ExtendedFormatter) FormatConfig(status *client.ServerStatus) error {
Expand Down
6 changes: 2 additions & 4 deletions cli/format/format_simple.go
Expand Up @@ -52,8 +52,7 @@ func (formatter *SimpleFormatter) FormatSilences(silences []types.Silence) error
silence.Comment,
)
}
w.Flush()
return nil
return w.Flush()
}

func (formatter *SimpleFormatter) FormatAlerts(alerts []*client.ExtendedAlert) error {
Expand All @@ -69,8 +68,7 @@ func (formatter *SimpleFormatter) FormatAlerts(alerts []*client.ExtendedAlert) e
alert.Annotations["summary"],
)
}
w.Flush()
return nil
return w.Flush()
}

func (formatter *SimpleFormatter) FormatConfig(status *client.ServerStatus) error {
Expand Down
4 changes: 3 additions & 1 deletion cli/silence_query.go
Expand Up @@ -148,7 +148,9 @@ func (c *silenceQueryCmd) query(ctx *kingpin.ParseContext) error {
if !found {
return errors.New("unknown output formatter")
}
formatter.FormatSilences(displaySilences)
if err := formatter.FormatSilences(displaySilences); err != nil {
return fmt.Errorf("error formatting silences: %v", err)
}
}
return nil
}
4 changes: 3 additions & 1 deletion cli/silence_update.go
Expand Up @@ -118,7 +118,9 @@ func (c *silenceUpdateCmd) update(ctx *kingpin.ParseContext) error {
if !found {
return fmt.Errorf("unknown output formatter")
}
formatter.FormatSilences(updatedSilences)
if err := formatter.FormatSilences(updatedSilences); err != nil {
return fmt.Errorf("error formatting silences: %v", err)
}
}
return nil
}
39 changes: 30 additions & 9 deletions client/client.go
Expand Up @@ -138,7 +138,10 @@ type httpStatusAPI struct {
func (h *httpStatusAPI) Get(ctx context.Context) (*ServerStatus, error) {
u := h.client.URL(epStatus, nil)

req, _ := http.NewRequest(http.MethodGet, u.String(), nil)
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
if err != nil {
return nil, fmt.Errorf("error creating request: %v", err)
}

_, body, err := h.client.Do(ctx, req)
if err != nil {
Expand Down Expand Up @@ -207,7 +210,10 @@ func (h *httpAlertAPI) List(ctx context.Context, filter, receiver string, silenc
params.Add("receiver", receiver)
u.RawQuery = params.Encode()

req, _ := http.NewRequest(http.MethodGet, u.String(), nil)
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
if err != nil {
return nil, fmt.Errorf("error creating request: %v", err)
}

_, body, err := h.client.Do(ctx, req)
if err != nil {
Expand All @@ -228,9 +234,12 @@ func (h *httpAlertAPI) Push(ctx context.Context, alerts ...Alert) error {
return err
}

req, _ := http.NewRequest(http.MethodPost, u.String(), &buf)
req, err := http.NewRequest(http.MethodPost, u.String(), &buf)
if err != nil {
return fmt.Errorf("error creating request: %v", err)
}

_, _, err := h.client.Do(ctx, req)
_, _, err = h.client.Do(ctx, req)
return err
}

Expand Down Expand Up @@ -260,7 +269,10 @@ func (h *httpSilenceAPI) Get(ctx context.Context, id string) (*types.Silence, er
"id": id,
})

req, _ := http.NewRequest(http.MethodGet, u.String(), nil)
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
if err != nil {
return nil, fmt.Errorf("error creating request: %v", err)
}

_, body, err := h.client.Do(ctx, req)
if err != nil {
Expand All @@ -278,9 +290,12 @@ func (h *httpSilenceAPI) Expire(ctx context.Context, id string) error {
"id": id,
})

req, _ := http.NewRequest(http.MethodDelete, u.String(), nil)
req, err := http.NewRequest(http.MethodDelete, u.String(), nil)
if err != nil {
return fmt.Errorf("error creating request: %v", err)
}

_, _, err := h.client.Do(ctx, req)
_, _, err = h.client.Do(ctx, req)
return err
}

Expand All @@ -292,7 +307,10 @@ func (h *httpSilenceAPI) Set(ctx context.Context, sil types.Silence) (string, er
return "", err
}

req, _ := http.NewRequest(http.MethodPost, u.String(), &buf)
req, err := http.NewRequest(http.MethodPost, u.String(), &buf)
if err != nil {
return "", fmt.Errorf("error creating request: %v", err)
}

_, body, err := h.client.Do(ctx, req)
if err != nil {
Expand All @@ -315,7 +333,10 @@ func (h *httpSilenceAPI) List(ctx context.Context, filter string) ([]*types.Sile
}
u.RawQuery = params.Encode()

req, _ := http.NewRequest(http.MethodGet, u.String(), nil)
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
if err != nil {
return nil, fmt.Errorf("error creating request: %v", err)
}

_, body, err := h.client.Do(ctx, req)
if err != nil {
Expand Down
6 changes: 4 additions & 2 deletions cmd/alertmanager/main.go
Expand Up @@ -267,9 +267,11 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), *settleTimeout)
defer func() {
cancel()
peer.Leave(10 * time.Second)
if err := peer.Leave(10 * time.Second); err != nil {
level.Warn(logger).Log("msg", "unable to leave gossip mesh", "err", err)
}
}()
go peer.Settle(ctx, *pushPullInterval*10)
go peer.Settle(ctx, *gossipInterval*10)
}

alerts, err := mem.NewAlerts(marker, *alertGCInterval)
Expand Down

0 comments on commit d19fae3

Please sign in to comment.