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

write more detail log if forwarding to storage fails #599

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.slf4j.LoggerFactory;
import org.swisspush.gateleen.core.configuration.ConfigurationResourceManager;
import org.swisspush.gateleen.core.configuration.ConfigurationResourceObserver;
import org.swisspush.gateleen.core.exception.GateleenExceptionFactory;
import org.swisspush.gateleen.core.http.HttpClientFactory;
import org.swisspush.gateleen.core.http.RequestLoggerFactory;
import org.swisspush.gateleen.core.logging.LoggableResource;
Expand Down Expand Up @@ -85,6 +86,8 @@ public class Router implements Refreshable, LoggableResource, ConfigurationResou
private OAuthStrategy oAuthStrategy = null;
private BasicAuthStrategy basicAuthStrategy;

private static GateleenExceptionFactory gateleenExceptionFactory = GateleenExceptionFactory.newGateleenThriftyExceptionFactory();
dominik-cnx marked this conversation as resolved.
Show resolved Hide resolved

/**
* The multiplier applied to routes, typically the number of {@link Router} instances in a cluster.
*/
Expand Down Expand Up @@ -324,7 +327,7 @@ private void createForwarders(List<Rule> rules, io.vertx.ext.web.Router newRoute
vertx.eventBus());
} else if (rule.getStorage() != null) {
forwarder = new StorageForwarder(vertx.eventBus(), rule, loggingResourceManager, logAppenderRepository,
monitoringHandler);
monitoringHandler, gateleenExceptionFactory);
} else if (rule.getScheme().equals("local")) {
forwarder = new Forwarder(vertx, selfClient, rule, this.storage, loggingResourceManager, logAppenderRepository,
monitoringHandler, userProfileUri, authStrategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.vertx.ext.web.RoutingContext;
import org.slf4j.Logger;
import org.swisspush.gateleen.core.cors.CORSHandler;
import org.swisspush.gateleen.core.exception.GateleenExceptionFactory;
import org.swisspush.gateleen.core.http.HeaderFunctions;
import org.swisspush.gateleen.core.http.HttpRequest;
import org.swisspush.gateleen.core.http.RequestLoggerFactory;
Expand All @@ -40,13 +41,17 @@ public class StorageForwarder extends AbstractForwarder {
private Pattern urlPattern;
private String address;
private CORSHandler corsHandler;
private GateleenExceptionFactory gateleenExceptionFactory;

public StorageForwarder(EventBus eventBus, Rule rule, LoggingResourceManager loggingResourceManager, LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler) {
public StorageForwarder(EventBus eventBus, Rule rule, LoggingResourceManager loggingResourceManager,
LogAppenderRepository logAppenderRepository, MonitoringHandler monitoringHandler,
GateleenExceptionFactory gateleenExceptionFactory) {
super(rule, loggingResourceManager, logAppenderRepository, monitoringHandler);
this.eventBus = eventBus;
this.address = Address.storageAddress() + "-" + rule.getStorage();
urlPattern = Pattern.compile(rule.getUrlPattern());
corsHandler = new CORSHandler();
this.gateleenExceptionFactory = gateleenExceptionFactory;
}

@Override
Expand Down Expand Up @@ -97,7 +102,7 @@ public void handle(final RoutingContext ctx) {
response.setStatusCode(StatusCode.INTERNAL_SERVER_ERROR.getStatusCode());
response.setStatusMessage(statusMessage);
response.end();
log.error("Storage request failed", result.cause());
log.error(statusMessage, gateleenExceptionFactory.newException(result.cause()));
} else {
Buffer buffer = result.result().body();
int headerLength = buffer.getInt(0);
Expand Down
Loading