diff --git a/core/autodetect.go b/core/autodetect.go index dcd448e..cdac19c 100644 --- a/core/autodetect.go +++ b/core/autodetect.go @@ -52,7 +52,6 @@ func autoDetectSwarmMode(c *Core) { if err != nil { continue } - logrus.Debugf("autodetect_swarm/%s added to orbiter.", service.Spec.Annotations.Name) c.Autoscalers[fmt.Sprintf("autodetect_swarm/%s", service.Spec.Annotations.Name)] = s } } @@ -65,12 +64,13 @@ func getAutoscalerByService(p autoscaler.Provider, an swarm.Annotations) (autosc up := convertStringLabelToInt("orbiter.up", an.Labels) down := convertStringLabelToInt("orbiter.down", an.Labels) as := autoscaler.NewAutoscaler(p, an.Name, up, down) + logrus.Debugf("autodetect_swarm/%s added to orbiter. UP %d, DOWN %d", an.Name, up, down) return as, nil } func convertStringLabelToInt(labelName string, labels map[string]string) int { row, e := labels[labelName] - if e == false { + if e == true { i, err := strconv.ParseInt(row, 10, 64) if err != nil { return 1 diff --git a/core/autodetect_test.go b/core/autodetect_test.go new file mode 100644 index 0000000..5759830 --- /dev/null +++ b/core/autodetect_test.go @@ -0,0 +1,23 @@ +package core + +import "testing" + +func TestGetRightOrbiterUp(t *testing.T) { + r := convertStringLabelToInt("orbiter.up", map[string]string{ + "orbiter.up": "3", + "orbiter.down": "3", + }) + if r != 3 { + t.Fatalf("%d != 3", r) + } +} + +func TestGetRightOrbiterDown(t *testing.T) { + r := convertStringLabelToInt("orbiter.down", map[string]string{ + "orbiter.up": "3", + "orbiter.down": "2", + }) + if r != 2 { + t.Fatalf("%d != 2", r) + } +}