Skip to content

Detection of failed services during routing #4512

@pavel-jares-bcm

Description

@pavel-jares-bcm

There is a mechanism how to handle network issue during resending request to a service:

public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
return super.filter(exchange, chain).onErrorResume(e -> {
if (e.getCause() instanceof ConnectException) {
var uri = exchange.getRequest().getURI();
return Mono.error(new ServiceNotAccessibleException(String.format("Service is not available at %s://%s:%d", uri.getScheme(), uri.getHost(), uri.getPort()), e));
}
return Mono.error(e);
});
}

The aim is detect that service is down. In this case GW returns 503 which is ok. But the condition is too general and could include other communication issue. The issue is then log in exception handler:

@ExceptionHandler({ServiceNotAccessibleException.class, WebClientResponseException.ServiceUnavailable.class})
public Mono<Void> handleServiceNotAccessibleException(ServerWebExchange exchange, Exception ex) {
log.debug("A service is not available at the moment to finish request {}: {}", exchange.getRequest().getURI(), ex.getMessage());
return setBodyResponse(exchange, SC_SERVICE_UNAVAILABLE, "org.zowe.apiml.common.serviceUnavailable", exchange.getRequest().getPath());
}

It generates debug message like:

A service is not available at the moment to finish request https://<GW host>:<GW port>/<path>: Service is not available at https://<service host>:<service port>

It ignores the cause of the error. It is not helpful to understand the reason of failure.

The aim of this issue is:

  • provide beter debug message
  • decide what exception could be logged as 503 and what as 500
    • 503 should be only request where is missing the remote site
    • exception about certificate (PKIX, etc.) shouldn't end with 503

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Unplanned Bugs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions