From d2c906ff248ef5a893029ef35db464651fbacc7d Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Mon, 11 Mar 2024 15:36:56 +0100 Subject: [PATCH 01/16] bug5973: added mongoDbReplicaSetNodes section to /gwt/status output --- .../sailing/gwt/ui/server/StatusServlet.java | 21 +++++++++++++++++++ .../com/sap/sse/mongodb/MongoDBService.java | 2 ++ .../mongodb/internal/MongoDBServiceImpl.java | 12 ++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java index 6178c5b3a54..506f15fafbd 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java @@ -10,13 +10,17 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.core.MediaType; +import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.ParseException; import org.osgi.framework.BundleContext; import org.osgi.util.tracker.ServiceTracker; +import com.mongodb.connection.ClusterDescription; +import com.mongodb.connection.ServerDescription; import com.sap.sailing.server.interfaces.RacingEventService; import com.sap.sse.ServerInfo; +import com.sap.sse.mongodb.MongoDBService; import com.sap.sse.replication.ReplicationService; import com.sap.sse.replication.ReplicationStatus; @@ -62,6 +66,7 @@ public class StatusServlet extends HttpServlet { result.put("numberofracesrestoreddoneloading", numberOfTrackedRacesRestoredDoneLoading); final int numberOfTrackedRacesStillLoading = service.getNumberOfTrackedRacesStillLoading(); result.put("numberofracesstillloading", numberOfTrackedRacesStillLoading); + result.put("mongoDbReplicaSetNodes", getMongoDBReplicaSetNodes()); final ReplicationService replicationService = getReplicationService(servletContext); final ReplicationStatus replicationStatus = replicationService == null ? null : replicationService.getStatus(); if (replicationStatus != null) { @@ -82,4 +87,20 @@ public class StatusServlet extends HttpServlet { throw new RuntimeException(e); } } + + private JSONObject getMongoDBReplicaSetNodes() { + final JSONObject result = new JSONObject(); + final ClusterDescription clusterDescription = MongoDBService.INSTANCE.getMongoClient().getClusterDescription(); + result.put("connectionMode", clusterDescription.getConnectionMode().name()); + result.put("replicaSet", clusterDescription.getClusterSettings().getRequiredReplicaSetName()); + final JSONArray servers = new JSONArray(); + for (final ServerDescription serverDescription : clusterDescription.getServerDescriptions()) { + final JSONObject serverHostAndPort = new JSONObject(); + serverHostAndPort.put("host", serverDescription.getAddress().getHost()); + serverHostAndPort.put("port", serverDescription.getAddress().getPort()); + servers.add(serverHostAndPort); + } + result.put("servers", servers); + return result; + } } diff --git a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java index 663c2aa6509..61156ac5b73 100644 --- a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java +++ b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java @@ -51,4 +51,6 @@ public interface MongoDBService { ClientSession startAutoRefreshingSession(); ClientSession startCausallyConsistentSession(); + + MongoClient getMongoClient(); } diff --git a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java index b54af5ba58f..3b37f55c870 100644 --- a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java +++ b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java @@ -138,10 +138,20 @@ public class MongoDBServiceImpl implements MongoDBService { private MongoClient getMongo(MongoDBConfiguration mongoDBConfiguration) { MongoClient mongo = mongos.computeIfAbsent(mongoDBConfiguration.getMongoClientURI(), - k-> MongoClients.create(mongoDBConfiguration.getMongoClientURI())); + k-> getMongoClient(mongoDBConfiguration)); return mongo; } + @Override + public MongoClient getMongoClient() { + ensureConfigurationDefaultingToTest(); + return getMongoClient(configuration); + } + + private MongoClient getMongoClient(MongoDBConfiguration mongoDBConfiguration) { + return MongoClients.create(mongoDBConfiguration.getMongoClientURI()); + } + @Override public void registerExclusively(Class registerForInterface, String collectionName) throws AlreadyRegisteredException { From 6c61d01ae01c08f0670cd6ef18c183503caafb95 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Mon, 11 Mar 2024 16:34:57 +0100 Subject: [PATCH 02/16] bug5973: for SailingAnalyticsProcess obtain current DB config from /gwt/status --- .../sailing/gwt/ui/server/StatusServlet.java | 3 +- .../landscape/SailingAnalyticsProcess.java | 1 - .../impl/SailingAnalyticsProcessImpl.java | 11 ++++ .../sap/sse/landscape/aws/MongoUriParser.java | 60 +++++++++++++++++-- .../aws/impl/AwsApplicationProcessImpl.java | 4 ++ .../com/sap/sse/mongodb/MongoDBService.java | 3 + .../mongodb/internal/MongoDBServiceImpl.java | 6 ++ 7 files changed, 81 insertions(+), 7 deletions(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java index 506f15fafbd..fc84b09e01c 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java @@ -66,7 +66,7 @@ public class StatusServlet extends HttpServlet { result.put("numberofracesrestoreddoneloading", numberOfTrackedRacesRestoredDoneLoading); final int numberOfTrackedRacesStillLoading = service.getNumberOfTrackedRacesStillLoading(); result.put("numberofracesstillloading", numberOfTrackedRacesStillLoading); - result.put("mongoDbReplicaSetNodes", getMongoDBReplicaSetNodes()); + result.put("mongoDbConfiguration", getMongoDBReplicaSetNodes()); final ReplicationService replicationService = getReplicationService(servletContext); final ReplicationStatus replicationStatus = replicationService == null ? null : replicationService.getStatus(); if (replicationStatus != null) { @@ -93,6 +93,7 @@ public class StatusServlet extends HttpServlet { final ClusterDescription clusterDescription = MongoDBService.INSTANCE.getMongoClient().getClusterDescription(); result.put("connectionMode", clusterDescription.getConnectionMode().name()); result.put("replicaSet", clusterDescription.getClusterSettings().getRequiredReplicaSetName()); + result.put("database", MongoDBService.INSTANCE.getMongoClientURI().getDatabase()); final JSONArray servers = new JSONArray(); for (final ServerDescription serverDescription : clusterDescription.getServerDescriptions()) { final JSONObject serverHostAndPort = new JSONObject(); diff --git a/java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/SailingAnalyticsProcess.java b/java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/SailingAnalyticsProcess.java index c0604667e9b..8620104386e 100755 --- a/java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/SailingAnalyticsProcess.java +++ b/java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/SailingAnalyticsProcess.java @@ -25,5 +25,4 @@ public interface SailingAnalyticsProcess extends AwsApplicationProc */ void refreshToRelease(Release release, Optional optionalKeyName, byte[] privateKeyEncryptionPassphrase) throws IOException, InterruptedException, JSchException, Exception; - } diff --git a/java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/impl/SailingAnalyticsProcessImpl.java b/java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/impl/SailingAnalyticsProcessImpl.java index 8b8a2c64f91..17e370c4b8c 100755 --- a/java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/impl/SailingAnalyticsProcessImpl.java +++ b/java/com.sap.sailing.landscape/src/com/sap/sailing/landscape/impl/SailingAnalyticsProcessImpl.java @@ -31,12 +31,15 @@ import com.sap.sse.common.Duration; import com.sap.sse.common.TimePoint; import com.sap.sse.common.Util; import com.sap.sse.landscape.Landscape; +import com.sap.sse.landscape.Region; import com.sap.sse.landscape.Release; import com.sap.sse.landscape.ReleaseRepository; import com.sap.sse.landscape.aws.ApplicationProcessHost; import com.sap.sse.landscape.aws.AwsLandscape; +import com.sap.sse.landscape.aws.MongoUriParser; import com.sap.sse.landscape.aws.impl.AwsApplicationProcessImpl; import com.sap.sse.landscape.impl.ReleaseImpl; +import com.sap.sse.landscape.mongodb.Database; import com.sap.sse.shared.util.Wait; import com.sap.sse.util.HttpUrlConnectionHelper; import com.sap.sse.util.LaxRedirectStrategyForAllRedirectResponseCodes; @@ -48,6 +51,7 @@ implements SailingAnalyticsProcess { private static final String STATUS_SERVERNAME_PROPERTY_NAME = "servername"; private static final String STATUS_SERVERDIRECTORY_PROPERTY_NAME = "serverdirectory"; private static final String STATUS_RELEASE_PROPERTY_NAME = "release"; + private static final String MONGODB_CONFIGURATION_PROPERTY_NAME = "mongoDbConfiguration"; private Integer expeditionUdpPort; private Release release; private TimePoint startTimePoint; @@ -115,6 +119,13 @@ implements SailingAnalyticsProcess { return release; } + @Override + public Database getDatabaseConfiguration(Region region, Optional optionalTimeout, + Optional optionalKeyName, byte[] privateKeyEncryptionPassphrase) throws Exception { + final JSONObject mongoDBConfiguration = (JSONObject) getStatus(optionalTimeout).get(MONGODB_CONFIGURATION_PROPERTY_NAME); + return new MongoUriParser(getLandscape(), region).parseMongoDBConfigurationFromStatus(mongoDBConfiguration); + } + private void updateServerNameFromStatus(JSONObject status) { serverName = status.get(STATUS_SERVERNAME_PROPERTY_NAME).toString(); } diff --git a/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/MongoUriParser.java b/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/MongoUriParser.java index 8af7fe75d60..9422da69a1f 100755 --- a/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/MongoUriParser.java +++ b/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/MongoUriParser.java @@ -4,6 +4,11 @@ import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; import com.sap.sse.common.Util; import com.sap.sse.common.Util.Pair; @@ -25,7 +30,7 @@ import com.sap.sse.landscape.mongodb.impl.MongoReplicaSetImpl; * by the {value} of the {@code "replicaSet"} parameter; otherwise the result is a {@link MongoProcess}. */ public class MongoUriParser { - private final String SCHEME = "mongodb"; + private final static String SCHEME = "mongodb"; private final AwsLandscape landscape; private final Region region; @@ -70,10 +75,42 @@ public class MongoUriParser { } return endpoint == null ? null : endpoint.getDatabase(dbName); } + + public Database parseMongoDBConfigurationFromStatus(JSONObject mongoDBConfigurationJSON) throws UnknownHostException { + final String databaseName = mongoDBConfigurationJSON.get("database").toString(); + final String replicaSetName = mongoDBConfigurationJSON.get("replicaSet").toString(); + final MongoEndpoint endpoint; + final List, Integer>> hostnamesAndPorts = new ArrayList<>(); + final JSONArray serversJSON = (JSONArray) mongoDBConfigurationJSON.get("servers"); + for (final Object serverObject : serversJSON) { + final JSONObject serverJSON = (JSONObject) serverObject; + final String hostname = serverJSON.get("host").toString(); + final int port = ((Number) serverJSON.get("port")).intValue(); + hostnamesAndPorts.add(getHostAndPort(hostname, port)); + } + if (replicaSetName != null) { + MongoReplicaSet replicaSet = new MongoReplicaSetImpl(replicaSetName); + for (final Pair, Integer> hostnameAndPort : hostnamesAndPorts) { + final MongoProcessInReplicaSet mongoProcessInReplicaSet = getMongoProcessInReplicaSet(replicaSet, hostnameAndPort); + if (mongoProcessInReplicaSet != null) { + replicaSet.addReplica(mongoProcessInReplicaSet); + } + } + endpoint = replicaSet; + } else { + endpoint = getMongoProcess(hostnamesAndPorts.get(0)); + } + return endpoint == null ? null : endpoint.getDatabase(databaseName); + + } private MongoEndpoint getMongoProcess(final String hostnameAndOptionalPort) throws UnknownHostException { - final MongoEndpoint endpoint; Pair, Integer> hostAndOptionalPort = getHostAndPort(hostnameAndOptionalPort); + return getMongoProcess(hostAndOptionalPort); + } + + private MongoEndpoint getMongoProcess(Pair, Integer> hostAndOptionalPort) { + final MongoEndpoint endpoint; if (hostAndOptionalPort.getA() != null) { if (hostAndOptionalPort.getB() != null) { endpoint = new MongoProcessImpl(hostAndOptionalPort.getA(), hostAndOptionalPort.getB()); @@ -87,8 +124,12 @@ public class MongoUriParser { } private MongoProcessInReplicaSet getMongoProcessInReplicaSet(final MongoReplicaSet replicaSet, final String hostnameAndOptionalPort) throws UnknownHostException { - final MongoProcessInReplicaSet endpoint; Pair, Integer> hostAndOptionalPort = getHostAndPort(hostnameAndOptionalPort); + return getMongoProcessInReplicaSet(replicaSet, hostAndOptionalPort); + } + + private MongoProcessInReplicaSet getMongoProcessInReplicaSet(final MongoReplicaSet replicaSet, Pair, Integer> hostAndOptionalPort) { + final MongoProcessInReplicaSet endpoint; if (hostAndOptionalPort.getA() != null) { if (hostAndOptionalPort.getB() != null) { endpoint = new MongoProcessInReplicaSetImpl(replicaSet, hostAndOptionalPort.getB(), hostAndOptionalPort.getA()); @@ -106,8 +147,17 @@ public class MongoUriParser { */ private Pair, Integer> getHostAndPort(String hostnameAndOptionalPort) throws UnknownHostException { final String[] hostnameAndOptionalPortSplit = hostnameAndOptionalPort.split(":"); - final InetAddress address = InetAddress.getByName(hostnameAndOptionalPortSplit[0]); + final String hostname = hostnameAndOptionalPortSplit[0]; + final Integer port = hostnameAndOptionalPortSplit.length<2?null:Integer.valueOf(hostnameAndOptionalPortSplit[1]); + return getHostAndPort(hostname, port); + } + + /** + * If the host isn't found in the landscape, the {@link Pair#getA()} component of the pair returned will be {@code null}. + */ + private Pair, Integer> getHostAndPort(String hostname, Integer optionalPort) throws UnknownHostException { + final InetAddress address = InetAddress.getByName(hostname); final AwsInstance hostByPrivateIp = landscape.getHostByPrivateIpAddress(region, address.getHostAddress(), AwsInstanceImpl::new); - return new Pair<>(hostByPrivateIp, hostnameAndOptionalPortSplit.length<2?null:Integer.valueOf(hostnameAndOptionalPortSplit[1])); + return new Pair<>(hostByPrivateIp, optionalPort); } } diff --git a/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/impl/AwsApplicationProcessImpl.java b/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/impl/AwsApplicationProcessImpl.java index 74c1de2c09d..c99f15d6b70 100755 --- a/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/impl/AwsApplicationProcessImpl.java +++ b/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/impl/AwsApplicationProcessImpl.java @@ -50,6 +50,10 @@ implements AwsApplicationProcess { this.landscape = landscape; } + protected AwsLandscape getLandscape() { + return landscape; + } + @Override public AwsInstance getHost() { @SuppressWarnings("unchecked") diff --git a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java index 61156ac5b73..af035ec1212 100644 --- a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java +++ b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java @@ -2,6 +2,7 @@ package com.sap.sse.mongodb; import java.lang.ref.WeakReference; +import com.mongodb.ConnectionString; import com.mongodb.client.ClientSession; import com.mongodb.client.MongoClient; import com.mongodb.client.MongoDatabase; @@ -53,4 +54,6 @@ public interface MongoDBService { ClientSession startCausallyConsistentSession(); MongoClient getMongoClient(); + + ConnectionString getMongoClientURI(); } diff --git a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java index 3b37f55c870..9140b37c4a9 100644 --- a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java +++ b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java @@ -142,6 +142,12 @@ public class MongoDBServiceImpl implements MongoDBService { return mongo; } + @Override + public ConnectionString getMongoClientURI() { + ensureConfigurationDefaultingToTest(); + return configuration.getMongoClientURI(); + } + @Override public MongoClient getMongoClient() { ensureConfigurationDefaultingToTest(); From a507601a0faa1f3636d179878cdf3070fef2319e Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Tue, 12 Mar 2024 10:03:30 +0100 Subject: [PATCH 03/16] bug5973: share MongoClients with equal ConnectionString throughout --- java/com.sap.sse.landscape/META-INF/MANIFEST.MF | 1 + .../landscape/mongodb/impl/MongoEndpointImpl.java | 6 +++--- .../src/com/sap/sse/mongodb/MongoDBService.java | 2 ++ .../sse/mongodb/internal/MongoDBServiceImpl.java | 15 ++++++++------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/java/com.sap.sse.landscape/META-INF/MANIFEST.MF b/java/com.sap.sse.landscape/META-INF/MANIFEST.MF index 445028a0521..a84930e07ec 100755 --- a/java/com.sap.sse.landscape/META-INF/MANIFEST.MF +++ b/java/com.sap.sse.landscape/META-INF/MANIFEST.MF @@ -32,3 +32,4 @@ Require-Bundle: com.sap.sse.common, org.mongodb.driver-core;bundle-version="4.3.1", org.mongodb.driver-sync;bundle-version="4.3.1" Bundle-ActivationPolicy: lazy +Import-Package: com.sap.sse.mongodb diff --git a/java/com.sap.sse.landscape/src/com/sap/sse/landscape/mongodb/impl/MongoEndpointImpl.java b/java/com.sap.sse.landscape/src/com/sap/sse/landscape/mongodb/impl/MongoEndpointImpl.java index 4680189b34b..b672486570c 100755 --- a/java/com.sap.sse.landscape/src/com/sap/sse/landscape/mongodb/impl/MongoEndpointImpl.java +++ b/java/com.sap.sse.landscape/src/com/sap/sse/landscape/mongodb/impl/MongoEndpointImpl.java @@ -11,7 +11,6 @@ import org.bson.Document; import com.mongodb.ClientSessionOptions; import com.mongodb.ConnectionString; import com.mongodb.client.MongoClient; -import com.mongodb.client.MongoClients; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; import com.mongodb.connection.ClusterConnectionMode; @@ -20,6 +19,7 @@ import com.sap.sse.common.Duration; import com.sap.sse.common.Util; import com.sap.sse.landscape.mongodb.Database; import com.sap.sse.landscape.mongodb.MongoEndpoint; +import com.sap.sse.mongodb.MongoDBService; public abstract class MongoEndpointImpl implements MongoEndpoint { private static final Logger logger = Logger.getLogger(MongoEndpointImpl.class.getName()); @@ -86,12 +86,12 @@ public abstract class MongoEndpointImpl implements MongoEndpoint { @Override public MongoClient getClient() throws URISyntaxException { - return MongoClients.create(getConnectionString(Optional.empty())); + return MongoDBService.INSTANCE.getMongo(getConnectionString(Optional.empty())); } @Override public MongoClient getClient(Optional timeoutEmptyMeaningForever) throws URISyntaxException { - return MongoClients.create(getConnectionString(Optional.empty(), timeoutEmptyMeaningForever)); + return MongoDBService.INSTANCE.getMongo(getConnectionString(Optional.empty(), timeoutEmptyMeaningForever)); } @Override diff --git a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java index af035ec1212..430a53d2909 100644 --- a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java +++ b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/MongoDBService.java @@ -56,4 +56,6 @@ public interface MongoDBService { MongoClient getMongoClient(); ConnectionString getMongoClientURI(); + + MongoClient getMongo(ConnectionString mongoConnectionString); } diff --git a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java index 9140b37c4a9..8e66cb0de1d 100644 --- a/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java +++ b/java/com.sap.sse.mongodb/src/com/sap/sse/mongodb/internal/MongoDBServiceImpl.java @@ -137,8 +137,13 @@ public class MongoDBServiceImpl implements MongoDBService { } private MongoClient getMongo(MongoDBConfiguration mongoDBConfiguration) { - MongoClient mongo = mongos.computeIfAbsent(mongoDBConfiguration.getMongoClientURI(), - k-> getMongoClient(mongoDBConfiguration)); + return getMongo(mongoDBConfiguration.getMongoClientURI()); + } + + @Override + public MongoClient getMongo(ConnectionString mongoConnectionString) { + MongoClient mongo = mongos.computeIfAbsent(mongoConnectionString, + k-> MongoClients.create(mongoConnectionString)); return mongo; } @@ -151,13 +156,9 @@ public class MongoDBServiceImpl implements MongoDBService { @Override public MongoClient getMongoClient() { ensureConfigurationDefaultingToTest(); - return getMongoClient(configuration); + return getMongo(getConfiguration()); } - private MongoClient getMongoClient(MongoDBConfiguration mongoDBConfiguration) { - return MongoClients.create(mongoDBConfiguration.getMongoClientURI()); - } - @Override public void registerExclusively(Class registerForInterface, String collectionName) throws AlreadyRegisteredException { From a7c047b8a2b9ba267c70505ba29b6585f78365ad Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Tue, 12 Mar 2024 10:33:46 +0100 Subject: [PATCH 04/16] b5969: Add instance types to landscape constants. --- .../com/sap/sse/landscape/aws/LandscapeConstants.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/LandscapeConstants.java b/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/LandscapeConstants.java index 6e78d84c19c..df852164aa4 100644 --- a/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/LandscapeConstants.java +++ b/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/LandscapeConstants.java @@ -1,5 +1,7 @@ package com.sap.sse.landscape.aws; +import software.amazon.awssdk.services.ec2.model.InstanceType; + public interface LandscapeConstants { /** * The key tag, indicating that an instance only acts as a reverse proxy @@ -58,4 +60,11 @@ public interface LandscapeConstants { * The tag for the central reverse proxy, which also hosts non-essential services. */ String CENTRAL_REVERSE_PROXY_TAG_NAME = "CentralReverseProxy"; + + InstanceType[] instanceTypesBannedFromInstanceBasedTargetGroups = new InstanceType[] { InstanceType.CC1_4_XLARGE, InstanceType.C1_MEDIUM, InstanceType.C1_XLARGE, + InstanceType.CC2_8_XLARGE, InstanceType.CG1_4_XLARGE, InstanceType.CR1_8_XLARGE, InstanceType.G2_2_XLARGE, + InstanceType.G2_8_XLARGE, InstanceType.HI1_4_XLARGE, InstanceType.HS1_8_XLARGE, InstanceType.M1_LARGE, + InstanceType.M1_MEDIUM, InstanceType.M1_SMALL, InstanceType.M1_XLARGE, InstanceType.M2_2_XLARGE, + InstanceType.M2_4_XLARGE, InstanceType.M2_XLARGE, InstanceType.M3_2_XLARGE, InstanceType.M3_LARGE, + InstanceType.M3_MEDIUM, InstanceType.M3_XLARGE, InstanceType.T1_MICRO }; } From 7d89e77d1b32be89eec01e0990452cc51c85cccc Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Tue, 12 Mar 2024 14:41:53 +0100 Subject: [PATCH 05/16] bug5973: added MongoDB server type to /gwt/status output --- .../main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java index fc84b09e01c..883ed6c814a 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/StatusServlet.java @@ -99,6 +99,7 @@ public class StatusServlet extends HttpServlet { final JSONObject serverHostAndPort = new JSONObject(); serverHostAndPort.put("host", serverDescription.getAddress().getHost()); serverHostAndPort.put("port", serverDescription.getAddress().getPort()); + serverHostAndPort.put("type", serverDescription.getType().name()); servers.add(serverHostAndPort); } result.put("servers", servers); From d6217970fcbba8a92aeb8419070e7936b5c345f3 Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Tue, 12 Mar 2024 16:56:57 +0100 Subject: [PATCH 06/16] b5969: Filter instance types using new method parameter. --- .../ChangeAutoScalingReplicaInstanceTypeDialog.java | 2 +- .../ui/client/CreateApplicationReplicaSetDialog.java | 4 ++-- .../ui/client/CreateReverseProxyInClusterDialog.java | 2 +- .../landscape/ui/client/LandscapeDialogUtil.java | 11 +++++++---- .../ui/client/LandscapeManagementWriteService.java | 2 +- .../client/LandscapeManagementWriteServiceAsync.java | 2 +- .../landscape/ui/client/MongoScalingDialog.java | 2 +- .../ui/client/MoveAllAwayFromHostDialog.java | 2 +- .../landscape/ui/client/MoveMasterProcessDialog.java | 2 +- .../client/SwitchToReplicaOnSharedInstanceDialog.java | 2 +- .../server/LandscapeManagementWriteServiceImpl.java | 5 ++++- .../com/sap/sse/landscape/aws/LandscapeConstants.java | 4 ++-- 12 files changed, 23 insertions(+), 17 deletions(-) diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/ChangeAutoScalingReplicaInstanceTypeDialog.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/ChangeAutoScalingReplicaInstanceTypeDialog.java index 72deeebd9bd..f1464db409a 100644 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/ChangeAutoScalingReplicaInstanceTypeDialog.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/ChangeAutoScalingReplicaInstanceTypeDialog.java @@ -24,7 +24,7 @@ public class ChangeAutoScalingReplicaInstanceTypeDialog extends DataEntryDialog< super(stringMessages.moveMasterToOtherInstance(), /* message */ null, stringMessages.ok(), stringMessages.cancel(), /* validator */ null, callback); this.stringMessages = stringMessages; instanceTypeListBox = LandscapeDialogUtil.createInstanceTypeListBox(this, landscapeManagementService, - stringMessages, SharedLandscapeConstants.DEFAULT_DEDICATED_INSTANCE_TYPE_NAME, errorReporter); + stringMessages, SharedLandscapeConstants.DEFAULT_DEDICATED_INSTANCE_TYPE_NAME, errorReporter, /* canBeDeployedInNlbInstanceBasedTargetGroup */ false); } @Override diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/CreateApplicationReplicaSetDialog.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/CreateApplicationReplicaSetDialog.java index 16ed1ae1e73..c8240033bf6 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/CreateApplicationReplicaSetDialog.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/CreateApplicationReplicaSetDialog.java @@ -193,10 +193,10 @@ public class CreateApplicationReplicaSetDialog extends AbstractApplicationReplic dynamicLoadBalancerCheckBox = mayUseDynamicLoadBalancer ? createCheckbox(stringMessages.useDynamicLoadBalancer()) : null; domainNameBox = createTextBox(SharedLandscapeConstants.DEFAULT_DOMAIN_NAME, 40); dedicatedInstanceTypeListBox = LandscapeDialogUtil.createInstanceTypeListBox(this, landscapeManagementService, - stringMessages, SharedLandscapeConstants.DEFAULT_DEDICATED_INSTANCE_TYPE_NAME, errorReporter); + stringMessages, SharedLandscapeConstants.DEFAULT_DEDICATED_INSTANCE_TYPE_NAME, errorReporter, /* canBeDeployedInNlbInstanceBasedTargetGroup */ false); dedicatedInstanceTypeLabel = new Label(); sharedInstanceTypeListBox = LandscapeDialogUtil.createInstanceTypeListBox(this, landscapeManagementService, - stringMessages, SharedLandscapeConstants.DEFAULT_SHARED_INSTANCE_TYPE_NAME, errorReporter); + stringMessages, SharedLandscapeConstants.DEFAULT_SHARED_INSTANCE_TYPE_NAME, errorReporter, /* canBeDeployedInNlbInstanceBasedTargetGroup */ false); sharedInstanceTypeLabel = new Label(); memoryInMegabytesBox = createIntegerBox(null, 7); memoryTotalSizeFactorBox = createIntegerBox(null, 2); diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/CreateReverseProxyInClusterDialog.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/CreateReverseProxyInClusterDialog.java index a4a702dc43b..06f6dd9e913 100644 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/CreateReverseProxyInClusterDialog.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/CreateReverseProxyInClusterDialog.java @@ -128,7 +128,7 @@ public class CreateReverseProxyInClusterDialog existingReverseProxies); proxyName = createTextBox("", 20); dedicatedInstanceTypeListBox = LandscapeDialogUtil.createInstanceTypeListBox(this, landscapeManagementService, - stringMessages, SharedLandscapeConstants.DEFAULT_REVERSE_PROXY_INSTANCE_TYPE, errorReporter); + stringMessages, SharedLandscapeConstants.DEFAULT_REVERSE_PROXY_INSTANCE_TYPE, errorReporter, /* canBeDeployedInNlbInstanceBasedTargetGroup */ true); // setup labels nameLabel = new Label(stringMessages.instanceName()); instanceTypeLabel = new Label(stringMessages.instanceType()); diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeDialogUtil.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeDialogUtil.java index f84a1c686b0..1a5d39725f2 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeDialogUtil.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeDialogUtil.java @@ -13,10 +13,10 @@ import com.sap.sse.gwt.client.dialog.DataEntryDialog; public class LandscapeDialogUtil { public static ListBox createInstanceTypeListBox(DataEntryDialog dialog, LandscapeManagementWriteServiceAsync landscapeManagementService, StringMessages stringMessages, - String defaultInstanceTypeName, ErrorReporter errorReporter) { + String defaultInstanceTypeName, ErrorReporter errorReporter, boolean canBeDeployedInNlbInstanceBasedTargetGroup) { return createInstanceTypeListBoxWithAdditionalDefaultEntry(dialog, /* additionalItem */ null, /* additionalValue */ null, landscapeManagementService, stringMessages, defaultInstanceTypeName, - errorReporter); + errorReporter, canBeDeployedInNlbInstanceBasedTargetGroup); } /** @@ -24,17 +24,20 @@ public class LandscapeDialogUtil { * if not {@code null}, an item with this name is created, and then {@code additionalValue} must not be * {@code null} because it is then used as that item's value. The item will then be set as the one * selected. + * @param canBeDeployedInNlbInstanceBasedTargetGroup A boolean indicating whether the instance list should filter out those + * which cannot be added to NLB, instance-based target groups. True indicates that it needs to be deployable + * to this type of target group, so the resulting listbox should not contain the banned instance types. */ public static ListBox createInstanceTypeListBoxWithAdditionalDefaultEntry(DataEntryDialog dialog, String additionalItem, String additionalValue, LandscapeManagementWriteServiceAsync landscapeManagementService, StringMessages stringMessages, - String defaultInstanceTypeName, ErrorReporter errorReporter) { + String defaultInstanceTypeName, ErrorReporter errorReporter, boolean canBeDeployedInNlbInstanceBasedTargetGroup) { final ListBox instanceTypeBox = dialog.createListBox(/* isMultipleSelect */false); if (additionalItem != null) { instanceTypeBox.addItem(additionalItem, additionalValue); instanceTypeBox.setSelectedIndex(0); } - landscapeManagementService.getInstanceTypeNames(new AsyncCallback>() { + landscapeManagementService.getInstanceTypeNames(canBeDeployedInNlbInstanceBasedTargetGroup, new AsyncCallback>() { @Override public void onFailure(Throwable caught) { errorReporter.reportError(caught.getMessage()); diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteService.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteService.java index 766bdbc1c02..09918eff4ac 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteService.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteService.java @@ -26,7 +26,7 @@ import com.sap.sse.landscape.aws.common.shared.RedirectDTO; public interface LandscapeManagementWriteService extends RemoteService { ArrayList getRegions(); - ArrayList getInstanceTypeNames(); + ArrayList getInstanceTypeNames(boolean canBeDeployedInNlbInstanceBasedTargetGroup); ArrayList getMongoEndpoints(String region) throws Exception; diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java index 0c47838b54d..64115cfa8bf 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java @@ -28,7 +28,7 @@ import com.sap.sse.landscape.aws.common.shared.RedirectDTO; public interface LandscapeManagementWriteServiceAsync { void getRegions(AsyncCallback> callback); - void getInstanceTypeNames(AsyncCallback> callback); + void getInstanceTypeNames(boolean canBeDeployedInNlbInstanceBasedTargetGroup, AsyncCallback> callback); void getMongoEndpoints(String regionId, AsyncCallback> callback); diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/MongoScalingDialog.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/MongoScalingDialog.java index e3aac368303..ce2f1f468b4 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/MongoScalingDialog.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/MongoScalingDialog.java @@ -106,7 +106,7 @@ public class MongoScalingDialog extends DataEntryDialog { stringMessages.ok(), stringMessages.cancel(), /* validator */ null, callback); instanceTypeListBox = LandscapeDialogUtil.createInstanceTypeListBoxWithAdditionalDefaultEntry(this, stringMessages.sameAsExistingHost(), SAME_AS_MASTER, landscapeManagementService, stringMessages, /* default */ stringMessages.sameAsExistingHost(), - errorReporter); + errorReporter, /* canBeDeployedInNlbInstanceBasedTargetGroup */ false); instanceTypeLabel = new Label(); } diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/MoveMasterProcessDialog.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/MoveMasterProcessDialog.java index d1cf2ccea8f..e5061d47dcf 100644 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/MoveMasterProcessDialog.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/MoveMasterProcessDialog.java @@ -79,7 +79,7 @@ public class MoveMasterProcessDialog extends DataEntryDialog getInstanceTypeNames() { + public ArrayList getInstanceTypeNames(boolean canBeDeployedInNlbInstanceBasedTargetGroup) { final ArrayList result = new ArrayList<>(); Util.addAll(Util.map(Arrays.asList(InstanceType.values()), instanceType->instanceType.name()), result); + if (canBeDeployedInNlbInstanceBasedTargetGroup) { + Arrays.asList(LandscapeConstants.INSTANCE_TYPES_BANNED_FROM_INSTANCE_BASED_NLB_TARGET_GROUPS).forEach(type -> result.remove(type.name())); + } return result; } diff --git a/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/LandscapeConstants.java b/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/LandscapeConstants.java index df852164aa4..f1e63bcc3ac 100644 --- a/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/LandscapeConstants.java +++ b/java/com.sap.sse.landscape.aws/src/com/sap/sse/landscape/aws/LandscapeConstants.java @@ -61,10 +61,10 @@ public interface LandscapeConstants { */ String CENTRAL_REVERSE_PROXY_TAG_NAME = "CentralReverseProxy"; - InstanceType[] instanceTypesBannedFromInstanceBasedTargetGroups = new InstanceType[] { InstanceType.CC1_4_XLARGE, InstanceType.C1_MEDIUM, InstanceType.C1_XLARGE, + InstanceType[] INSTANCE_TYPES_BANNED_FROM_INSTANCE_BASED_NLB_TARGET_GROUPS = new InstanceType[] { InstanceType.CC1_4_XLARGE, InstanceType.C1_MEDIUM, InstanceType.C1_XLARGE, InstanceType.CC2_8_XLARGE, InstanceType.CG1_4_XLARGE, InstanceType.CR1_8_XLARGE, InstanceType.G2_2_XLARGE, InstanceType.G2_8_XLARGE, InstanceType.HI1_4_XLARGE, InstanceType.HS1_8_XLARGE, InstanceType.M1_LARGE, InstanceType.M1_MEDIUM, InstanceType.M1_SMALL, InstanceType.M1_XLARGE, InstanceType.M2_2_XLARGE, InstanceType.M2_4_XLARGE, InstanceType.M2_XLARGE, InstanceType.M3_2_XLARGE, InstanceType.M3_LARGE, - InstanceType.M3_MEDIUM, InstanceType.M3_XLARGE, InstanceType.T1_MICRO }; + InstanceType.M3_MEDIUM, InstanceType.M3_XLARGE, InstanceType.T1_MICRO}; } From 7bf220dcc531e9b537d52440a48b3daa86fffd3d Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Tue, 12 Mar 2024 17:01:00 +0100 Subject: [PATCH 07/16] b5969: Filter AZ choice list for reverse proxy creation, based on the default ALB security group's vpc. --- .../ui/server/LandscapeManagementWriteServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java index cc71d00bfaa..eecb5f907d3 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java @@ -244,8 +244,12 @@ public class LandscapeManagementWriteServiceImpl extends ResultCachingProxiedRem @Override public ArrayList describeAvailabilityZones(String region) { final ArrayList availabilityZones = new ArrayList<>(); - getLandscape().getAvailabilityZones(new AwsRegion(region, getLandscape())) - .forEach(az -> availabilityZones.add(new AvailabilityZoneDTO(az.getName(), region, az.getId()))); + logger.info(getLandscape().getDefaultSecurityGroupForApplicationLoadBalancer(new AwsRegion(region, getLandscape())).getId()); + getLandscape() + .getAvailabilityZones(new AwsRegion(region, getLandscape()), + Optional.of(getLandscape().getDefaultSecurityGroupForApplicationLoadBalancer( + new AwsRegion(region, getLandscape())).getVpcId())) + .forEach(az -> availabilityZones.add(new AvailabilityZoneDTO(az.getName(), region, az.getId()))); return availabilityZones; } From 67cdfa55ee4df262e1ea470242a46c3c07d34bc9 Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Tue, 12 Mar 2024 17:06:42 +0100 Subject: [PATCH 08/16] b5969: Add insightful comment. --- .../ui/client/LandscapeManagementWriteServiceAsync.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java index 64115cfa8bf..babfa7cd461 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java @@ -28,6 +28,12 @@ import com.sap.sse.landscape.aws.common.shared.RedirectDTO; public interface LandscapeManagementWriteServiceAsync { void getRegions(AsyncCallback> callback); + /** + * + * @param canBeDeployedInNlbInstanceBasedTargetGroup + * A boolean indicating, if true, that the list of available instance types should not contain those, + * which cannot be added to an instance-based Network Load Balancer. + */ void getInstanceTypeNames(boolean canBeDeployedInNlbInstanceBasedTargetGroup, AsyncCallback> callback); void getMongoEndpoints(String regionId, AsyncCallback> callback); From 54db8716c2f02c0be3ca1e6b9323dcd7090ba9f7 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Wed, 13 Mar 2024 00:12:33 +0100 Subject: [PATCH 09/16] enhanced timeout waiting for new master after moving master to new host; example: my.sapsailing.com --- .../src/com/sap/sse/landscape/Landscape.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com.sap.sse.landscape/src/com/sap/sse/landscape/Landscape.java b/java/com.sap.sse.landscape/src/com/sap/sse/landscape/Landscape.java index 2de7d94a62c..21d23ac7447 100755 --- a/java/com.sap.sse.landscape/src/com/sap/sse/landscape/Landscape.java +++ b/java/com.sap.sse.landscape/src/com/sap/sse/landscape/Landscape.java @@ -16,7 +16,7 @@ public interface Landscape { /** * The timeout for a host to come up */ - Optional WAIT_FOR_HOST_TIMEOUT = Optional.of(Duration.ONE_MINUTE.times(30)); + Optional WAIT_FOR_HOST_TIMEOUT = Optional.of(Duration.ONE_HOUR.times(2)); /** * The timeout for a running process to respond */ From 2d6bfaf5dcda73fc411377391930b84f5e5b5b15 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Wed, 13 Mar 2024 01:13:40 +0100 Subject: [PATCH 10/16] bug5969: suggested simplification for filtering banned NLB instance-based target group instance types --- .../LandscapeManagementWriteServiceAsync.java | 1 - .../LandscapeManagementWriteServiceImpl.java | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java index babfa7cd461..223728a0f0d 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/client/LandscapeManagementWriteServiceAsync.java @@ -29,7 +29,6 @@ public interface LandscapeManagementWriteServiceAsync { void getRegions(AsyncCallback> callback); /** - * * @param canBeDeployedInNlbInstanceBasedTargetGroup * A boolean indicating, if true, that the list of available instance types should not contain those, * which cannot be added to an instance-based Network Load Balancer. diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java index eecb5f907d3..c04b77075db 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java @@ -208,14 +208,21 @@ public class LandscapeManagementWriteServiceImpl extends ResultCachingProxiedRem Util.addAll(Util.map(AwsLandscape.obtain(RemoteServiceMappingConstants.pathPrefixForShardingKey).getRegions(), r->r.getId()), result); return result; } - + + private static final Set INSTANCE_TYPES_BANNED_FROM_INSTANCE_BASE_NLB_TARGET_GROUPS_AS_SET = + new HashSet<>(Arrays.asList(LandscapeConstants.INSTANCE_TYPES_BANNED_FROM_INSTANCE_BASED_NLB_TARGET_GROUPS)); + @Override public ArrayList getInstanceTypeNames(boolean canBeDeployedInNlbInstanceBasedTargetGroup) { final ArrayList result = new ArrayList<>(); - Util.addAll(Util.map(Arrays.asList(InstanceType.values()), instanceType->instanceType.name()), result); - if (canBeDeployedInNlbInstanceBasedTargetGroup) { - Arrays.asList(LandscapeConstants.INSTANCE_TYPES_BANNED_FROM_INSTANCE_BASED_NLB_TARGET_GROUPS).forEach(type -> result.remove(type.name())); - } + Util.addAll( + Util.map( + // if deployment to NLB instance-based target group is to be possible, remove those + // instance types that are banned from those sorts of target groups + Util.filter(Arrays.asList(InstanceType.values()), it-> + !canBeDeployedInNlbInstanceBasedTargetGroup || + !INSTANCE_TYPES_BANNED_FROM_INSTANCE_BASE_NLB_TARGET_GROUPS_AS_SET.contains(it)), + instanceType->instanceType.name()), result); return result; } From 9374c6e3ef738368b83ec3fcbf7f4c07bd756655 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Wed, 13 Mar 2024 02:16:02 +0100 Subject: [PATCH 11/16] upgraded SAPJVM8 to 8.1.097 for docker image production --- docker/Dockerfile | 2 +- docker/Dockerfile_sapjvm | 2 +- docker/Dockerfile_windestimation | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 67cc250cd7a..796f0b19a12 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.sapsailing.com/sapjvm8:8.1.096 +FROM docker.sapsailing.com/sapjvm8:8.1.097 ARG RELEASE LABEL maintainer=axel.uhl@sap.com # Download and extract the release diff --git a/docker/Dockerfile_sapjvm b/docker/Dockerfile_sapjvm index b23c4b5e069..ebdcddbd098 100644 --- a/docker/Dockerfile_sapjvm +++ b/docker/Dockerfile_sapjvm @@ -1,5 +1,5 @@ FROM buildpack-deps:bullseye -ARG SAPJVM_VERSION=8.1.096 +ARG SAPJVM_VERSION=8.1.097 LABEL maintainer=axel.uhl@sap.com # Download and extract the SAP JVM 8 ENV PATH=${PATH}:/opt/sapjvm_8/bin diff --git a/docker/Dockerfile_windestimation b/docker/Dockerfile_windestimation index 25c99187d0e..fd1d577d4dc 100755 --- a/docker/Dockerfile_windestimation +++ b/docker/Dockerfile_windestimation @@ -1,4 +1,4 @@ -ARG SAPJVM_VERSION=8.1.096 +ARG SAPJVM_VERSION=8.1.097 FROM docker.sapsailing.com/sapjvm8:${SAPJVM_VERSION} LABEL maintainer=axel.uhl@sap.com # Download and extract the release From 550f98bb0cfbe4120357c9c987c94e6e50f5c416 Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Wed, 13 Mar 2024 09:35:31 +0100 Subject: [PATCH 12/16] b5969: Tweak lambda parameter name. --- .../ui/server/LandscapeManagementWriteServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java index c04b77075db..7ec00ee619f 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java @@ -219,9 +219,9 @@ public class LandscapeManagementWriteServiceImpl extends ResultCachingProxiedRem Util.map( // if deployment to NLB instance-based target group is to be possible, remove those // instance types that are banned from those sorts of target groups - Util.filter(Arrays.asList(InstanceType.values()), it-> + Util.filter(Arrays.asList(InstanceType.values()), instanceType-> !canBeDeployedInNlbInstanceBasedTargetGroup || - !INSTANCE_TYPES_BANNED_FROM_INSTANCE_BASE_NLB_TARGET_GROUPS_AS_SET.contains(it)), + !INSTANCE_TYPES_BANNED_FROM_INSTANCE_BASE_NLB_TARGET_GROUPS_AS_SET.contains(instanceType)), instanceType->instanceType.name()), result); return result; } From 33949456cf2f4cca0d57c2e8fceac627b0b5ceee Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Wed, 13 Mar 2024 09:41:49 +0100 Subject: [PATCH 13/16] b5969: Remove uneccessary logging statement. --- .../landscape/ui/server/LandscapeManagementWriteServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java index 7ec00ee619f..e818772c4d0 100755 --- a/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java +++ b/java/com.sap.sailing.landscape.ui/src/com/sap/sailing/landscape/ui/server/LandscapeManagementWriteServiceImpl.java @@ -251,7 +251,6 @@ public class LandscapeManagementWriteServiceImpl extends ResultCachingProxiedRem @Override public ArrayList describeAvailabilityZones(String region) { final ArrayList availabilityZones = new ArrayList<>(); - logger.info(getLandscape().getDefaultSecurityGroupForApplicationLoadBalancer(new AwsRegion(region, getLandscape())).getId()); getLandscape() .getAvailabilityZones(new AwsRegion(region, getLandscape()), Optional.of(getLandscape().getDefaultSecurityGroupForApplicationLoadBalancer( From 1f40b7e45044a0d1a699386d66c55deed2d2d46d Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Wed, 13 Mar 2024 10:35:19 +0100 Subject: [PATCH 14/16] Remove author warnings upon disposable httpd conf commits. --- .../reverse_proxy/files/root/setupHttpdGitLocal.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configuration/environments_scripts/reverse_proxy/files/root/setupHttpdGitLocal.sh b/configuration/environments_scripts/reverse_proxy/files/root/setupHttpdGitLocal.sh index fcbaaf61d85..0bf91980f16 100755 --- a/configuration/environments_scripts/reverse_proxy/files/root/setupHttpdGitLocal.sh +++ b/configuration/environments_scripts/reverse_proxy/files/root/setupHttpdGitLocal.sh @@ -14,4 +14,7 @@ if ! git status; then GIT_SSH_COMMAND="ssh -A -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git fetch git checkout main fi -echo "Use Status ${SELF_IP} internal-server-status" > /etc/httpd/conf.d/${STATUS_DEFINITION_FILE} \ No newline at end of file +echo "Use Status ${SELF_IP} internal-server-status" > /etc/httpd/conf.d/${STATUS_DEFINITION_FILE} +cd /etc/httpd +git config user.name "Disposable Reverse Proxy" +git config user.email "$(hostname)" \ No newline at end of file From 70a42fc9baea839b0decff76d9781e643348ab39 Mon Sep 17 00:00:00 2001 From: Thomas Stokes Date: Wed, 13 Mar 2024 12:33:26 +0100 Subject: [PATCH 15/16] Fix image upgrade bug and add no-startup-command. --- .../usr/local/bin/register-deregister-from-nlb-target-group.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configuration/environments_scripts/reverse_proxy/files/usr/local/bin/register-deregister-from-nlb-target-group.sh b/configuration/environments_scripts/reverse_proxy/files/usr/local/bin/register-deregister-from-nlb-target-group.sh index 7dbec292cd4..ebabac1bf77 100755 --- a/configuration/environments_scripts/reverse_proxy/files/usr/local/bin/register-deregister-from-nlb-target-group.sh +++ b/configuration/environments_scripts/reverse_proxy/files/usr/local/bin/register-deregister-from-nlb-target-group.sh @@ -17,7 +17,8 @@ if [[ "$#" -eq 0 ]];then fi addSelfToNLB() { - if ! ec2-metadata --user-data | grep "^image-upgrade$" ; then + user_data=$(ec2-metadata --user-data | sed -e 's/^user-data: //') + if ! echo "$user_data" | grep "^image-upgrade$" && ! echo "$user_data" | grep "^no-startup-automation$" ; then ec2-metadata --local-ipv4 | grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\>" > /var/cache/local-ip ec2-metadata --availability-zone | grep -o "[a-zA-Z]\+-[a-zA-Z]\+-[0-9a-z]\+\>" > /var/cache/availability-zone aws elbv2 register-targets --target-group-arn "${targetGroupArn}" --targets Id="${selfIp}",Port=80,AvailabilityZone="${availabilityZone}" From b900bc86fdb3a5218594059ee30a08e886fad8fc Mon Sep 17 00:00:00 2001 From: Generic Wiki User Date: Wed, 13 Mar 2024 11:39:21 +0000 Subject: [PATCH 16/16] Add central-only httpd config files to the repo structure. --- .../etc/httpd/central-config.d/004-git.conf | 25 ++++++ .../central-config.d/006-docker-registry.conf | 39 ++++++++++ .../central-config.d/007-sail-insight.conf | 14 ++++ .../etc/httpd/central-config.d/awstats.conf | 56 +++++++++++++ .../central-only-virtual-hosts.conf | 78 +++++++++++++++++++ .../etc/httpd/central-config.d/loadPhp.conf | 1 + .../etc/httpd/central-config.d/perl.conf | 48 ++++++++++++ .../etc/httpd/central-config.d/php-conf.7.1 | 57 ++++++++++++++ .../files/etc/httpd/central-config.d/php.conf | 57 ++++++++++++++ 9 files changed, 375 insertions(+) create mode 100644 configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/004-git.conf create mode 100644 configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/006-docker-registry.conf create mode 100644 configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/007-sail-insight.conf create mode 100644 configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/awstats.conf create mode 100644 configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/central-only-virtual-hosts.conf create mode 100644 configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/loadPhp.conf create mode 100644 configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/perl.conf create mode 100644 configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/php-conf.7.1 create mode 100644 configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/php.conf diff --git a/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/004-git.conf b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/004-git.conf new file mode 100644 index 00000000000..97270e6d056 --- /dev/null +++ b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/004-git.conf @@ -0,0 +1,25 @@ + +ServerName git.sapsailing.com +SetEnv GIT_PROJECT_ROOT /home/trac/git +SetEnv GIT_HTTP_EXPORT_ALL +ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/ +ScriptAlias /hooks/ /var/www/cgi-bin/ + + + Options +ExecCGI + AuthType Basic + AuthName 'Git' + AuthUserFile '/etc/httpd/conf/passwd.git' + Require valid-user + + + + AllowOverride None + Options FollowSymLinks + Order allow,deny + Allow from all + + +SetEnvIf User-Agent ".*MSIE.*" \ + downgrade-1.0 force-response-1.0 + diff --git a/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/006-docker-registry.conf b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/006-docker-registry.conf new file mode 100644 index 00000000000..a8a59f71935 --- /dev/null +++ b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/006-docker-registry.conf @@ -0,0 +1,39 @@ + + ServerName docker.sapsailing.com + ProxyPreserveHost on + ProxyPass / http://127.0.0.1:5000/ + ProxyPassReverse / http://127.0.0.1:5000/ + + Order deny,allow + Allow from all + AuthName "Docker Registry Authentication" + AuthType basic + AuthUserFile '/etc/httpd/conf/passwd.git' + Require valid-user + + # Use separate log files for the SSL virtual host; note that LogLevel + # is not inherited from httpd.conf. + ErrorLog logs/docker_error_log + TransferLog logs/docker_access_log + LogLevel warn + + + + ServerName docker-registry.sapsailing.com + ProxyPreserveHost on + ProxyPass /v2 http://127.0.0.1:5001/v2 + ProxyPassReverse /v2 http://127.0.0.1:5001/v2 + + Order deny,allow + Allow from all + AuthName "Docker Registry Authentication" + AuthType basic + AuthUserFile '/etc/httpd/conf/passwd.git' + Require valid-user + + # Use separate log files for the SSL virtual host; note that LogLevel + # is not inherited from httpd.conf. + ErrorLog logs/docker_error_log + TransferLog logs/docker_access_log + LogLevel warn + diff --git a/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/007-sail-insight.conf b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/007-sail-insight.conf new file mode 100644 index 00000000000..99512acd0c0 --- /dev/null +++ b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/007-sail-insight.conf @@ -0,0 +1,14 @@ +# sail-insight.com + + ServerName sail-insight.com + ServerAlias www.sail-insight.com + CustomLog logs/services_log combined env=!original_client_ip + CustomLog logs/services_log first_forwarded_for_ip env=original_client_ip + Alias / /home/trac/sail-insight-website/ + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all + + diff --git a/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/awstats.conf b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/awstats.conf new file mode 100644 index 00000000000..71f8ca03299 --- /dev/null +++ b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/awstats.conf @@ -0,0 +1,56 @@ +# +# Content of this file, with correct values, can be automatically added to +# your Apache server by using the AWStats configure.pl tool. +# + + +# If using Windows and Perl ActiveStat, this is to enable Perl script as CGI. +#ScriptInterpreterSource registry + + +# +# Directives to add to your Apache conf file to allow use of AWStats as a CGI. +# Note that path "/usr/share/awstats/" must reflect your AWStats install path. +# +Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/" +Alias /awstatscss "/usr/share/awstats/wwwroot/css/" +Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/" +ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/" + +# Adding access to /var/log/old/cache/unique-ips-per-referrer/stats: +Alias /unique-visitors/ "/var/log/old/cache/unique-ips-per-referrer/stats/" + +# +# This is to permit URL access to scripts/files in AWStats directory. +# + + ServerName awstats.sapsailing.com + CustomLog logs/awstats_access_log combined + ErrorLog logs/awstats_error_log + + + Options None +# AllowOverride None +# Order allow,deny +# Allow from 127.0.0.1 + AuthType Basic + AuthName 'awstats' + AuthUserFile /etc/httpd/conf/passwd.awstats + Require valid-user + + + + Options Indexes +# AllowOverride None +# Order allow,deny +# Allow from 127.0.0.1 + AuthType Basic + AuthName 'awstats' + AuthUserFile /etc/httpd/conf/passwd.awstats + Require valid-user + +# Additional Perl modules + + SetEnv PERL5LIB /usr/share/awstats/lib:/usr/share/awstats/plugins:/root/perl5/lib/perl5 + + diff --git a/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/central-only-virtual-hosts.conf b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/central-only-virtual-hosts.conf new file mode 100644 index 00000000000..ddd678ce2a4 --- /dev/null +++ b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/central-only-virtual-hosts.conf @@ -0,0 +1,78 @@ + + ServerName jobs.sapsailing.com + CustomLog logs/jobs_log combined env=!original_client_ip + CustomLog logs/jobs_log first_forwarded_for_ip env=original_client_ip + DocumentRoot /home/trac/static/jobs + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all + + + +# P2 repository + + ServerName p2.sapsailing.com + CustomLog logs/services_log combined env=!original_client_ip + CustomLog logs/services_log first_forwarded_for_ip env=original_client_ip + Alias /p2 /home/trac/p2-repositories + + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + + + + + ServerName bugzilla.sapsailing.com + RewriteEngine On + RewriteRule ^/?$ http://bugzilla.sapsailing.com/bugzilla [L] + CustomLog logs/services_log combined env=!original_client_ip + CustomLog logs/services_log first_forwarded_for_ip env=original_client_ip + Alias /bugzilla /usr/share/bugzilla + + AddHandler cgi-script .cgi + Options +Indexes +ExecCGI +FollowSymLinks + DirectoryIndex index.cgi + AllowOverride Limit Options FileInfo Indexes AuthConfig + + # Additional Perl modules + + SetEnv PERL5LIB /root/perl5/lib/perl5:/root/perl5/lib/perl5/x86_64-linux-thread-multi + + + +# Wiki --> + + ServerName wiki.sapsailing.com + RewriteEngine on + RewriteRule ^/(.*) http://localhost:4567/$1 [P,L] + ProxyPassReverse / http://localhost:4567/ + CustomLog logs/services_log combined env=!original_client_ip + CustomLog logs/services_log first_forwarded_for_ip env=original_client_ip + + + + ServerName releases.sapsailing.com + DocumentRoot /home/trac/releases + + Options +Indexes +FollowSymLinks + + CustomLog logs/services_log combined env=!original_client_ip + CustomLog logs/services_log first_forwarded_for_ip env=original_client_ip + + + + ServerName static.sapsailing.com + DocumentRoot /var/www/static + + Order Deny,Allow + Allow from all + Options -Indexes +FollowSymLinks -ExecCGI + AllowOverride All + + CustomLog logs/services_log combined env=!original_client_ip + CustomLog logs/services_log first_forwarded_for_ip env=original_client_ip + diff --git a/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/loadPhp.conf b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/loadPhp.conf new file mode 100644 index 00000000000..67a415dca06 --- /dev/null +++ b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/loadPhp.conf @@ -0,0 +1 @@ +LoadModule php7_module modules/libphp-7.1.so diff --git a/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/perl.conf b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/perl.conf new file mode 100644 index 00000000000..30d5d16f3bd --- /dev/null +++ b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/perl.conf @@ -0,0 +1,48 @@ +# +# Mod_perl incorporates a Perl interpreter into the Apache web server, +# so that the Apache web server can directly execute Perl code. +# Mod_perl links the Perl runtime library into the Apache web server +# and provides an object-oriented Perl interface for Apache's C +# language API. The end result is a quicker CGI script turnaround +# process, since no external Perl interpreter has to be started. +# + +# Uncomment this line to globally enable warnings, which will be +# written to the server's error log. Warnings should be enabled +# during the development process, but should be disabled on a +# production server as they affect performance. +# +#PerlSwitches -w + +# Uncomment this line to enable taint checking globally. When Perl is +# running in taint mode various checks are performed to reduce the +# risk of insecure data being passed to a subshell or being used to +# modify the filesystem. Unfortunately many Perl modules are not +# taint-safe, so you should exercise care before enabling it on a +# production server. +# +#PerlSwitches -T + +# This will allow execution of mod_perl to compile your scripts to +# subroutines which it will execute directly, avoiding the costly +# compile process for most requests. +# +#Alias /perl /var/www/perl +# +# SetHandler perl-script +# PerlResponseHandler ModPerl::Registry +# PerlOptions +ParseHeaders +# Options +ExecCGI +# + +# This will allow remote server configuration reports, with the URL of +# http://servername/perl-status +# Change the ".example.com" to match your domain to enable. +# +# +# SetHandler perl-script +# PerlResponseHandler Apache2::Status +# Order deny,allow +# Deny from all +# Allow from .example.com +# diff --git a/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/php-conf.7.1 b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/php-conf.7.1 new file mode 100644 index 00000000000..2c8064ed7f1 --- /dev/null +++ b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/php-conf.7.1 @@ -0,0 +1,57 @@ +# +# The following lines prevent .user.ini files from being viewed by Web clients. +# + + Require all denied + + +# +# Allow php to handle Multiviews +# +AddType text/html .php + +# +# Add index.php to the list of files that will be served as directory +# indexes. +# +DirectoryIndex index.php + +# mod_php options + + # + # Cause the PHP interpreter to handle files with a .php extension. + # + + SetHandler application/x-httpd-php + + + # + # Uncomment the following lines to allow PHP to pretty-print .phps + # files as PHP source code: + # + # + # SetHandler application/x-httpd-php-source + # + + # + # Apache specific PHP configuration options + # those can be override in each configured vhost + # + php_value session.save_handler "files" + php_value session.save_path "/var/lib/php/7.1/session" + php_value soap.wsdl_cache_dir "/var/lib/php/7.1/wsdlcache" + + #php_value opcache.file_cache "/var/lib/php/7.1/opcache" + + +# Redirect to local php-fpm if mod_php is not available + + + # Enable http authorization headers + SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1 + + + SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost" + + + diff --git a/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/php.conf b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/php.conf new file mode 100644 index 00000000000..2c8064ed7f1 --- /dev/null +++ b/configuration/environments_scripts/central_reverse_proxy/files/etc/httpd/central-config.d/php.conf @@ -0,0 +1,57 @@ +# +# The following lines prevent .user.ini files from being viewed by Web clients. +# + + Require all denied + + +# +# Allow php to handle Multiviews +# +AddType text/html .php + +# +# Add index.php to the list of files that will be served as directory +# indexes. +# +DirectoryIndex index.php + +# mod_php options + + # + # Cause the PHP interpreter to handle files with a .php extension. + # + + SetHandler application/x-httpd-php + + + # + # Uncomment the following lines to allow PHP to pretty-print .phps + # files as PHP source code: + # + # + # SetHandler application/x-httpd-php-source + # + + # + # Apache specific PHP configuration options + # those can be override in each configured vhost + # + php_value session.save_handler "files" + php_value session.save_path "/var/lib/php/7.1/session" + php_value soap.wsdl_cache_dir "/var/lib/php/7.1/wsdlcache" + + #php_value opcache.file_cache "/var/lib/php/7.1/opcache" + + +# Redirect to local php-fpm if mod_php is not available + + + # Enable http authorization headers + SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1 + + + SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost" + + +