From 634527407b0fda68bf41d75f2f93941afa8aee22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 31 Jul 2023 15:54:10 +0200 Subject: [PATCH] Disable disk-based shard allocation thresholds for Elasticsearch in dev services and tests In a single-node setup they just don't make sense, and lead to problems on large disks with little space left. See https://www.elastic.co/guide/en/elasticsearch/reference/8.8/modules-cluster.html#disk-based-shard-allocation --- docs/src/main/asciidoc/centralized-log-management.adoc | 5 +++++ docs/src/main/asciidoc/elasticsearch.adoc | 1 + .../deployment/DevServicesElasticsearchProcessor.java | 5 +++++ .../deployment/pom.xml | 6 ++++++ .../deployment/pom.xml | 6 ++++++ integration-tests/elasticsearch-java-client/pom.xml | 6 ++++++ integration-tests/elasticsearch-rest-client/pom.xml | 6 ++++++ .../pom.xml | 7 ++++++- .../hibernate-search-orm-elasticsearch-tenancy/pom.xml | 6 ++++++ .../hibernate-search-orm-elasticsearch/pom.xml | 6 ++++++ integration-tests/logging-gelf/pom.xml | 9 +++++---- .../src/test/resources/docker-compose-efk.yml | 1 + .../src/test/resources/docker-compose-elk.yml | 1 + .../src/test/resources/docker-compose-graylog.yml | 1 + 14 files changed, 61 insertions(+), 5 deletions(-) diff --git a/docs/src/main/asciidoc/centralized-log-management.adoc b/docs/src/main/asciidoc/centralized-log-management.adoc index 6ee23b3d85598..cd640e7289de2 100644 --- a/docs/src/main/asciidoc/centralized-log-management.adoc +++ b/docs/src/main/asciidoc/centralized-log-management.adoc @@ -109,6 +109,7 @@ services: environment: ES_JAVA_OPTS: "-Xms512m -Xmx512m" discovery.type: "single-node" + cluster.routing.allocation.disk.threshold_enabled: false networks: - graylog @@ -197,6 +198,7 @@ services: environment: ES_JAVA_OPTS: "-Xms512m -Xmx512m" discovery.type: "single-node" + cluster.routing.allocation.disk.threshold_enabled: false networks: - elk @@ -286,6 +288,7 @@ services: environment: ES_JAVA_OPTS: "-Xms512m -Xmx512m" discovery.type: "single-node" + cluster.routing.allocation.disk.threshold_enabled: false networks: - efk @@ -372,6 +375,8 @@ services: - "9300:9300" environment: ES_JAVA_OPTS: "-Xms512m -Xmx512m" + discovery.type: "single-node" + cluster.routing.allocation.disk.threshold_enabled: false networks: - efk diff --git a/docs/src/main/asciidoc/elasticsearch.adoc b/docs/src/main/asciidoc/elasticsearch.adoc index 2f060358070cd..a79632c8e07a7 100644 --- a/docs/src/main/asciidoc/elasticsearch.adoc +++ b/docs/src/main/asciidoc/elasticsearch.adoc @@ -350,6 +350,7 @@ If you want to use Docker to run an Elasticsearch instance, you can use the foll [source,bash,subs=attributes+] ---- docker run --name elasticsearch -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m"\ + -e "cluster.routing.allocation.disk.threshold_enabled=false" --rm -p 9200:9200 {elasticsearch-image} ---- diff --git a/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/DevServicesElasticsearchProcessor.java b/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/DevServicesElasticsearchProcessor.java index 14de2679ed56f..e8bc4284af108 100644 --- a/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/DevServicesElasticsearchProcessor.java +++ b/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/DevServicesElasticsearchProcessor.java @@ -212,6 +212,11 @@ private DevServicesResultBuildItem.RunningDevService startElasticsearch( container.addEnv("ES_JAVA_OPTS", config.javaOpts); // 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"); + // Disable disk-based shard allocation thresholds: + // in a single-node setup they just don't make sense, + // and lead to problems on large disks with little space left. + // See https://www.elastic.co/guide/en/elasticsearch/reference/8.8/modules-cluster.html#disk-based-shard-allocation + container.addEnv( "cluster.routing.allocation.disk.threshold_enabled", "false" ); container.start(); return new DevServicesResultBuildItem.RunningDevService(Feature.ELASTICSEARCH_REST_CLIENT_COMMON.getName(), diff --git a/extensions/hibernate-search-orm-coordination-outbox-polling/deployment/pom.xml b/extensions/hibernate-search-orm-coordination-outbox-polling/deployment/pom.xml index c346c9a80a7f9..bf5a1e9fb07c4 100644 --- a/extensions/hibernate-search-orm-coordination-outbox-polling/deployment/pom.xml +++ b/extensions/hibernate-search-orm-coordination-outbox-polling/deployment/pom.xml @@ -122,6 +122,12 @@ single-node false -Xms512m -Xmx512m + + false 9200:9200 diff --git a/extensions/hibernate-search-orm-elasticsearch/deployment/pom.xml b/extensions/hibernate-search-orm-elasticsearch/deployment/pom.xml index 4d92af9a5529e..6f2645e3e2bf0 100644 --- a/extensions/hibernate-search-orm-elasticsearch/deployment/pom.xml +++ b/extensions/hibernate-search-orm-elasticsearch/deployment/pom.xml @@ -127,6 +127,12 @@ single-node false -Xms512m -Xmx512m + + false 9200:9200 diff --git a/integration-tests/elasticsearch-java-client/pom.xml b/integration-tests/elasticsearch-java-client/pom.xml index a3bd81558cc3a..bcb1f3405e81f 100644 --- a/integration-tests/elasticsearch-java-client/pom.xml +++ b/integration-tests/elasticsearch-java-client/pom.xml @@ -167,6 +167,12 @@ single-node false -Xms512m -Xmx512m + + false 9200:9200 diff --git a/integration-tests/elasticsearch-rest-client/pom.xml b/integration-tests/elasticsearch-rest-client/pom.xml index af00909796ce0..0010baf5a2d06 100644 --- a/integration-tests/elasticsearch-rest-client/pom.xml +++ b/integration-tests/elasticsearch-rest-client/pom.xml @@ -167,6 +167,12 @@ single-node false -Xms512m -Xmx512m + + false 9200:9200 diff --git a/integration-tests/hibernate-search-orm-elasticsearch-coordination-outbox-polling/pom.xml b/integration-tests/hibernate-search-orm-elasticsearch-coordination-outbox-polling/pom.xml index 05e8f99f152c1..4f59a84df7820 100644 --- a/integration-tests/hibernate-search-orm-elasticsearch-coordination-outbox-polling/pom.xml +++ b/integration-tests/hibernate-search-orm-elasticsearch-coordination-outbox-polling/pom.xml @@ -208,7 +208,12 @@ single-node false -Xms512m -Xmx512m - + + false 9200:9200 diff --git a/integration-tests/hibernate-search-orm-elasticsearch-tenancy/pom.xml b/integration-tests/hibernate-search-orm-elasticsearch-tenancy/pom.xml index ee74eac208c1e..a888a9cbbf521 100644 --- a/integration-tests/hibernate-search-orm-elasticsearch-tenancy/pom.xml +++ b/integration-tests/hibernate-search-orm-elasticsearch-tenancy/pom.xml @@ -224,6 +224,12 @@ single-node false -Xms512m -Xmx512m + + false 9200:9200 diff --git a/integration-tests/hibernate-search-orm-elasticsearch/pom.xml b/integration-tests/hibernate-search-orm-elasticsearch/pom.xml index 32df10fdad812..5494677e184e1 100644 --- a/integration-tests/hibernate-search-orm-elasticsearch/pom.xml +++ b/integration-tests/hibernate-search-orm-elasticsearch/pom.xml @@ -186,6 +186,12 @@ single-node false -Xms512m -Xmx512m + + false 9200:9200 diff --git a/integration-tests/logging-gelf/pom.xml b/integration-tests/logging-gelf/pom.xml index 0fd53519d9542..4c1c3e4fd4b5e 100644 --- a/integration-tests/logging-gelf/pom.xml +++ b/integration-tests/logging-gelf/pom.xml @@ -158,12 +158,13 @@ single-node false - false - -Xms512m -Xmx512m Elasticsearch: diff --git a/integration-tests/logging-gelf/src/test/resources/docker-compose-efk.yml b/integration-tests/logging-gelf/src/test/resources/docker-compose-efk.yml index d1b13ca0b7289..ec5090633fc30 100644 --- a/integration-tests/logging-gelf/src/test/resources/docker-compose-efk.yml +++ b/integration-tests/logging-gelf/src/test/resources/docker-compose-efk.yml @@ -7,6 +7,7 @@ services: ES_JAVA_OPTS: "-Xms512m -Xmx512m" discovery.type: "single-node" xpack.security.enabled: "false" + cluster.routing.allocation.disk.threshold_enabled: false networks: - efk diff --git a/integration-tests/logging-gelf/src/test/resources/docker-compose-elk.yml b/integration-tests/logging-gelf/src/test/resources/docker-compose-elk.yml index ef3ac1c81d05e..6363ac563612e 100644 --- a/integration-tests/logging-gelf/src/test/resources/docker-compose-elk.yml +++ b/integration-tests/logging-gelf/src/test/resources/docker-compose-elk.yml @@ -7,6 +7,7 @@ services: ES_JAVA_OPTS: "-Xms512m -Xmx512m" discovery.type: "single-node" xpack.security.enabled: "false" + cluster.routing.allocation.disk.threshold_enabled: false networks: - elk diff --git a/integration-tests/logging-gelf/src/test/resources/docker-compose-graylog.yml b/integration-tests/logging-gelf/src/test/resources/docker-compose-graylog.yml index 2b113d640780e..645a9e1c615ac 100644 --- a/integration-tests/logging-gelf/src/test/resources/docker-compose-graylog.yml +++ b/integration-tests/logging-gelf/src/test/resources/docker-compose-graylog.yml @@ -7,6 +7,7 @@ services: ES_JAVA_OPTS: "-Xms512m -Xmx512m" discovery.type: "single-node" xpack.security.enabled: "false" + cluster.routing.allocation.disk.threshold_enabled: false networks: - graylog