Avoid flapping of multiple Ingress definitions
This commit is contained in:
parent
a9deeb321b
commit
157580c232
3 changed files with 163 additions and 23 deletions
|
@ -1571,6 +1571,14 @@ rateset:
|
|||
route("root", "Host:root"),
|
||||
),
|
||||
),
|
||||
frontend("root2/",
|
||||
passHostHeader(),
|
||||
redirectRegex("root2/$", "root2/root2"),
|
||||
routes(
|
||||
route("/", "PathPrefix:/;ReplacePathRegex: ^/(.*) /abc$1"),
|
||||
route("root2", "Host:root2"),
|
||||
),
|
||||
),
|
||||
frontend("root/root1",
|
||||
passHostHeader(),
|
||||
routes(
|
||||
|
@ -3476,3 +3484,93 @@ func TestTemplateBreakingIngresssValues(t *testing.T) {
|
|||
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestDivergingIngressDefinitions(t *testing.T) {
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iRules(
|
||||
iRule(
|
||||
iHost("host-a"),
|
||||
iPaths(
|
||||
onePath(iBackend("service1", intstr.FromString("80"))),
|
||||
)),
|
||||
),
|
||||
),
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iRules(
|
||||
iRule(
|
||||
iHost("host-a"),
|
||||
iPaths(
|
||||
onePath(iBackend("missing", intstr.FromString("80"))),
|
||||
)),
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
sUID("1"),
|
||||
sSpec(
|
||||
clusterIP("10.0.0.1"),
|
||||
sPorts(sPort(80, "http")),
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
endpoints := []*corev1.Endpoints{
|
||||
buildEndpoint(
|
||||
eNamespace("testing"),
|
||||
eName("service1"),
|
||||
eUID("1"),
|
||||
subset(
|
||||
eAddresses(
|
||||
eAddress("10.10.0.1"),
|
||||
),
|
||||
ePorts(ePort(80, "http")),
|
||||
),
|
||||
subset(
|
||||
eAddresses(
|
||||
eAddress("10.10.0.2"),
|
||||
),
|
||||
ePorts(ePort(80, "http")),
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
watchChan := make(chan interface{})
|
||||
client := clientMock{
|
||||
ingresses: ingresses,
|
||||
services: services,
|
||||
endpoints: endpoints,
|
||||
watchChan: watchChan,
|
||||
}
|
||||
provider := Provider{}
|
||||
|
||||
actual, err := provider.loadIngresses(client)
|
||||
require.NoError(t, err, "error loading ingresses")
|
||||
|
||||
expected := buildConfiguration(
|
||||
backends(
|
||||
backend("host-a",
|
||||
servers(
|
||||
server("http://10.10.0.1:80", weight(1)),
|
||||
server("http://10.10.0.2:80", weight(1)),
|
||||
),
|
||||
lbMethod("wrr"),
|
||||
),
|
||||
),
|
||||
frontends(
|
||||
frontend("host-a",
|
||||
passHostHeader(),
|
||||
routes(
|
||||
route("host-a", "Host:host-a")),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
assert.Equal(t, expected, actual, "error merging multiple backends")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue