Skip to content

Commit

Permalink
feat: Adds alerts about configuration mismatch of proxy target subdom…
Browse files Browse the repository at this point in the history
…ain.

This is to ensure that we can quickly check the central configuration for errors on our end if the proxy URL does not match.

Also adds an alarm that generally indicates exceptions that occurred when retrieving the central configuration.

PR #529
  • Loading branch information
jekutzsche authored Jan 7, 2022
1 parent 1e19b7e commit 7327bf8
Showing 1 changed file with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.apache.commons.lang3.StringUtils.*;

import iris.client_bff.core.alert.AlertService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -30,6 +31,7 @@ public class CentralConfigurationService {
private final JsonRpcHttpClient epsRpcClient;
private final ProxyServiceProperties proxyProperties;
private final Environment env;
private final AlertService alerts;

private Configuration config;
private Instant lastFetch = Instant.MIN;
Expand Down Expand Up @@ -73,9 +75,22 @@ void checkValues() {
}

try {
if (!StringUtils.equals(proxyProperties.getTargetSubdomain(), getProxyUrl())) {

var proxyUrl = getProxyUrl();

if (!StringUtils.equals(proxyUrl, proxyProperties.getTargetSubdomain())) {

alerts.createAlertTicketAndMessage("Configuration mismatch of proxy target subdomain", String.format(
"""
The proxy target subdomain is configured different in this client (via environment variable) and in backend service (by the IRIS team)!
Client: %s
BS: %s
""",
proxyProperties.getTargetSubdomain(), proxyUrl));

throw new CentralConfigurationException(
"The proxy target subdomain is configured differend in this client (via environment variable) and in backend service (by the IRIS team)!");
"The proxy target subdomain is configured different in this client (via environment variable) and in backend service (by the IRIS team)!");
}
} catch (MissingCentralConfigurationException e) {

Expand Down Expand Up @@ -115,14 +130,20 @@ private Configuration fetchConfig() {
}

private Configuration handleException(Throwable e) {

if (ignoreConnectionErrors) {

log.debug("Ignore connection error of central connection service.");

return config;

} else {
throw new CentralConfigurationException("Can't fetch the central configuration from backend service!", e);

alerts.createAlertMessage("Fetch central configuration error", String.format(
"Can't fetch the central configuration from backend service. (Exception: %s)",
e.getClass().getCanonicalName()));

throw new CentralConfigurationException("Can't fetch the central configuration from backend service.", e);
}
}

Expand Down

0 comments on commit 7327bf8

Please sign in to comment.