From 10f79eda1d31ffb4ce210e7be82220cff80d90ba Mon Sep 17 00:00:00 2001 From: LinPeiWen <591171850@qq.com> Date: Thu, 11 Mar 2021 15:13:58 +0000 Subject: [PATCH] Use Docker healthchecks for elasticsearch services This change enables the use of Docker healthchecks for elasticsearch services. Implements: blueprint container-health-check Change-Id: Ib50d56cc206a80b20a4f96e95bcdd8d11269234f --- ansible/roles/elasticsearch/defaults/main.yml | 14 ++++++++++++++ ansible/roles/elasticsearch/handlers/main.yml | 1 + .../roles/elasticsearch/tasks/check-containers.yml | 1 + ...hchecks-for-elasticsearch-b251cd701d428a18.yaml | 6 ++++++ 4 files changed, 22 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-elasticsearch-b251cd701d428a18.yaml diff --git a/ansible/roles/elasticsearch/defaults/main.yml b/ansible/roles/elasticsearch/defaults/main.yml index 18a9b15554..fca532337f 100644 --- a/ansible/roles/elasticsearch/defaults/main.yml +++ b/ansible/roles/elasticsearch/defaults/main.yml @@ -11,6 +11,7 @@ elasticsearch_services: ES_JAVA_OPTS: "{{ es_java_opts }}" volumes: "{{ elasticsearch_default_volumes + elasticsearch_extra_volumes }}" dimensions: "{{ elasticsearch_dimensions }}" + healthcheck: "{{ elasticsearch_healthcheck }}" haproxy: elasticsearch: enabled: "{{ enable_elasticsearch }}" @@ -85,6 +86,19 @@ elasticsearch_curator_image_full: "{{ elasticsearch_curator_image }}:{{ elastics elasticsearch_dimensions: "{{ default_container_dimensions }}" elasticsearch_curator_dimensions: "{{ default_container_dimensions }}" +elasticsearch_enable_healthchecks: "{{ enable_container_healthchecks }}" +elasticsearch_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +elasticsearch_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +elasticsearch_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +elasticsearch_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ elasticsearch_port }}"] +elasticsearch_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +elasticsearch_healthcheck: + interval: "{{ elasticsearch_healthcheck_interval }}" + retries: "{{ elasticsearch_healthcheck_retries }}" + start_period: "{{ elasticsearch_healthcheck_start_period }}" + test: "{% if elasticsearch_enable_healthchecks | bool %}{{ elasticsearch_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ elasticsearch_healthcheck_timeout }}" + elasticsearch_default_volumes: - "{{ node_config_directory }}/elasticsearch/:{{ container_config_directory }}/" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/elasticsearch/handlers/main.yml b/ansible/roles/elasticsearch/handlers/main.yml index af1cf3282d..641163c22c 100644 --- a/ansible/roles/elasticsearch/handlers/main.yml +++ b/ansible/roles/elasticsearch/handlers/main.yml @@ -12,6 +12,7 @@ environment: "{{ service.environment }}" volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" diff --git a/ansible/roles/elasticsearch/tasks/check-containers.yml b/ansible/roles/elasticsearch/tasks/check-containers.yml index b6ebbbb2be..120eadb499 100644 --- a/ansible/roles/elasticsearch/tasks/check-containers.yml +++ b/ansible/roles/elasticsearch/tasks/check-containers.yml @@ -8,6 +8,7 @@ image: "{{ item.value.image }}" volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" + healthcheck: "{{ item.value.healthcheck | default(omit) }}" environment: "{{ item.value.environment|default(omit) }}" when: - inventory_hostname in groups[item.value.group] diff --git a/releasenotes/notes/implement-docker-healthchecks-for-elasticsearch-b251cd701d428a18.yaml b/releasenotes/notes/implement-docker-healthchecks-for-elasticsearch-b251cd701d428a18.yaml new file mode 100644 index 0000000000..d0f508f3e9 --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-elasticsearch-b251cd701d428a18.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for elasticsearch services. + See `blueprint + `__