Problem
elasticsearch_cluster_settings is applied at the very end of the role, after any restart triggered by a config change has already completed.
In roles/elasticsearch/tasks/main.yml:
- line 532 —
import_tasks: elasticsearch-security.yml, which ends with meta: flush_handlers (elasticsearch-security.yml:625). This is where Restart Elasticsearch rolling runs.
- line 651 —
include_tasks: elasticsearch-cluster-settings.yml
So the rolling restart runs with whatever persistent settings the cluster happens to have at that moment, not with the ones declared in elasticsearch_cluster_settings.
Impact
This matters most for the settings that govern how fast a cluster recovers after a node comes back:
indices.recovery.max_bytes_per_sec (ES default 40mb)
cluster.routing.allocation.node_concurrent_incoming_recoveries (ES default 2)
On a first run, or any time those settings have drifted out of the cluster, every node in the rolling restart recovers at the ES defaults even though the playbook declares something higher.
It also interacts badly with the health gate in restart_and_verify_elasticsearch_rolling_node.yml, which waits for:
- status in _elasticsearch_health_statuses
- relocating_shards == 0
- initializing_shards == 0
A cluster can be green while the balancer is still relocating shards after the restarted node rejoins, so this gate waits for the rebalance to finish. The budget is elasticsearch_config_restart_health_retries (50) x elasticsearch_config_restart_health_delay (30s) = 25 minutes per node. At the default 40mb throttle a rebalance on a large data node can exceed that, and the run then falls into the rescue block and fails with:
Elasticsearch failed to restart on <host>.
Recent log output: ...
plus 50 lines of journal, while the node restarted perfectly fine and the cluster was green the whole time.
Suggested fix
Apply the persistent cluster settings before any restart handler can run, e.g. move the elasticsearch-cluster-settings.yml include ahead of elasticsearch-security.yml.
Secondary: the rescue message assumes a startup failure. When the failing task is the post-restart health gate, reporting the last cluster health response (status, relocating_shards, initializing_shards) would point at the real cause instead of the journal.
Problem
elasticsearch_cluster_settingsis applied at the very end of the role, after any restart triggered by a config change has already completed.In
roles/elasticsearch/tasks/main.yml:import_tasks: elasticsearch-security.yml, which ends withmeta: flush_handlers(elasticsearch-security.yml:625). This is whereRestart Elasticsearch rollingruns.include_tasks: elasticsearch-cluster-settings.ymlSo the rolling restart runs with whatever persistent settings the cluster happens to have at that moment, not with the ones declared in
elasticsearch_cluster_settings.Impact
This matters most for the settings that govern how fast a cluster recovers after a node comes back:
indices.recovery.max_bytes_per_sec(ES default 40mb)cluster.routing.allocation.node_concurrent_incoming_recoveries(ES default 2)On a first run, or any time those settings have drifted out of the cluster, every node in the rolling restart recovers at the ES defaults even though the playbook declares something higher.
It also interacts badly with the health gate in
restart_and_verify_elasticsearch_rolling_node.yml, which waits for:A cluster can be
greenwhile the balancer is still relocating shards after the restarted node rejoins, so this gate waits for the rebalance to finish. The budget iselasticsearch_config_restart_health_retries(50) xelasticsearch_config_restart_health_delay(30s) = 25 minutes per node. At the default 40mb throttle a rebalance on a large data node can exceed that, and the run then falls into therescueblock and fails with:plus 50 lines of journal, while the node restarted perfectly fine and the cluster was green the whole time.
Suggested fix
Apply the persistent cluster settings before any restart handler can run, e.g. move the
elasticsearch-cluster-settings.ymlinclude ahead ofelasticsearch-security.yml.Secondary: the
rescuemessage assumes a startup failure. When the failing task is the post-restart health gate, reporting the last cluster health response (status,relocating_shards,initializing_shards) would point at the real cause instead of the journal.