From 72df931b58e0ec1e9218ad86cf7dfff0a19d7c89 Mon Sep 17 00:00:00 2001 From: LinPeiWen <591171850@qq.com> Date: Mon, 8 Mar 2021 10:44:02 +0000 Subject: [PATCH] Use Docker healthchecks for kafka services This change enables the use of Docker healthchecks for kafka services. Implements: blueprint container-health-check Change-Id: I31c978be7f8687de1e41b168712aceed28c67a8a --- ansible/roles/kafka/defaults/main.yml | 15 +++++++++++++++ ansible/roles/kafka/handlers/main.yml | 1 + ansible/roles/kafka/tasks/check-containers.yml | 1 + ...r-healthchecks-for-kafka-5358d90e8b93bda3.yaml | 6 ++++++ 4 files changed, 23 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-kafka-5358d90e8b93bda3.yaml diff --git a/ansible/roles/kafka/defaults/main.yml b/ansible/roles/kafka/defaults/main.yml index 5a6a42e70a..0cb1641185 100644 --- a/ansible/roles/kafka/defaults/main.yml +++ b/ansible/roles/kafka/defaults/main.yml @@ -12,6 +12,8 @@ kafka_services: KAFKA_HEAP_OPTS: "{{ kafka_heap_opts }}" volumes: "{{ kafka_default_volumes + kafka_extra_volumes }}" dimensions: "{{ kafka_dimensions }}" + healthcheck: "{{ kafka_healthcheck }}" + #################### # Kafka @@ -30,6 +32,19 @@ kafka_tag: "{{ openstack_tag }}" kafka_image_full: "{{ kafka_image }}:{{ kafka_tag }}" kafka_dimensions: "{{ default_container_dimensions }}" +kafka_enable_healthchecks: "{{ enable_container_healthchecks }}" +kafka_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +kafka_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +kafka_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +kafka_healthcheck_test: ["CMD-SHELL", "healthcheck_listen java {{ kafka_port }}"] +kafka_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +kafka_healthcheck: + interval: "{{ kafka_healthcheck_interval }}" + retries: "{{ kafka_healthcheck_retries }}" + start_period: "{{ kafka_healthcheck_start_period }}" + test: "{% if kafka_enable_healthchecks | bool %}{{ kafka_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ kafka_healthcheck_timeout }}" + kafka_default_volumes: - "{{ node_config_directory }}/kafka/:{{ container_config_directory }}/" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/kafka/handlers/main.yml b/ansible/roles/kafka/handlers/main.yml index 28b45dc303..132de1e048 100644 --- a/ansible/roles/kafka/handlers/main.yml +++ b/ansible/roles/kafka/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/kafka/tasks/check-containers.yml b/ansible/roles/kafka/tasks/check-containers.yml index 1e285db046..f383d0813f 100644 --- a/ansible/roles/kafka/tasks/check-containers.yml +++ b/ansible/roles/kafka/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-kafka-5358d90e8b93bda3.yaml b/releasenotes/notes/implement-docker-healthchecks-for-kafka-5358d90e8b93bda3.yaml new file mode 100644 index 0000000000..131bcc727e --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-kafka-5358d90e8b93bda3.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for kafka services. + See `blueprint + `__