envoyproxy / java-control-plane

Java implementation of an Envoy gRPC control plane
Apache License 2.0
293 stars 136 forks source link

DiscoveryRequest validation and returning custom error response #104

Closed MarcinFalkowski closed 5 years ago

MarcinFalkowski commented 5 years ago

Sometimes we need to validate DiscoveryRequest (mostly node metadata). Currently we can do it in DiscoveryServerCallbacks.onStreamRequest, but there is no simple way to return custom error response. Throwing exception in that method will result in returning status UNKNOWN without any description.

It would be nice to return custom status with description what actually is wrong with the request. This way in Envoy logs we will see that description instead of enigmatic line: gRPC config stream closed: 2,.

I prepared a PR with implementation.