From 9d112511dd92a67ca7e270469007fc93dd3641a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 22 Apr 2016 14:02:33 +0000 Subject: [PATCH] further bug fixes --- handler/lib.go | 9 ++++++--- main.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/handler/lib.go b/handler/lib.go index 629932c..91227e7 100644 --- a/handler/lib.go +++ b/handler/lib.go @@ -152,7 +152,7 @@ func (h *Handler) evaluateWhen(p *udf.Point) (bool, error) { if err != nil { return false, fmt.Errorf("the expression `when` should evaluate to true or false, got %s", res) } - h.debug("evaluate '%s' for '%v' -> should scale: %s", h.When, fields, doScale) + h.debug("evaluate '%s' for '%v' -> should scale: %v", h.When, fields, doScale) return doScale, nil } @@ -191,6 +191,9 @@ func (h *Handler) Point(p *udf.Point) error { if err != nil { return err } + if to == service.CurrentInstances { + h.debug("skip scaling service '%s' still %d", h.Id, to) + } h.debug("attempt to scale service '%s' from %d to %d", h.Id, service.CurrentInstances, to) if !h.Simulate { err = h.scaleAgent.Scale(h.Id, to) @@ -200,9 +203,9 @@ func (h *Handler) Point(p *udf.Point) error { } service.CurrentInstances = to service.CooldownUntil = time.Now().Add(h.Cooldown) - p.FieldsDouble = nil + p.FieldsDouble = make(map[string]float64) p.FieldsInt = map[string]int64{"scale": to} - p.FieldsString = nil + p.FieldsString = make(map[string]string) h.kapacitorAgent.Responses <- &udf.Response{ Message: &udf.Response_Point{ Point: p, diff --git a/main.go b/main.go index d28ff7e..1f9d5be 100644 --- a/main.go +++ b/main.go @@ -47,7 +47,7 @@ func (acc *acceptor) Accept(conn net.Conn) { func parseArgs() *url.URL { flag.Parse() if len(os.Args) < 2 { - fmt.Fprintf(os.Stderr, "USAGE: %s rancherurl\n") + fmt.Fprintf(os.Stderr, "USAGE: %s rancherurl\n", os.Args[0]) fmt.Fprintf(os.Stderr, "rancher url is expected as first argument, for example: http://accesskey:secretkey@localhost:8080") os.Exit(1) }