Skip to content

Commit 6aa220b

Browse files
committed
xds: add LEDS (Locality Endpoint Discovery Service) support
Wire up the LocalityEndpointDiscoveryService which allows discovering LbEndpoint resources via delta xDS, as an alternative to inlining endpoints in the EDS ClusterLoadAssignment response. Signed-off-by: William Dauchy <william.dauchy@datadoghq.com>
1 parent bf47e54 commit 6aa220b

File tree

6 files changed

+16
-0
lines changed

6 files changed

+16
-0
lines changed

internal/example/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func (s *Server) registerServer(grpcServer *grpc.Server) {
5656
// register services
5757
discoverygrpc.RegisterAggregatedDiscoveryServiceServer(grpcServer, s.xdsserver)
5858
endpointservice.RegisterEndpointDiscoveryServiceServer(grpcServer, s.xdsserver)
59+
endpointservice.RegisterLocalityEndpointDiscoveryServiceServer(grpcServer, s.xdsserver)
5960
clusterservice.RegisterClusterDiscoveryServiceServer(grpcServer, s.xdsserver)
6061
routeservice.RegisterRouteDiscoveryServiceServer(grpcServer, s.xdsserver)
6162
listenerservice.RegisterListenerDiscoveryServiceServer(grpcServer, s.xdsserver)
@@ -99,6 +100,7 @@ func registerServer(grpcServer *grpc.Server, server server.Server) {
99100
// register services
100101
discoverygrpc.RegisterAggregatedDiscoveryServiceServer(grpcServer, server)
101102
endpointservice.RegisterEndpointDiscoveryServiceServer(grpcServer, server)
103+
endpointservice.RegisterLocalityEndpointDiscoveryServiceServer(grpcServer, server)
102104
clusterservice.RegisterClusterDiscoveryServiceServer(grpcServer, server)
103105
routeservice.RegisterRouteDiscoveryServiceServer(grpcServer, server)
104106
listenerservice.RegisterListenerDiscoveryServiceServer(grpcServer, server)

pkg/cache/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type ResponseType int
3737
const (
3838
Cluster ResponseType = iota
3939
Endpoint
40+
LbEndpoint
4041
Listener
4142
Route
4243
ScopedRoute

pkg/cache/v3/resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ func GetResponseType(typeURL resource.Type) types.ResponseType {
5050
return types.ExtensionConfig
5151
case resource.RateLimitConfigType:
5252
return types.RateLimitConfig
53+
case resource.LbEndpointType:
54+
return types.LbEndpoint
5355
}
5456
return types.UnknownType
5557
}
@@ -77,6 +79,8 @@ func GetResponseTypeURL(responseType types.ResponseType) (string, error) {
7779
return resource.ExtensionConfigType, nil
7880
case types.RateLimitConfig:
7981
return resource.RateLimitConfigType, nil
82+
case types.LbEndpoint:
83+
return resource.LbEndpointType, nil
8084
default:
8185
return "", fmt.Errorf("couldn't map response type %v to known resource type", responseType)
8286
}

pkg/resource/v3/resource.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const (
2929
// Rate Limit service
3030
RateLimitConfigType = APITypePrefix + "ratelimit.config.ratelimit.v3.RateLimitConfig"
3131

32+
// LEDS
33+
LbEndpointType = APITypePrefix + "envoy.config.endpoint.v3.LbEndpoint"
34+
3235
// AnyType is used only by ADS
3336
AnyType = ""
3437
)

pkg/server/v3/server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444
// Server is a collection of handlers for streaming discovery requests.
4545
type Server interface {
4646
endpointservice.EndpointDiscoveryServiceServer
47+
endpointservice.LocalityEndpointDiscoveryServiceServer
4748
clusterservice.ClusterDiscoveryServiceServer
4849
routeservice.RouteDiscoveryServiceServer
4950
routeservice.ScopedRoutesDiscoveryServiceServer
@@ -350,3 +351,7 @@ func (s *server) DeltaExtensionConfigs(stream extensionconfigservice.ExtensionCo
350351
func (s *server) DeltaVirtualHosts(stream routeservice.VirtualHostDiscoveryService_DeltaVirtualHostsServer) error {
351352
return s.DeltaStreamHandler(stream, resource.VirtualHostType)
352353
}
354+
355+
func (s *server) DeltaLocalityEndpoints(stream endpointservice.LocalityEndpointDiscoveryService_DeltaLocalityEndpointsServer) error {
356+
return s.DeltaStreamHandler(stream, resource.LbEndpointType)
357+
}

pkg/test/v3/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ func RegisterServer(grpcServer *grpc.Server, server server.Server) {
4646
listenerservice.RegisterListenerDiscoveryServiceServer(grpcServer, server)
4747
secretservice.RegisterSecretDiscoveryServiceServer(grpcServer, server)
4848
runtimeservice.RegisterRuntimeDiscoveryServiceServer(grpcServer, server)
49+
endpointservice.RegisterLocalityEndpointDiscoveryServiceServer(grpcServer, server)
4950
}

0 commit comments

Comments
 (0)