Implementation of serving not ready endpoints
This commit is contained in:
parent
a4c0b1649d
commit
9588e51146
13 changed files with 204 additions and 42 deletions
|
@ -18,7 +18,7 @@ func Test_convertSlice_corev1_to_networkingv1(t *testing.T) {
|
|||
{
|
||||
Port: 123,
|
||||
Protocol: "https",
|
||||
Error: ptr("test"),
|
||||
Error: pointer("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -35,7 +35,7 @@ func Test_convertSlice_corev1_to_networkingv1(t *testing.T) {
|
|||
{
|
||||
Port: 123,
|
||||
Protocol: "https",
|
||||
Error: ptr("test"),
|
||||
Error: pointer("test"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -52,7 +52,7 @@ func Test_convert(t *testing.T) {
|
|||
{
|
||||
Port: 123,
|
||||
Protocol: "https",
|
||||
Error: ptr("test"),
|
||||
Error: pointer("test"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -67,14 +67,10 @@ func Test_convert(t *testing.T) {
|
|||
{
|
||||
Port: 123,
|
||||
Protocol: "https",
|
||||
Error: ptr("test"),
|
||||
Error: pointer("test"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func ptr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
netv1 "k8s.io/api/networking/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -587,7 +588,7 @@ func (p *Provider) loadService(client Client, namespace string, backend netv1.In
|
|||
protocol := getProtocol(portSpec, portName, svcConfig)
|
||||
|
||||
for _, endpoint := range endpointSlice.Endpoints {
|
||||
if endpoint.Conditions.Ready == nil || !*endpoint.Conditions.Ready {
|
||||
if !k8s.EndpointServing(endpoint) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -598,7 +599,8 @@ func (p *Provider) loadService(client Client, namespace string, backend netv1.In
|
|||
|
||||
addresses[address] = struct{}{}
|
||||
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),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue