georchestra / georchestra-gateway

GNU General Public License v3.0
0 stars 5 forks source link

Map connection exceptions to HTTP 503 status code instead of 500 #98

Closed groldan closed 7 months ago

groldan commented 7 months ago

In the event that a route exists and the downstream service is not available, usually the Gateway returns a 503 status code as expected.

On a dynamic environment though, such as k8s and docker compose, the underlying error results from a DNS lookup failure, and the default error is 500 instead.

A custom org.springframework.boot.web.reactive.error.ErrorAttributes is now used to override the DefaultErrorAttributes configured in ErrorWebFluxAutoConfiguration and injected to the ErrorWebExceptionHandler, and translates java.net.UnknownHostException and java.net.ConnectException to HttpStatus.SERVICE_UNAVAILABLE instead.