From bca6a34fccf22fbdd66bf5e91ddfcf7687508a50 Mon Sep 17 00:00:00 2001 From: LinPeiWen <591171850@qq.com> Date: Sat, 6 Mar 2021 15:24:24 +0000 Subject: [PATCH] Use Docker healthchecks for vitrage services This change enables the use of Docker healthchecks for vitrage services. Implements: blueprint container-health-check Change-Id: Icd2a8471a08b737352cfe941b5d38b02ed3b19fe --- ansible/roles/vitrage/defaults/main.yml | 70 +++++++++++++++++++ ansible/roles/vitrage/handlers/main.yml | 5 ++ .../roles/vitrage/tasks/check-containers.yml | 1 + ...thchecks-for-vitrage-e2866c51c4b8fb78.yaml | 6 ++ 4 files changed, 82 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-vitrage-e2866c51c4b8fb78.yaml diff --git a/ansible/roles/vitrage/defaults/main.yml b/ansible/roles/vitrage/defaults/main.yml index ba1e795bc4..9f39f5b2a0 100644 --- a/ansible/roles/vitrage/defaults/main.yml +++ b/ansible/roles/vitrage/defaults/main.yml @@ -9,6 +9,7 @@ vitrage_services: image: "{{ vitrage_api_image_full }}" volumes: "{{ vitrage_api_default_volumes + vitrage_api_extra_volumes }}" dimensions: "{{ vitrage_api_dimensions }}" + healthcheck: "{{ vitrage_api_healthcheck }}" haproxy: vitrage_api: enabled: "{{ enable_vitrage }}" @@ -27,6 +28,7 @@ vitrage_services: image: "{{ vitrage_notifier_image_full }}" volumes: "{{ vitrage_notifier_default_volumes + vitrage_notifier_extra_volumes }}" dimensions: "{{ vitrage_notifier_dimensions }}" + healthcheck: "{{ vitrage_notifier_healthcheck }}" vitrage-graph: container_name: vitrage_graph group: vitrage-graph @@ -34,6 +36,7 @@ vitrage_services: image: "{{ vitrage_graph_image_full }}" volumes: "{{ vitrage_graph_default_volumes + vitrage_graph_extra_volumes }}" dimensions: "{{ vitrage_graph_dimensions }}" + healthcheck: "{{ vitrage_graph_healthcheck }}" vitrage-ml: container_name: vitrage_ml group: vitrage-ml @@ -41,6 +44,7 @@ vitrage_services: image: "{{ vitrage_ml_image_full }}" volumes: "{{ vitrage_ml_default_volumes + vitrage_ml_extra_volumes }}" dimensions: "{{ vitrage_ml_dimensions }}" + healthcheck: "{{ vitrage_ml_healthcheck }}" vitrage-persistor: container_name: vitrage_persistor group: vitrage-persistor @@ -48,6 +52,7 @@ vitrage_services: image: "{{ vitrage_persistor_image_full }}" volumes: "{{ vitrage_persistor_default_volumes + vitrage_persistor_extra_volumes }}" dimensions: "{{ vitrage_persistor_dimensions }}" + healthcheck: "{{ vitrage_persistor_healthcheck }}" #################### ## Database @@ -89,6 +94,71 @@ vitrage_graph_dimensions: "{{ default_container_dimensions }}" vitrage_ml_dimensions: "{{ default_container_dimensions }}" vitrage_persistor_dimensions: "{{ default_container_dimensions }}" +vitrage_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +vitrage_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +vitrage_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +vitrage_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +vitrage_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ vitrage_api_port }}"] +vitrage_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +vitrage_api_healthcheck: + interval: "{{ vitrage_api_healthcheck_interval }}" + retries: "{{ vitrage_api_healthcheck_retries }}" + start_period: "{{ vitrage_api_healthcheck_start_period }}" + test: "{% if vitrage_api_enable_healthchecks | bool %}{{ vitrage_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ vitrage_api_healthcheck_timeout }}" + +vitrage_notifier_enable_healthchecks: "{{ enable_container_healthchecks }}" +vitrage_notifier_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +vitrage_notifier_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +vitrage_notifier_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +vitrage_notifier_healthcheck_test: ["CMD-SHELL", "healthcheck_port vitrage-notifier {{ om_rpc_port }}"] +vitrage_notifier_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +vitrage_notifier_healthcheck: + interval: "{{ vitrage_notifier_healthcheck_interval }}" + retries: "{{ vitrage_notifier_healthcheck_retries }}" + start_period: "{{ vitrage_notifier_healthcheck_start_period }}" + test: "{% if vitrage_notifier_enable_healthchecks | bool %}{{ vitrage_notifier_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ vitrage_notifier_healthcheck_timeout }}" + +vitrage_graph_enable_healthchecks: "{{ enable_container_healthchecks }}" +vitrage_graph_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +vitrage_graph_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +vitrage_graph_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +vitrage_graph_healthcheck_test: ["CMD-SHELL", "healthcheck_port vitrage-graph {{ om_rpc_port }}"] +vitrage_graph_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +vitrage_graph_healthcheck: + interval: "{{ vitrage_graph_healthcheck_interval }}" + retries: "{{ vitrage_graph_healthcheck_retries }}" + start_period: "{{ vitrage_graph_healthcheck_start_period }}" + test: "{% if vitrage_graph_enable_healthchecks | bool %}{{ vitrage_graph_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ vitrage_graph_healthcheck_timeout }}" + +vitrage_ml_enable_healthchecks: "{{ enable_container_healthchecks }}" +vitrage_ml_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +vitrage_ml_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +vitrage_ml_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +vitrage_ml_healthcheck_test: ["CMD-SHELL", "healthcheck_port vitrage-ml {{ om_rpc_port }}"] +vitrage_ml_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +vitrage_ml_healthcheck: + interval: "{{ vitrage_ml_healthcheck_interval }}" + retries: "{{ vitrage_ml_healthcheck_retries }}" + start_period: "{{ vitrage_ml_healthcheck_start_period }}" + test: "{% if vitrage_ml_enable_healthchecks | bool %}{{ vitrage_ml_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ vitrage_ml_healthcheck_timeout }}" + +vitrage_persistor_enable_healthchecks: "{{ enable_container_healthchecks }}" +vitrage_persistor_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +vitrage_persistor_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +vitrage_persistor_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +vitrage_persistor_healthcheck_test: ["CMD-SHELL", "healthcheck_port vitrage-persistor {{ om_rpc_port }}"] +vitrage_persistor_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +vitrage_persistor_healthcheck: + interval: "{{ vitrage_persistor_healthcheck_interval }}" + retries: "{{ vitrage_persistor_healthcheck_retries }}" + start_period: "{{ vitrage_persistor_healthcheck_start_period }}" + test: "{% if vitrage_persistor_enable_healthchecks | bool %}{{ vitrage_persistor_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ vitrage_persistor_healthcheck_timeout }}" + vitrage_api_default_volumes: - "{{ node_config_directory }}/vitrage-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/vitrage/handlers/main.yml b/ansible/roles/vitrage/handlers/main.yml index d1f007b6b5..50cdf2aaa1 100644 --- a/ansible/roles/vitrage/handlers/main.yml +++ b/ansible/roles/vitrage/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,6 +43,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes | reject('equalto', '') | list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -56,6 +59,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes | reject('equalto', '') | list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -71,5 +75,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/vitrage/tasks/check-containers.yml b/ansible/roles/vitrage/tasks/check-containers.yml index 4127997d53..5840a73352 100644 --- a/ansible/roles/vitrage/tasks/check-containers.yml +++ b/ansible/roles/vitrage/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-vitrage-e2866c51c4b8fb78.yaml b/releasenotes/notes/implement-docker-healthchecks-for-vitrage-e2866c51c4b8fb78.yaml new file mode 100644 index 0000000000..1eb13b43e9 --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-vitrage-e2866c51c4b8fb78.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for vitrage services. + See `blueprint + `__