Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: continue routing to serving endpointslices during termination #4946

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ func getIREndpointsFromEndpointSlice(endpointSlice *discoveryv1.EndpointSlice, p
if *endpointPort.Name == portName &&
*endpointPort.Protocol == portProtocol &&
// Unknown state (nil) should be interpreted as Ready, see https://pkg.go.dev/k8s.io/api/discovery/v1#EndpointConditions
(endpoint.Conditions.Ready == nil || *endpoint.Conditions.Ready) {
(endpoint.Conditions.Ready == nil || *endpoint.Conditions.Ready || (endpoint.Conditions.Serving != nil && *endpoint.Conditions.Serving)) {
for _, address := range endpoint.Addresses {
ep := ir.NewDestEndpoint(
address,
Expand Down
54 changes: 53 additions & 1 deletion internal/gatewayapi/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -50,10 +51,59 @@ func TestGetIREndpointsFromEndpointSlices(t *testing.T) {
{Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)},
},
},
{
ObjectMeta: metav1.ObjectMeta{Name: "slice3"},
AddressType: discoveryv1.AddressTypeIPv6,
Endpoints: []discoveryv1.Endpoint{
{
Addresses: []string{"2001:db8::2"},
Conditions: discoveryv1.EndpointConditions{
Ready: ptr.To(false),
},
},
},
Ports: []discoveryv1.EndpointPort{
{Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)},
},
},
{
ObjectMeta: metav1.ObjectMeta{Name: "slice4"},
AddressType: discoveryv1.AddressTypeIPv6,
Endpoints: []discoveryv1.Endpoint{
{
Addresses: []string{"2001:db8::3"},
Conditions: discoveryv1.EndpointConditions{
Ready: ptr.To(false),
Serving: ptr.To(true),
Terminating: ptr.To(true),
},
},
},
Ports: []discoveryv1.EndpointPort{
{Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)},
},
},
{
ObjectMeta: metav1.ObjectMeta{Name: "slice5"},
AddressType: discoveryv1.AddressTypeIPv6,
Endpoints: []discoveryv1.Endpoint{
{
Addresses: []string{"2001:db8::4"},
Conditions: discoveryv1.EndpointConditions{
Ready: ptr.To(false),
Serving: ptr.To(false),
Terminating: ptr.To(true),
},
},
},
Ports: []discoveryv1.EndpointPort{
{Name: ptr.To("http"), Port: ptr.To(int32(80)), Protocol: ptr.To(corev1.ProtocolTCP)},
},
},
},
portName: "http",
portProtocol: corev1.ProtocolTCP,
expectedEndpoints: 3,
expectedEndpoints: 4,
expectedAddrType: ir.IP,
},
{
Expand Down Expand Up @@ -174,6 +224,8 @@ func TestGetIREndpointsFromEndpointSlices(t *testing.T) {
}

fmt.Println()
require.Len(t, endpoints, tt.expectedEndpoints)
require.Equal(t, tt.expectedAddrType, *addrType)
})
}
}
1 change: 1 addition & 0 deletions release-notes/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ new features: |
Added support for trusted CIDRs in the ClientIPDetectionSettings API
Added support for sending attributes to external processor in EnvoyExtensionPolicy API
Added support for patching EnvoyProxy.spec.provider.kubernetes.envoyHpa and EnvoyProxy.spec.provider.kubernetes.envoyPDB
Do not stop routing to endpoints until their graceful termination is complete, as indicated by their respective EndpointConditions

# Fixes for bugs identified in previous versions.
bug fixes: |
Expand Down