From 3e9ad631874a8b076d3731573935d75a9e31f9cf Mon Sep 17 00:00:00 2001 From: LinPeiWen <591171850@qq.com> Date: Wed, 3 Mar 2021 14:02:22 +0000 Subject: [PATCH] Use Docker healthchecks for gnocchi services This change enables the use of Docker healthchecks for gnocchi services. Implements: blueprint container-health-check Change-Id: Ib1eb766d061c376c0bdd693dd6ea1e5b3e3fc02a --- ansible/roles/gnocchi/defaults/main.yml | 42 +++++++++++++++++++ ansible/roles/gnocchi/handlers/main.yml | 3 ++ .../roles/gnocchi/tasks/check-containers.yml | 1 + ...thchecks-for-gnocchi-fa2fa16bcdcc0667.yaml | 6 +++ 4 files changed, 52 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-gnocchi-fa2fa16bcdcc0667.yaml diff --git a/ansible/roles/gnocchi/defaults/main.yml b/ansible/roles/gnocchi/defaults/main.yml index 34ddd43876..7ebfb079a4 100644 --- a/ansible/roles/gnocchi/defaults/main.yml +++ b/ansible/roles/gnocchi/defaults/main.yml @@ -9,6 +9,7 @@ gnocchi_services: image: "{{ gnocchi_api_image_full }}" volumes: "{{ gnocchi_api_default_volumes + gnocchi_api_extra_volumes }}" dimensions: "{{ gnocchi_api_dimensions }}" + healthcheck: "{{ gnocchi_api_healthcheck }}" haproxy: gnocchi_api: enabled: "{{ enable_gnocchi }}" @@ -27,6 +28,7 @@ gnocchi_services: image: "{{ gnocchi_metricd_image_full }}" volumes: "{{ gnocchi_metricd_default_volumes + gnocchi_metricd_extra_volumes }}" dimensions: "{{ gnocchi_metricd_dimensions }}" + healthcheck: "{{ gnocchi_metricd_healthcheck }}" gnocchi-statsd: container_name: gnocchi_statsd group: gnocchi-statsd @@ -34,6 +36,7 @@ gnocchi_services: image: "{{ gnocchi_statsd_image_full }}" volumes: "{{ gnocchi_statsd_default_volumes + gnocchi_statsd_extra_volumes }}" dimensions: "{{ gnocchi_statsd_dimensions }}" + healthcheck: "{{ gnocchi_statsd_healthcheck }}" #################### @@ -73,6 +76,45 @@ gnocchi_api_dimensions: "{{ default_container_dimensions }}" gnocchi_metricd_dimensions: "{{ default_container_dimensions }}" gnocchi_statsd_dimensions: "{{ default_container_dimensions }}" +gnocchi_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +gnocchi_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +gnocchi_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +gnocchi_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +gnocchi_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ gnocchi_api_listen_port }}"] +gnocchi_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +gnocchi_api_healthcheck: + interval: "{{ gnocchi_api_healthcheck_interval }}" + retries: "{{ gnocchi_api_healthcheck_retries }}" + start_period: "{{ gnocchi_api_healthcheck_start_period }}" + test: "{% if gnocchi_api_enable_healthchecks | bool %}{{ gnocchi_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ gnocchi_api_healthcheck_timeout }}" + +gnocchi_metricd_enable_healthchecks: "{{ enable_container_healthchecks }}" +gnocchi_metricd_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +gnocchi_metricd_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +gnocchi_metricd_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +gnocchi_metricd_healthcheck_test: ["CMD-SHELL", "healthcheck_port gnocchi-metricd {{ database_port }}"] +gnocchi_metricd_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +gnocchi_metricd_healthcheck: + interval: "{{ gnocchi_metricd_healthcheck_interval }}" + retries: "{{ gnocchi_metricd_healthcheck_retries }}" + start_period: "{{ gnocchi_metricd_healthcheck_start_period }}" + test: "{% if gnocchi_metricd_enable_healthchecks | bool %}{{ gnocchi_metricd_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ gnocchi_metricd_healthcheck_timeout }}" + +gnocchi_statsd_enable_healthchecks: "{{ enable_container_healthchecks }}" +gnocchi_statsd_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +gnocchi_statsd_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +gnocchi_statsd_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +gnocchi_statsd_healthcheck_test: ["CMD-SHELL", "healthcheck_port gnocchi-statsd {{ database_port }}"] +gnocchi_statsd_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +gnocchi_statsd_healthcheck: + interval: "{{ gnocchi_statsd_healthcheck_interval }}" + retries: "{{ gnocchi_statsd_healthcheck_retries }}" + start_period: "{{ gnocchi_statsd_healthcheck_start_period }}" + test: "{% if gnocchi_statsd_enable_healthchecks | bool %}{{ gnocchi_statsd_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ gnocchi_statsd_healthcheck_timeout }}" + gnocchi_api_default_volumes: - "{{ node_config_directory }}/gnocchi-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/gnocchi/handlers/main.yml b/ansible/roles/gnocchi/handlers/main.yml index d7ca93a660..cc2d5762ae 100644 --- a/ansible/roles/gnocchi/handlers/main.yml +++ b/ansible/roles/gnocchi/handlers/main.yml @@ -11,6 +11,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -26,6 +27,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -41,5 +43,6 @@ image: "{{ service.image }}" volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" diff --git a/ansible/roles/gnocchi/tasks/check-containers.yml b/ansible/roles/gnocchi/tasks/check-containers.yml index 9659330f00..ed92fb1da6 100644 --- a/ansible/roles/gnocchi/tasks/check-containers.yml +++ b/ansible/roles/gnocchi/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) }}" when: - inventory_hostname in groups[item.value.group] - item.value.enabled | bool diff --git a/releasenotes/notes/implement-docker-healthchecks-for-gnocchi-fa2fa16bcdcc0667.yaml b/releasenotes/notes/implement-docker-healthchecks-for-gnocchi-fa2fa16bcdcc0667.yaml new file mode 100644 index 0000000000..1b5ff6e880 --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-gnocchi-fa2fa16bcdcc0667.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for gnocchi services. + See `blueprint + `__