Skip to content

Commit 6b9024d

Browse files
committed
continue routing to serving endpointslices during termination
Signed-off-by: fogninid <[email protected]>
1 parent ca2d80b commit 6b9024d

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

internal/gatewayapi/route.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ func getIREndpointsFromEndpointSlice(endpointSlice *discoveryv1.EndpointSlice, p
16221622
if *endpointPort.Name == portName &&
16231623
*endpointPort.Protocol == portProtocol &&
16241624
// Unknown state (nil) should be interpreted as Ready, see https://pkg.go.dev/k8s.io/api/discovery/v1#EndpointConditions
1625-
(endpoint.Conditions.Ready == nil || *endpoint.Conditions.Ready) {
1625+
(endpoint.Conditions.Ready == nil || *endpoint.Conditions.Ready || (endpoint.Conditions.Serving != nil && *endpoint.Conditions.Serving)) {
16261626
for _, address := range endpoint.Addresses {
16271627
ep := ir.NewDestEndpoint(
16281628
address,

internal/gatewayapi/route_test.go

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"fmt"
1010
"testing"
1111

12+
"github.com/stretchr/testify/require"
1213
corev1 "k8s.io/api/core/v1"
1314
discoveryv1 "k8s.io/api/discovery/v1"
1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -50,10 +51,59 @@ func TestGetIREndpointsFromEndpointSlices(t *testing.T) {
5051
{Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)},
5152
},
5253
},
54+
{
55+
ObjectMeta: metav1.ObjectMeta{Name: "slice3"},
56+
AddressType: discoveryv1.AddressTypeIPv6,
57+
Endpoints: []discoveryv1.Endpoint{
58+
{
59+
Addresses: []string{"2001:db8::2"},
60+
Conditions: discoveryv1.EndpointConditions{
61+
Ready: ptr.To(false),
62+
},
63+
},
64+
},
65+
Ports: []discoveryv1.EndpointPort{
66+
{Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)},
67+
},
68+
},
69+
{
70+
ObjectMeta: metav1.ObjectMeta{Name: "slice4"},
71+
AddressType: discoveryv1.AddressTypeIPv6,
72+
Endpoints: []discoveryv1.Endpoint{
73+
{
74+
Addresses: []string{"2001:db8::3"},
75+
Conditions: discoveryv1.EndpointConditions{
76+
Ready: ptr.To(false),
77+
Serving: ptr.To(true),
78+
Terminating: ptr.To(true),
79+
},
80+
},
81+
},
82+
Ports: []discoveryv1.EndpointPort{
83+
{Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)},
84+
},
85+
},
86+
{
87+
ObjectMeta: metav1.ObjectMeta{Name: "slice5"},
88+
AddressType: discoveryv1.AddressTypeIPv6,
89+
Endpoints: []discoveryv1.Endpoint{
90+
{
91+
Addresses: []string{"2001:db8::4"},
92+
Conditions: discoveryv1.EndpointConditions{
93+
Ready: ptr.To(false),
94+
Serving: ptr.To(false),
95+
Terminating: ptr.To(true),
96+
},
97+
},
98+
},
99+
Ports: []discoveryv1.EndpointPort{
100+
{Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)},
101+
},
102+
},
53103
},
54104
portName: "http",
55105
portProtocol: corev1.ProtocolTCP,
56-
expectedEndpoints: 3,
106+
expectedEndpoints: 4,
57107
expectedAddrType: ir.IP,
58108
},
59109
{
@@ -174,6 +224,8 @@ func TestGetIREndpointsFromEndpointSlices(t *testing.T) {
174224
}
175225

176226
fmt.Println()
227+
require.Len(t, endpoints, tt.expectedEndpoints)
228+
require.Equal(t, tt.expectedAddrType, *addrType)
177229
})
178230
}
179231
}

release-notes/current.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ new features: |
1717
Added support for trusted CIDRs in the ClientIPDetectionSettings API
1818
Added support for sending attributes to external processor in EnvoyExtensionPolicy API
1919
Added support for patching EnvoyProxy.spec.provider.kubernetes.envoyHpa and EnvoyProxy.spec.provider.kubernetes.envoyPDB
20+
Do not stop routing to endpoints until their graceful termination is complete, as indicated by their respective EndpointConditions
2021
2122
# Fixes for bugs identified in previous versions.
2223
bug fixes: |

0 commit comments

Comments
 (0)