Skip to content

Commit

Permalink
fix: hard coded default algorithm that should not be set in this part…
Browse files Browse the repository at this point in the history
… of the code

test: add test cases

Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
  • Loading branch information
szuecs committed Sep 22, 2023
1 parent 9ad6457 commit d28bd00
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 6 deletions.
4 changes: 0 additions & 4 deletions dataclients/kubernetes/definitions/routegroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ func (sb *SkipperBackend) UnmarshalJSON(value []byte) error {
perr = err
}

if a == loadbalancer.None {
a = loadbalancer.RoundRobin
}

var b SkipperBackend
b.Name = p.Name
b.Type = bt
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kube_rg__default__myapp__all__0_0:
Host("^(example[.]org[.]?(:[0-9]+)?)$")
&& PathSubtree("/")
-> <powerOfRandomNChoices, "http://10.2.9.103:7272", "http://10.2.9.104:7272">;

kube_rg____example_org__catchall__0_0: Host("^(example[.]org[.]?(:[0-9]+)?)$") -> <shunt>;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default-lb-algorithm: consistentHash
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: zalando.org/v1
kind: RouteGroup
metadata:
name: myapp
spec:
hosts:
- example.org
backends:
- name: myapp
type: service
serviceName: myapp
servicePort: 80
algorithm: powerOfRandomNChoices
routes:
- pathSubtree: /
backends:
- backendName: myapp
---
apiVersion: v1
kind: Service
metadata:
labels:
application: myapp
name: myapp
spec:
clusterIP: 10.3.190.97
ports:
- name: main
port: 80
protocol: TCP
targetPort: 7272
selector:
application: myapp
type: ClusterIP
---
apiVersion: v1
kind: Endpoints
metadata:
labels:
application: myapp
name: myapp
namespace: default
subsets:
- addresses:
- ip: 10.2.9.103
- ip: 10.2.9.104
ports:
- name: main
port: 7272
protocol: TCP
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kube_rg__default__myapp__all__0_0:
Host("^(example[.]org[.]?(:[0-9]+)?)$")
&& PathSubtree("/")
-> <roundRobin, "http://10.2.9.103:7272", "http://10.2.9.104:7272">;

kube_rg____example_org__catchall__0_0: Host("^(example[.]org[.]?(:[0-9]+)?)$") -> <shunt>;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default-lb-algorithm: does-not-exist
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: zalando.org/v1
kind: RouteGroup
metadata:
name: myapp
spec:
hosts:
- example.org
backends:
- name: myapp
type: service
serviceName: myapp
servicePort: 80
routes:
- pathSubtree: /
backends:
- backendName: myapp
---
apiVersion: v1
kind: Service
metadata:
labels:
application: myapp
name: myapp
spec:
clusterIP: 10.3.190.97
ports:
- name: main
port: 80
protocol: TCP
targetPort: 7272
selector:
application: myapp
type: ClusterIP
---
apiVersion: v1
kind: Endpoints
metadata:
labels:
application: myapp
name: myapp
namespace: default
subsets:
- addresses:
- ip: 10.2.9.103
- ip: 10.2.9.104
ports:
- name: main
port: 7272
protocol: TCP
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kube_rg__default__myapp__all__0_0:
Host("^(example[.]org[.]?(:[0-9]+)?)$")
&& PathSubtree("/")
-> <roundRobin, "http://10.2.9.103:7272", "http://10.2.9.104:7272">;
-> <consistentHash, "http://10.2.9.103:7272", "http://10.2.9.104:7272">;

kube_rg____example_org__catchall__0_0: Host("^(example[.]org[.]?(:[0-9]+)?)$") -> <shunt>;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default-lb-algorithm: consistantHash
default-lb-algorithm: consistentHash

0 comments on commit d28bd00

Please sign in to comment.