From de5624e8e9e652f412e96950be06fd1e230207b3 Mon Sep 17 00:00:00 2001 From: LinPeiWen <591171850@qq.com> Date: Mon, 8 Mar 2021 10:51:23 +0000 Subject: [PATCH] Use Docker healthchecks for zookeeper services This change enables the use of Docker healthchecks for zookeeper services. Implements: blueprint container-health-check Change-Id: I344115580840f3aa3f872c6136492f7bd7b73db8 --- ansible/roles/zookeeper/defaults/main.yml | 15 +++++++++++++++ ansible/roles/zookeeper/handlers/main.yml | 1 + .../roles/zookeeper/tasks/check-containers.yml | 1 + ...althchecks-for-zookeeper-7f02c4667a1bd051.yaml | 6 ++++++ 4 files changed, 23 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-zookeeper-7f02c4667a1bd051.yaml diff --git a/ansible/roles/zookeeper/defaults/main.yml b/ansible/roles/zookeeper/defaults/main.yml index e4b50f7304..6dc6be13f1 100644 --- a/ansible/roles/zookeeper/defaults/main.yml +++ b/ansible/roles/zookeeper/defaults/main.yml @@ -12,6 +12,8 @@ zookeeper_services: ZOO_LOG4J_PROP: "{{ zookeeper_log_settings }}" volumes: "{{ zookeeper_default_volumes + zookeeper_extra_volumes }}" dimensions: "{{ zookeeper_dimensions }}" + healthcheck: "{{ zookeeper_healthcheck }}" + #################### # Zookeeper @@ -27,6 +29,19 @@ zookeeper_tag: "{{ openstack_tag }}" zookeeper_image_full: "{{ zookeeper_image }}:{{ zookeeper_tag }}" zookeeper_dimensions: "{{ default_container_dimensions }}" +zookeeper_enable_healthchecks: "{{ enable_container_healthchecks }}" +zookeeper_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +zookeeper_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +zookeeper_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +zookeeper_healthcheck_test: ["CMD-SHELL", "healthcheck_listen java {{ zookeeper_client_port }}"] +zookeeper_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +zookeeper_healthcheck: + interval: "{{ zookeeper_healthcheck_interval }}" + retries: "{{ zookeeper_healthcheck_retries }}" + start_period: "{{ zookeeper_healthcheck_start_period }}" + test: "{% if zookeeper_enable_healthchecks | bool %}{{ zookeeper_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ zookeeper_healthcheck_timeout }}" + zookeeper_default_volumes: - "{{ node_config_directory }}/zookeeper/:{{ container_config_directory }}/" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/zookeeper/handlers/main.yml b/ansible/roles/zookeeper/handlers/main.yml index 75e0ec3244..18d063d7ae 100644 --- a/ansible/roles/zookeeper/handlers/main.yml +++ b/ansible/roles/zookeeper/handlers/main.yml @@ -12,5 +12,6 @@ environment: "{{ service.environment }}" volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" diff --git a/ansible/roles/zookeeper/tasks/check-containers.yml b/ansible/roles/zookeeper/tasks/check-containers.yml index 85198e9839..3f86d932ba 100644 --- a/ansible/roles/zookeeper/tasks/check-containers.yml +++ b/ansible/roles/zookeeper/tasks/check-containers.yml @@ -9,6 +9,7 @@ volumes: "{{ item.value.volumes }}" environment: "{{ item.value.environment }}" dimensions: "{{ item.value.dimensions }}" + healthcheck: "{{ item.value.healthcheck | default(omit) }}" when: - inventory_hostname in groups[item.value.group] - item.value.enabled | bool diff --git a/releasenotes/notes/implement-docker-healthchecks-for-zookeeper-7f02c4667a1bd051.yaml b/releasenotes/notes/implement-docker-healthchecks-for-zookeeper-7f02c4667a1bd051.yaml new file mode 100644 index 0000000000..92ce958637 --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-zookeeper-7f02c4667a1bd051.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for zookeeper services. + See `blueprint + `__