mirror of
https://github.com/traefik/traefik.git
synced 2025-05-06 07:53:01 +00:00
Fix fenced server status computation
Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
parent
68a8650297
commit
a29628fa2e
@ -31,17 +31,22 @@ endpoints:
|
|||||||
- 10.10.0.2
|
- 10.10.0.2
|
||||||
conditions:
|
conditions:
|
||||||
ready: true
|
ready: true
|
||||||
|
serving: true
|
||||||
|
terminating: false
|
||||||
- addresses:
|
- addresses:
|
||||||
- 10.10.0.3
|
- 10.10.0.3
|
||||||
- 10.10.0.4
|
- 10.10.0.4
|
||||||
conditions:
|
conditions:
|
||||||
ready: false
|
ready: false
|
||||||
serving: true
|
serving: true
|
||||||
|
terminating: true
|
||||||
- addresses:
|
- addresses:
|
||||||
- 10.10.0.5
|
- 10.10.0.5
|
||||||
- 10.10.0.6
|
- 10.10.0.6
|
||||||
conditions:
|
conditions:
|
||||||
ready: true
|
ready: false
|
||||||
|
serving: false
|
||||||
|
terminating: true
|
||||||
|
|
||||||
---
|
---
|
||||||
apiVersion: traefik.io/v1alpha1
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
@ -559,7 +559,7 @@ func (c configBuilder) loadServers(parentNamespace string, svc traefikv1alpha1.L
|
|||||||
addresses[address] = struct{}{}
|
addresses[address] = struct{}{}
|
||||||
servers = append(servers, dynamic.Server{
|
servers = append(servers, dynamic.Server{
|
||||||
URL: fmt.Sprintf("%s://%s", protocol, net.JoinHostPort(address, strconv.Itoa(int(port)))),
|
URL: fmt.Sprintf("%s://%s", protocol, net.JoinHostPort(address, strconv.Itoa(int(port)))),
|
||||||
Fenced: ptr.Deref(endpoint.Conditions.Serving, false),
|
Fenced: ptr.Deref(endpoint.Conditions.Terminating, false) && ptr.Deref(endpoint.Conditions.Serving, false),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4751,12 +4751,6 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||||||
URL: "http://10.10.0.4:80",
|
URL: "http://10.10.0.4:80",
|
||||||
Fenced: true,
|
Fenced: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
URL: "http://10.10.0.5:80",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
URL: "http://10.10.0.6:80",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
PassHostHeader: pointer(true),
|
PassHostHeader: pointer(true),
|
||||||
ResponseForwarding: &dynamic.ResponseForwarding{
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
kind: Ingress
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
name: ""
|
||||||
|
namespace: testing
|
||||||
|
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- http:
|
||||||
|
paths:
|
||||||
|
- path: /bar
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: service1
|
||||||
|
port:
|
||||||
|
number: 80
|
||||||
|
pathType: Prefix
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: Service
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: service1
|
||||||
|
namespace: testing
|
||||||
|
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
clusterIP: 10.0.0.1
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: EndpointSlice
|
||||||
|
apiVersion: discovery.k8s.io/v1
|
||||||
|
metadata:
|
||||||
|
name: service1-abc
|
||||||
|
namespace: testing
|
||||||
|
labels:
|
||||||
|
kubernetes.io/service-name: service1
|
||||||
|
|
||||||
|
addressType: IPv4
|
||||||
|
ports:
|
||||||
|
- port: 8080
|
||||||
|
name: ""
|
||||||
|
endpoints:
|
||||||
|
- addresses:
|
||||||
|
- 10.10.0.1
|
||||||
|
- 10.10.0.2
|
||||||
|
conditions:
|
||||||
|
ready: true
|
||||||
|
serving: true
|
||||||
|
terminating: false
|
||||||
|
- addresses:
|
||||||
|
- 10.10.0.3
|
||||||
|
- 10.10.0.4
|
||||||
|
conditions:
|
||||||
|
ready: false
|
||||||
|
serving: true
|
||||||
|
terminating: true
|
||||||
|
- addresses:
|
||||||
|
- 10.10.0.5
|
||||||
|
- 10.10.0.6
|
||||||
|
conditions:
|
||||||
|
ready: false
|
||||||
|
serving: false
|
||||||
|
terminating: true
|
@ -601,7 +601,7 @@ func (p *Provider) loadService(client Client, namespace string, backend netv1.In
|
|||||||
addresses[address] = struct{}{}
|
addresses[address] = struct{}{}
|
||||||
svc.LoadBalancer.Servers = append(svc.LoadBalancer.Servers, dynamic.Server{
|
svc.LoadBalancer.Servers = append(svc.LoadBalancer.Servers, dynamic.Server{
|
||||||
URL: fmt.Sprintf("%s://%s", protocol, net.JoinHostPort(address, strconv.Itoa(int(port)))),
|
URL: fmt.Sprintf("%s://%s", protocol, net.JoinHostPort(address, strconv.Itoa(int(port)))),
|
||||||
Fenced: ptr.Deref(endpoint.Conditions.Serving, false),
|
Fenced: ptr.Deref(endpoint.Conditions.Terminating, false) && ptr.Deref(endpoint.Conditions.Serving, false),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1534,6 +1534,46 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "Ingress with endpoint conditions",
|
||||||
|
expected: &dynamic.Configuration{
|
||||||
|
HTTP: &dynamic.HTTPConfiguration{
|
||||||
|
Middlewares: map[string]*dynamic.Middleware{},
|
||||||
|
Routers: map[string]*dynamic.Router{
|
||||||
|
"testing-bar": {
|
||||||
|
Rule: "PathPrefix(`/bar`)",
|
||||||
|
Service: "testing-service1-80",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Services: map[string]*dynamic.Service{
|
||||||
|
"testing-service1-80": {
|
||||||
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||||
|
PassHostHeader: pointer(true),
|
||||||
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
||||||
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
||||||
|
},
|
||||||
|
Servers: []dynamic.Server{
|
||||||
|
{
|
||||||
|
URL: "http://10.10.0.1:8080",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
URL: "http://10.10.0.2:8080",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
URL: "http://10.10.0.3:8080",
|
||||||
|
Fenced: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
URL: "http://10.10.0.4:8080",
|
||||||
|
Fenced: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user