From 5c2d1c90be7f41edc2176c11588818970bd12c95 Mon Sep 17 00:00:00 2001 From: LinPeiWen <591171850@qq.com> Date: Tue, 2 Mar 2021 12:11:02 +0000 Subject: [PATCH] Use Docker healthchecks for octavia services This change enables the use of Docker healthchecks for octavia services. Implements: blueprint container-health-check Change-Id: I2ec11544b0e9c66a1821bfe0f9a40a9e9d88033b --- ansible/roles/octavia/defaults/main.yml | 56 +++++++++++++++++++ ansible/roles/octavia/handlers/main.yml | 4 ++ .../roles/octavia/tasks/check-containers.yml | 1 + ...thchecks-for-octavia-add6a52fad7a09b9.yaml | 6 ++ 4 files changed, 67 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-octavia-add6a52fad7a09b9.yaml diff --git a/ansible/roles/octavia/defaults/main.yml b/ansible/roles/octavia/defaults/main.yml index e04b2eb0a6..4b381823f3 100644 --- a/ansible/roles/octavia/defaults/main.yml +++ b/ansible/roles/octavia/defaults/main.yml @@ -9,6 +9,7 @@ octavia_services: image: "{{ octavia_api_image_full }}" volumes: "{{ octavia_api_default_volumes + octavia_api_extra_volumes }}" dimensions: "{{ octavia_api_dimensions }}" + healthcheck: "{{ octavia_api_healthcheck }}" haproxy: octavia_api: enabled: "{{ enable_octavia }}" @@ -27,6 +28,7 @@ octavia_services: image: "{{ octavia_health_manager_image_full }}" volumes: "{{ octavia_health_manager_default_volumes + octavia_health_manager_extra_volumes }}" dimensions: "{{ octavia_health_manager_dimensions }}" + healthcheck: "{{ octavia_health_manager_healthcheck }}" octavia-housekeeping: container_name: octavia_housekeeping group: octavia-housekeeping @@ -34,6 +36,7 @@ octavia_services: image: "{{ octavia_housekeeping_image_full }}" volumes: "{{ octavia_housekeeping_default_volumes + octavia_housekeeping_extra_volumes }}" dimensions: "{{ octavia_housekeeping_dimensions }}" + healthcheck: "{{ octavia_housekeeping_healthcheck }}" octavia-worker: container_name: octavia_worker group: octavia-worker @@ -41,6 +44,7 @@ octavia_services: image: "{{ octavia_worker_image_full }}" volumes: "{{ octavia_worker_default_volumes + octavia_worker_extra_volumes }}" dimensions: "{{ octavia_worker_dimensions }}" + healthcheck: "{{ octavia_worker_healthcheck }}" octavia_required_roles: - load-balancer_observer @@ -85,6 +89,58 @@ octavia_health_manager_dimensions: "{{ default_container_dimensions }}" octavia_housekeeping_dimensions: "{{ default_container_dimensions }}" octavia_worker_dimensions: "{{ default_container_dimensions }}" +octavia_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +octavia_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +octavia_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +octavia_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +octavia_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ octavia_api_listen_port }}"] +octavia_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +octavia_api_healthcheck: + interval: "{{ octavia_api_healthcheck_interval }}" + retries: "{{ octavia_api_healthcheck_retries }}" + start_period: "{{ octavia_api_healthcheck_start_period }}" + test: "{% if octavia_api_enable_healthchecks | bool %}{{ octavia_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ octavia_api_healthcheck_timeout }}" + +octavia_health_manager_enable_healthchecks: "{{ enable_container_healthchecks }}" +octavia_health_manager_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +octavia_health_manager_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +octavia_health_manager_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +octavia_health_manager_healthcheck_test: ["CMD-SHELL", "healthcheck_port octavia-health-manager {{ database_port }}"] +octavia_health_manager_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +octavia_health_manager_healthcheck: + interval: "{{ octavia_health_manager_healthcheck_interval }}" + retries: "{{ octavia_health_manager_healthcheck_retries }}" + start_period: "{{ octavia_health_manager_healthcheck_start_period }}" + test: "{% if octavia_health_manager_enable_healthchecks | bool %}{{ octavia_health_manager_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ octavia_health_manager_healthcheck_timeout }}" + +octavia_housekeeping_enable_healthchecks: "{{ enable_container_healthchecks }}" +octavia_housekeeping_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +octavia_housekeeping_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +octavia_housekeeping_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +octavia_housekeeping_healthcheck_test: ["CMD-SHELL", "healthcheck_port octavia-housekeeping {{ database_port }}"] +octavia_housekeeping_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +octavia_housekeeping_healthcheck: + interval: "{{ octavia_housekeeping_healthcheck_interval }}" + retries: "{{ octavia_housekeeping_healthcheck_retries }}" + start_period: "{{ octavia_housekeeping_healthcheck_start_period }}" + test: "{% if octavia_housekeeping_enable_healthchecks | bool %}{{ octavia_housekeeping_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ octavia_housekeeping_healthcheck_timeout }}" + +octavia_worker_enable_healthchecks: "{{ enable_container_healthchecks }}" +octavia_worker_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +octavia_worker_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +octavia_worker_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +octavia_worker_healthcheck_test: ["CMD-SHELL", "healthcheck_port octavia-worker {{ om_rpc_port }}"] +octavia_worker_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +octavia_worker_healthcheck: + interval: "{{ octavia_worker_healthcheck_interval }}" + retries: "{{ octavia_worker_healthcheck_retries }}" + start_period: "{{ octavia_worker_healthcheck_start_period }}" + test: "{% if octavia_worker_enable_healthchecks | bool %}{{ octavia_worker_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ octavia_worker_healthcheck_timeout }}" + octavia_api_default_volumes: - "{{ node_config_directory }}/octavia-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/octavia/handlers/main.yml b/ansible/roles/octavia/handlers/main.yml index 1f856365b5..a8791b2e8b 100644 --- a/ansible/roles/octavia/handlers/main.yml +++ b/ansible/roles/octavia/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,5 +59,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/octavia/tasks/check-containers.yml b/ansible/roles/octavia/tasks/check-containers.yml index e55da929f7..1c3a518e34 100644 --- a/ansible/roles/octavia/tasks/check-containers.yml +++ b/ansible/roles/octavia/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-octavia-add6a52fad7a09b9.yaml b/releasenotes/notes/implement-docker-healthchecks-for-octavia-add6a52fad7a09b9.yaml new file mode 100644 index 0000000000..bff099f6b3 --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-octavia-add6a52fad7a09b9.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for octavia services. + See `blueprint + `__