diff --git a/ansible/roles/blazar/defaults/main.yml b/ansible/roles/blazar/defaults/main.yml index 0d4749df46..2ad285215a 100644 --- a/ansible/roles/blazar/defaults/main.yml +++ b/ansible/roles/blazar/defaults/main.yml @@ -9,6 +9,7 @@ blazar_services: image: "{{ blazar_api_image_full }}" volumes: "{{ blazar_api_default_volumes + blazar_api_extra_volumes }}" dimensions: "{{ blazar_api_dimensions }}" + healthcheck: "{{ blazar_api_healthcheck }}" haproxy: blazar_api: enabled: "{{ enable_blazar }}" @@ -27,6 +28,7 @@ blazar_services: image: "{{ blazar_manager_image_full }}" volumes: "{{ blazar_manager_default_volumes + blazar_manager_extra_volumes }}" dimensions: "{{ blazar_manager_dimensions }}" + healthcheck: "{{ blazar_manager_healthcheck }}" #################### @@ -59,6 +61,34 @@ blazar_api_image_full: "{{ blazar_api_image }}:{{ blazar_api_tag }}" blazar_api_dimensions: "{{ default_container_dimensions }}" blazar_manager_dimensions: "{{ default_container_dimensions }}" +blazar_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +blazar_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +blazar_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +blazar_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +# NOTE(wuchunyang): we don't use healthcheck_url because the api returns 401(Unauthorized) which is failed. +blazar_api_healthcheck_test: ["CMD-SHELL", "healthcheck_listen blazar-api {{ blazar_api_port }}"] +blazar_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +blazar_api_healthcheck: + interval: "{{ blazar_api_healthcheck_interval }}" + retries: "{{ blazar_api_healthcheck_retries }}" + start_period: "{{ blazar_api_healthcheck_start_period }}" + test: "{% if blazar_api_enable_healthchecks | bool %}{{ blazar_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ blazar_api_healthcheck_timeout }}" + +blazar_manager_enable_healthchecks: "{{ enable_container_healthchecks }}" +blazar_manager_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +blazar_manager_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +blazar_manager_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +blazar_manager_healthcheck_test: ["CMD-SHELL", "healthcheck_port blazar-manager {{ om_rpc_port }}"] +blazar_manager_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +blazar_manager_healthcheck: + interval: "{{ blazar_manager_healthcheck_interval }}" + retries: "{{ blazar_manager_healthcheck_retries }}" + start_period: "{{ blazar_manager_healthcheck_start_period }}" + test: "{% if blazar_manager_enable_healthchecks | bool %}{{ blazar_manager_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ blazar_manager_healthcheck_timeout }}" + + blazar_api_default_volumes: - "{{ node_config_directory }}/blazar-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/blazar/handlers/main.yml b/ansible/roles/blazar/handlers/main.yml index c1559f8a55..b42afd415b 100644 --- a/ansible/roles/blazar/handlers/main.yml +++ b/ansible/roles/blazar/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/blazar/tasks/check-containers.yml b/ansible/roles/blazar/tasks/check-containers.yml index 4fb1d8b68c..79b0c6cc03 100644 --- a/ansible/roles/blazar/tasks/check-containers.yml +++ b/ansible/roles/blazar/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-blazar-88fb90398a249e18.yaml b/releasenotes/notes/implement-docker-healthchecks-for-blazar-88fb90398a249e18.yaml new file mode 100644 index 0000000000..60d765d266 --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-blazar-88fb90398a249e18.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for blazar services. + See `blueprint + `__