further bug fixes
This commit is contained in:
parent
5d48af9013
commit
9d112511dd
@ -152,7 +152,7 @@ func (h *Handler) evaluateWhen(p *udf.Point) (bool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("the expression `when` should evaluate to true or false, got %s", res)
|
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
|
return doScale, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +191,9 @@ func (h *Handler) Point(p *udf.Point) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
h.debug("attempt to scale service '%s' from %d to %d", h.Id, service.CurrentInstances, to)
|
||||||
if !h.Simulate {
|
if !h.Simulate {
|
||||||
err = h.scaleAgent.Scale(h.Id, to)
|
err = h.scaleAgent.Scale(h.Id, to)
|
||||||
@ -200,9 +203,9 @@ func (h *Handler) Point(p *udf.Point) error {
|
|||||||
}
|
}
|
||||||
service.CurrentInstances = to
|
service.CurrentInstances = to
|
||||||
service.CooldownUntil = time.Now().Add(h.Cooldown)
|
service.CooldownUntil = time.Now().Add(h.Cooldown)
|
||||||
p.FieldsDouble = nil
|
p.FieldsDouble = make(map[string]float64)
|
||||||
p.FieldsInt = map[string]int64{"scale": to}
|
p.FieldsInt = map[string]int64{"scale": to}
|
||||||
p.FieldsString = nil
|
p.FieldsString = make(map[string]string)
|
||||||
h.kapacitorAgent.Responses <- &udf.Response{
|
h.kapacitorAgent.Responses <- &udf.Response{
|
||||||
Message: &udf.Response_Point{
|
Message: &udf.Response_Point{
|
||||||
Point: p,
|
Point: p,
|
||||||
|
2
main.go
2
main.go
@ -47,7 +47,7 @@ func (acc *acceptor) Accept(conn net.Conn) {
|
|||||||
func parseArgs() *url.URL {
|
func parseArgs() *url.URL {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if len(os.Args) < 2 {
|
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")
|
fmt.Fprintf(os.Stderr, "rancher url is expected as first argument, for example: http://accesskey:secretkey@localhost:8080")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user