From 2518e926d995024f62e117bdc36692649bd03596 Mon Sep 17 00:00:00 2001 From: LinPeiWen <591171850@qq.com> Date: Tue, 2 Mar 2021 11:04:31 +0000 Subject: [PATCH] Use Docker healthchecks for trove services This change enables the use of Docker healthchecks for trove services. Implements: blueprint container-health-check Change-Id: I55badd93f92f82e020ef80b06c788600e597d068 --- ansible/roles/trove/defaults/main.yml | 42 +++++++++++++++++++ ansible/roles/trove/handlers/main.yml | 3 ++ .../roles/trove/tasks/check-containers.yml | 1 + ...althchecks-for-trove-7920c841f784b2e1.yaml | 6 +++ 4 files changed, 52 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-trove-7920c841f784b2e1.yaml diff --git a/ansible/roles/trove/defaults/main.yml b/ansible/roles/trove/defaults/main.yml index 75fb64cd5b..a7ee7eaca0 100644 --- a/ansible/roles/trove/defaults/main.yml +++ b/ansible/roles/trove/defaults/main.yml @@ -9,6 +9,7 @@ trove_services: image: "{{ trove_api_image_full }}" volumes: "{{ trove_api_default_volumes + trove_api_extra_volumes }}" dimensions: "{{ trove_api_dimensions }}" + healthcheck: "{{ trove_api_healthcheck }}" haproxy: trove_api: enabled: "{{ enable_trove }}" @@ -27,6 +28,7 @@ trove_services: image: "{{ trove_conductor_image_full }}" volumes: "{{ trove_conductor_default_volumes + trove_conductor_extra_volumes }}" dimensions: "{{ trove_conductor_dimensions }}" + healthcheck: "{{ trove_conductor_healthcheck }}" trove-taskmanager: container_name: trove_taskmanager group: trove-taskmanager @@ -34,6 +36,7 @@ trove_services: image: "{{ trove_taskmanager_image_full }}" volumes: "{{ trove_taskmanager_default_volumes + trove_taskmanager_extra_volumes }}" dimensions: "{{ trove_taskmanager_dimensions }}" + healthcheck: "{{ trove_taskmanager_healthcheck }}" #################### @@ -66,6 +69,45 @@ trove_api_dimensions: "{{ default_container_dimensions }}" trove_conductor_dimensions: "{{ default_container_dimensions }}" trove_taskmanager_dimensions: "{{ default_container_dimensions }}" +trove_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +trove_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +trove_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +trove_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +trove_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ trove_api_port }}"] +trove_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +trove_api_healthcheck: + interval: "{{ trove_api_healthcheck_interval }}" + retries: "{{ trove_api_healthcheck_retries }}" + start_period: "{{ trove_api_healthcheck_start_period }}" + test: "{% if trove_api_enable_healthchecks | bool %}{{ trove_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ trove_api_healthcheck_timeout }}" + +trove_conductor_enable_healthchecks: "{{ enable_container_healthchecks }}" +trove_conductor_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +trove_conductor_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +trove_conductor_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +trove_conductor_healthcheck_test: ["CMD-SHELL", "healthcheck_port trove-conductor {{ om_rpc_port }}"] +trove_conductor_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +trove_conductor_healthcheck: + interval: "{{ trove_conductor_healthcheck_interval }}" + retries: "{{ trove_conductor_healthcheck_retries }}" + start_period: "{{ trove_conductor_healthcheck_start_period }}" + test: "{% if trove_conductor_enable_healthchecks | bool %}{{ trove_conductor_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ trove_conductor_healthcheck_timeout }}" + +trove_taskmanager_enable_healthchecks: "{{ enable_container_healthchecks }}" +trove_taskmanager_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +trove_taskmanager_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +trove_taskmanager_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +trove_taskmanager_healthcheck_test: ["CMD-SHELL", "healthcheck_port trove-taskmanager {{ om_rpc_port }}"] +trove_taskmanager_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +trove_taskmanager_healthcheck: + interval: "{{ trove_taskmanager_healthcheck_interval }}" + retries: "{{ trove_taskmanager_healthcheck_retries }}" + start_period: "{{ trove_taskmanager_healthcheck_start_period }}" + test: "{% if trove_taskmanager_enable_healthchecks | bool %}{{ trove_taskmanager_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ trove_taskmanager_healthcheck_timeout }}" + trove_api_default_volumes: - "{{ node_config_directory }}/trove-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/trove/handlers/main.yml b/ansible/roles/trove/handlers/main.yml index 865ab5bf32..10bd498179 100644 --- a/ansible/roles/trove/handlers/main.yml +++ b/ansible/roles/trove/handlers/main.yml @@ -11,6 +11,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -26,6 +27,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -41,5 +43,6 @@ image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" diff --git a/ansible/roles/trove/tasks/check-containers.yml b/ansible/roles/trove/tasks/check-containers.yml index 3bf7ab14cb..32e6303893 100644 --- a/ansible/roles/trove/tasks/check-containers.yml +++ b/ansible/roles/trove/tasks/check-containers.yml @@ -8,6 +8,7 @@ image: "{{ item.value.image }}" volumes: "{{ item.value.volumes|reject('equalto', '')|list }}" 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-trove-7920c841f784b2e1.yaml b/releasenotes/notes/implement-docker-healthchecks-for-trove-7920c841f784b2e1.yaml new file mode 100644 index 0000000000..ee365ab863 --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-trove-7920c841f784b2e1.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for trove services. + See `blueprint + `__