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

Add Rate-Limit xDS config server related control plane functionality #598

Merged
merged 4 commits into from
Jan 27, 2023
Merged
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
1 change: 1 addition & 0 deletions pkg/cache/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ const (
Secret
Runtime
ExtensionConfig
RateLimitConfig
UnknownType // token to count the total number of supported types
)
7 changes: 7 additions & 0 deletions pkg/cache/v3/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
runtime "github.com/envoyproxy/go-control-plane/envoy/service/runtime/v3"
"github.com/envoyproxy/go-control-plane/pkg/cache/types"
"github.com/envoyproxy/go-control-plane/pkg/resource/v3"
ratelimit "github.com/envoyproxy/go-control-plane/ratelimit/config/ratelimit/v3"
)

// GetResponseType returns the enumeration for a valid xDS type URL.
Expand All @@ -53,6 +54,8 @@ func GetResponseType(typeURL resource.Type) types.ResponseType {
return types.Runtime
case resource.ExtensionConfigType:
return types.ExtensionConfig
case resource.RateLimitConfigType:
return types.RateLimitConfig
}
return types.UnknownType
}
Expand All @@ -78,6 +81,8 @@ func GetResponseTypeURL(responseType types.ResponseType) (string, error) {
return resource.RuntimeType, nil
case types.ExtensionConfig:
return resource.ExtensionConfigType, nil
case types.RateLimitConfig:
return resource.RateLimitConfigType, nil
default:
return "", fmt.Errorf("couldn't map response type %v to known resource type", responseType)
}
Expand All @@ -104,6 +109,8 @@ func GetResourceName(res types.Resource) string {
return v.GetName()
case *core.TypedExtensionConfig:
return v.GetName()
case *ratelimit.RateLimitConfig:
return v.GetName()
case types.ResourceWithName:
return v.GetName()
default:
Expand Down
3 changes: 3 additions & 0 deletions pkg/resource/v3/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const (
RuntimeType = APITypePrefix + "envoy.service.runtime.v3.Runtime"
ThriftRouteType = APITypePrefix + "envoy.extensions.filters.network.thrift_proxy.v3.RouteConfiguration"

// Rate Limit service
RateLimitConfigType = APITypePrefix + "ratelimit.config.ratelimit.v3.RateLimitConfig"
renuka-fernando marked this conversation as resolved.
Show resolved Hide resolved

// AnyType is used only by ADS
AnyType = ""
)
Expand Down
14 changes: 14 additions & 0 deletions pkg/server/v3/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
secretservice "github.com/envoyproxy/go-control-plane/envoy/service/secret/v3"
"github.com/envoyproxy/go-control-plane/pkg/cache/v3"
"github.com/envoyproxy/go-control-plane/pkg/resource/v3"
rlsconfigservice "github.com/envoyproxy/go-control-plane/ratelimit/service/ratelimit/v3"
)

// Server is a collection of handlers for streaming discovery requests.
Expand All @@ -52,6 +53,7 @@ type Server interface {
secretservice.SecretDiscoveryServiceServer
runtimeservice.RuntimeDiscoveryServiceServer
extensionconfigservice.ExtensionConfigDiscoveryServiceServer
rlsconfigservice.RateLimitConfigDiscoveryServiceServer

rest.Server
sotw.Server
Expand Down Expand Up @@ -220,6 +222,10 @@ func (s *server) StreamExtensionConfigs(stream extensionconfigservice.ExtensionC
return s.StreamHandler(stream, resource.ExtensionConfigType)
}

func (s *server) StreamRlsConfigs(stream rlsconfigservice.RateLimitConfigDiscoveryService_StreamRlsConfigsServer) error {
alecholmez marked this conversation as resolved.
Show resolved Hide resolved
return s.StreamHandler(stream, resource.RateLimitConfigType)
}

// VHDS doesn't support SOTW requests, so no handler for it exists.

// Fetch is the universal fetch method.
Expand Down Expand Up @@ -291,6 +297,14 @@ func (s *server) FetchExtensionConfigs(ctx context.Context, req *discovery.Disco
return s.Fetch(ctx, req)
}

func (s *server) FetchRlsConfigs(ctx context.Context, req *discovery.DiscoveryRequest) (*discovery.DiscoveryResponse, error) {
if req == nil {
return nil, status.Errorf(codes.Unavailable, "empty request")
}
req.TypeUrl = resource.RateLimitConfigType
return s.Fetch(ctx, req)
}

// VHDS doesn't support REST requests, so no handler exists for this.

func (s *server) DeltaStreamHandler(stream stream.DeltaStream, typeURL string) error {
Expand Down
Loading