Skip to content

Commit

Permalink
Merge pull request #38713 from yrodiere/i38706-elasticsearch-containe…
Browse files Browse the repository at this point in the history
…r-hash

Only configure shared network for Elasticsearch/OpenSearch containers where necessary
  • Loading branch information
yrodiere authored Feb 9, 2024
2 parents 0fbf090 + 5013fe5 commit 3077c2e
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ private DevServicesResultBuildItem.RunningDevService startElasticsearch(
final Supplier<DevServicesResultBuildItem.RunningDevService> defaultElasticsearchSupplier = () -> {

GenericContainer<?> container = resolvedDistribution.equals(Distribution.ELASTIC)
? createElasticsearchContainer(config, resolvedImageName)
: createOpensearchContainer(config, resolvedImageName);
? createElasticsearchContainer(config, resolvedImageName, useSharedNetwork)
: createOpensearchContainer(config, resolvedImageName, useSharedNetwork);

if (config.serviceName != null) {
container.withLabel(DEV_SERVICE_LABEL, config.serviceName);
Expand Down Expand Up @@ -247,10 +247,12 @@ private DevServicesResultBuildItem.RunningDevService startElasticsearch(
}

private GenericContainer<?> createElasticsearchContainer(ElasticsearchDevServicesBuildTimeConfig config,
DockerImageName resolvedImageName) {
DockerImageName resolvedImageName, boolean useSharedNetwork) {
ElasticsearchContainer container = new ElasticsearchContainer(
resolvedImageName.asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch"));
ConfigureUtil.configureSharedNetwork(container, DEV_SERVICE_ELASTICSEARCH);
if (useSharedNetwork) {
ConfigureUtil.configureSharedNetwork(container, DEV_SERVICE_ELASTICSEARCH);
}

// Disable security as else we would need to configure it correctly to avoid tons of WARNING in the log
container.addEnv("xpack.security.enabled", "false");
Expand All @@ -264,10 +266,12 @@ private GenericContainer<?> createElasticsearchContainer(ElasticsearchDevService
}

private GenericContainer<?> createOpensearchContainer(ElasticsearchDevServicesBuildTimeConfig config,
DockerImageName resolvedImageName) {
DockerImageName resolvedImageName, boolean useSharedNetwork) {
OpensearchContainer container = new OpensearchContainer(
resolvedImageName.asCompatibleSubstituteFor("opensearchproject/opensearch"));
ConfigureUtil.configureSharedNetwork(container, DEV_SERVICE_OPENSEARCH);
if (useSharedNetwork) {
ConfigureUtil.configureSharedNetwork(container, DEV_SERVICE_OPENSEARCH);
}

container.addEnv("bootstrap.memory_lock", "true");
container.addEnv("plugins.index_state_management.enabled", "false");
Expand Down

0 comments on commit 3077c2e

Please sign in to comment.