mirror of
https://github.com/spaytac/orbiter.git
synced 2026-01-21 23:44:41 +00:00
Bugfix autodetection labels
This commit is contained in:
parent
3cea6bb8ba
commit
b6f6cb3784
@ -52,7 +52,6 @@ func autoDetectSwarmMode(c *Core) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
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
|
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)
|
up := convertStringLabelToInt("orbiter.up", an.Labels)
|
||||||
down := convertStringLabelToInt("orbiter.down", an.Labels)
|
down := convertStringLabelToInt("orbiter.down", an.Labels)
|
||||||
as := autoscaler.NewAutoscaler(p, an.Name, up, down)
|
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
|
return as, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertStringLabelToInt(labelName string, labels map[string]string) int {
|
func convertStringLabelToInt(labelName string, labels map[string]string) int {
|
||||||
row, e := labels[labelName]
|
row, e := labels[labelName]
|
||||||
if e == false {
|
if e == true {
|
||||||
i, err := strconv.ParseInt(row, 10, 64)
|
i, err := strconv.ParseInt(row, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
23
core/autodetect_test.go
Normal file
23
core/autodetect_test.go
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user