Fix if-guard for replica scaling

This commit is contained in:
Alex
2017-01-23 22:12:47 +00:00
parent 6feaff784e
commit 59ca597903

View File

@ -23,7 +23,7 @@ func scaleService(req requests.PrometheusAlert, c *client.Client) error {
//Todo: convert to loop / handler.
serviceName := req.Alerts[0].Labels.FunctionName
service, _, inspectErr := c.ServiceInspectWithRaw(context.Background(), serviceName)
if inspectErr != nil {
if inspectErr == nil {
var replicas uint64
if req.Status == "firing" {
@ -60,12 +60,17 @@ func scaleService(req requests.PrometheusAlert, c *client.Client) error {
func makeAlertHandler(c *client.Client) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
log.Println("Alert received.")
body, _ := ioutil.ReadAll(r.Body)
body, readErr := ioutil.ReadAll(r.Body)
if readErr != nil {
log.Println(readErr)
return
}
var req requests.PrometheusAlert
err := json.Unmarshal(body, &req)
if err != nil {
log.Println(err)
return
}
if len(req.Alerts) > 0 {