Skip to content

Commit

Permalink
bgpv1: filter terminating backends from endpoint selection
Browse files Browse the repository at this point in the history
Filtering out backends which are terminating when creating local
endpoint state. This will result in quicker route withdrawal if local
backends go into terminating state, without waiting for graceful
shutdown period of the pods.

Signed-off-by: harsimran pabla <hpabla@isovalent.com>
  • Loading branch information
harsimran-pabla authored and julianwiedmann committed May 16, 2024
1 parent 913e41b commit 4aa6a7f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/bgpv1/manager/reconciler/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ endpointsLoop:
svcID := eps.ServiceID

for _, be := range eps.Backends {
if be.NodeName == localNodeName {
if !be.Terminating && be.NodeName == localNodeName {
// At least one endpoint is available on this node. We
// can make unavailable to available.
if _, found := ls[svcID]; !found {
Expand Down
30 changes: 30 additions & 0 deletions pkg/bgpv1/manager/reconciler/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,26 @@ func TestServiceReconcilerWithLoadBalancer(t *testing.T) {
},
}

eps1IPv4LocalTerminating := &k8s.Endpoints{
ObjectMeta: slim_metav1.ObjectMeta{
Name: "svc-1-ipv4",
Namespace: "default",
},
EndpointSliceID: k8s.EndpointSliceID{
ServiceID: k8s.ServiceID{
Name: "svc-1",
Namespace: "default",
},
EndpointSliceName: "svc-1-ipv4",
},
Backends: map[cmtypes.AddrCluster]*k8s.Backend{
cmtypes.MustParseAddrCluster("10.0.0.1"): {
NodeName: "node1",
Terminating: true,
},
},
}

eps1IPv4Remote := &k8s.Endpoints{
ObjectMeta: slim_metav1.ObjectMeta{
Name: "svc-1-ipv4",
Expand Down Expand Up @@ -448,6 +468,16 @@ func TestServiceReconcilerWithLoadBalancer(t *testing.T) {
upsertedEndpoints: []*k8s.Endpoints{},
updated: map[resource.Key][]string{},
},
// Service with terminating endpoint
{
name: "etp-local-terminating-endpoint",
oldServiceSelector: &blueSelector,
newServiceSelector: &blueSelector,
advertised: map[resource.Key][]string{},
upsertedServices: []*slim_corev1.Service{svc1ETPLocal},
upsertedEndpoints: []*k8s.Endpoints{eps1IPv4LocalTerminating},
updated: map[resource.Key][]string{},
},
// externalTrafficPolicy=Local && IPv4 && single slice && local endpoint
{
name: "etp-local-ipv4-single-slice-local",
Expand Down

0 comments on commit 4aa6a7f

Please sign in to comment.