From e6e7e4d5d637da6c05fd86c0ae966a17b4a654c4 Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Mon, 21 Dec 2020 11:16:39 +0800 Subject: [PATCH] Use Docker healthchecks for cloudkitty services This change enables the use of Docker healthchecks for cloudkitty services. Implements: blueprint container-health-check Change-Id: I19892035382ffff5200e88da53408a19e72c9d68 --- ansible/roles/cloudkitty/defaults/main.yml | 28 +++++++++++++++++++ ansible/roles/cloudkitty/handlers/main.yml | 2 ++ .../cloudkitty/tasks/check-containers.yml | 1 + ...hecks-for-cloudkitty-a032d6408b7eea26.yaml | 6 ++++ 4 files changed, 37 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-cloudkitty-a032d6408b7eea26.yaml diff --git a/ansible/roles/cloudkitty/defaults/main.yml b/ansible/roles/cloudkitty/defaults/main.yml index 512c693b2a..a40f0eb798 100644 --- a/ansible/roles/cloudkitty/defaults/main.yml +++ b/ansible/roles/cloudkitty/defaults/main.yml @@ -9,6 +9,7 @@ cloudkitty_services: enabled: True volumes: "{{ cloudkitty_api_default_volumes + cloudkitty_api_extra_volumes }}" dimensions: "{{ cloudkitty_api_dimensions }}" + healthcheck: "{{ cloudkitty_api_healthcheck }}" haproxy: cloudkitty_api: enabled: "{{ enable_cloudkitty }}" @@ -27,6 +28,7 @@ cloudkitty_services: enabled: True volumes: "{{ cloudkitty_processor_default_volumes + cloudkitty_processor_extra_volumes }}" dimensions: "{{ cloudkitty_processor_dimensions }}" + healthcheck: "{{ cloudkitty_processor_healthcheck }}" #################### @@ -67,6 +69,32 @@ cloudkitty_processor_default_volumes: - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/cloudkitty/cloudkitty:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/cloudkitty' if cloudkitty_dev_mode | bool else '' }}" +cloudkitty_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +cloudkitty_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +cloudkitty_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +cloudkitty_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +cloudkitty_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ cloudkitty_api_port}}"] +cloudkitty_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +cloudkitty_api_healthcheck: + interval: "{{ cloudkitty_api_healthcheck_interval }}" + retries: "{{ cloudkitty_api_healthcheck_retries }}" + start_period: "{{ cloudkitty_api_healthcheck_start_period }}" + test: "{% if cloudkitty_api_enable_healthchecks | bool %}{{ cloudkitty_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ cloudkitty_api_healthcheck_timeout }}" + +cloudkitty_processor_enable_healthchecks: "{{ enable_container_healthchecks }}" +cloudkitty_processor_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +cloudkitty_processor_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +cloudkitty_processor_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +cloudkitty_processor_healthcheck_test: ["CMD-SHELL", "healthcheck_port cloudkitty-processor {{ om_rpc_port }}"] +cloudkitty_processor_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +cloudkitty_processor_healthcheck: + interval: "{{ cloudkitty_processor_healthcheck_interval }}" + retries: "{{ cloudkitty_processor_healthcheck_retries }}" + start_period: "{{ cloudkitty_processor_healthcheck_start_period }}" + test: "{% if cloudkitty_processor_enable_healthchecks | bool %}{{ cloudkitty_processor_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ cloudkitty_processor_healthcheck_timeout }}" + cloudkitty_extra_volumes: "{{ default_extra_volumes }}" cloudkitty_processor_extra_volumes: "{{ cloudkitty_extra_volumes }}" cloudkitty_api_extra_volumes: "{{ cloudkitty_extra_volumes }}" diff --git a/ansible/roles/cloudkitty/handlers/main.yml b/ansible/roles/cloudkitty/handlers/main.yml index a49a0319ee..686a633dcf 100644 --- a/ansible/roles/cloudkitty/handlers/main.yml +++ b/ansible/roles/cloudkitty/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,5 +27,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/cloudkitty/tasks/check-containers.yml b/ansible/roles/cloudkitty/tasks/check-containers.yml index 7f65aa85b2..c680daf1d9 100644 --- a/ansible/roles/cloudkitty/tasks/check-containers.yml +++ b/ansible/roles/cloudkitty/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-cloudkitty-a032d6408b7eea26.yaml b/releasenotes/notes/implement-docker-healthchecks-for-cloudkitty-a032d6408b7eea26.yaml new file mode 100644 index 0000000000..f7b88dded4 --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-cloudkitty-a032d6408b7eea26.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for cloudkitty services. + See `blueprint + `__