From cb537eb8d3e8ee7002265a694772027cea57ac41 Mon Sep 17 00:00:00 2001 From: LinPeiWen <591171850@qq.com> Date: Sat, 6 Mar 2021 16:31:29 +0000 Subject: [PATCH] Use Docker healthchecks for ironic services This change enables the use of Docker healthchecks for ironic services. Implements: blueprint container-health-check Change-Id: If0a11db5470899c3a0e69ca94fdd0903daadcf8b --- ansible/roles/ironic/defaults/main.yml | 56 +++++++++++++++++++ ansible/roles/ironic/handlers/main.yml | 4 ++ .../roles/ironic/tasks/check-containers.yml | 1 + ...lthchecks-for-ironic-26df3f8c96ab70c7.yaml | 6 ++ 4 files changed, 67 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-ironic-26df3f8c96ab70c7.yaml diff --git a/ansible/roles/ironic/defaults/main.yml b/ansible/roles/ironic/defaults/main.yml index 7899462806..414889c85b 100644 --- a/ansible/roles/ironic/defaults/main.yml +++ b/ansible/roles/ironic/defaults/main.yml @@ -9,6 +9,7 @@ ironic_services: image: "{{ ironic_api_image_full }}" volumes: "{{ ironic_api_default_volumes + ironic_api_extra_volumes }}" dimensions: "{{ ironic_api_dimensions }}" + healthcheck: "{{ ironic_api_healthcheck }}" haproxy: ironic_api: enabled: "{{ enable_ironic }}" @@ -32,6 +33,7 @@ ironic_services: privileged: True volumes: "{{ ironic_conductor_default_volumes + ironic_conductor_extra_volumes }}" dimensions: "{{ ironic_conductor_dimensions }}" + healthcheck: "{{ ironic_conductor_healthcheck }}" ironic-inspector: container_name: ironic_inspector group: ironic-inspector @@ -40,6 +42,7 @@ ironic_services: privileged: True volumes: "{{ ironic_inspector_default_volumes + ironic_inspector_extra_volumes }}" dimensions: "{{ ironic_inspector_dimensions }}" + healthcheck: "{{ ironic_inspector_healthcheck }}" haproxy: ironic_inspector: enabled: "{{ enable_ironic }}" @@ -67,6 +70,7 @@ ironic_services: image: "{{ ironic_pxe_image_full }}" volumes: "{{ ironic_ipxe_default_volumes + ironic_ipxe_extra_volumes }}" dimensions: "{{ ironic_ipxe_dimensions }}" + healthcheck: "{{ ironic_ipxe_healthcheck }}" ironic-dnsmasq: container_name: ironic_dnsmasq group: ironic-inspector @@ -123,6 +127,58 @@ ironic_ipxe_dimensions: "{{ default_container_dimensions }}" ironic_inspector_dimensions: "{{ default_container_dimensions }}" ironic_dnsmasq_dimensions: "{{ default_container_dimensions }}" +ironic_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +ironic_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +ironic_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +ironic_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +ironic_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ ironic_api_listen_port }}"] +ironic_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +ironic_api_healthcheck: + interval: "{{ ironic_api_healthcheck_interval }}" + retries: "{{ ironic_api_healthcheck_retries }}" + start_period: "{{ ironic_api_healthcheck_start_period }}" + test: "{% if ironic_api_enable_healthchecks | bool %}{{ ironic_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ ironic_api_healthcheck_timeout }}" + +ironic_conductor_enable_healthchecks: "{{ enable_container_healthchecks }}" +ironic_conductor_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +ironic_conductor_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +ironic_conductor_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +ironic_conductor_healthcheck_test: ["CMD-SHELL", "healthcheck_port ironic-conductor {{ om_rpc_port }}"] +ironic_conductor_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +ironic_conductor_healthcheck: + interval: "{{ ironic_conductor_healthcheck_interval }}" + retries: "{{ ironic_conductor_healthcheck_retries }}" + start_period: "{{ ironic_conductor_healthcheck_start_period }}" + test: "{% if ironic_conductor_enable_healthchecks | bool %}{{ ironic_conductor_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ ironic_conductor_healthcheck_timeout }}" + +ironic_inspector_enable_healthchecks: "{{ enable_container_healthchecks }}" +ironic_inspector_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +ironic_inspector_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +ironic_inspector_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +ironic_inspector_healthcheck_test: ["CMD-SHELL", "healthcheck_port ironic-inspector {{ om_rpc_port }}"] +ironic_inspector_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +ironic_inspector_healthcheck: + interval: "{{ ironic_inspector_healthcheck_interval }}" + retries: "{{ ironic_inspector_healthcheck_retries }}" + start_period: "{{ ironic_inspector_healthcheck_start_period }}" + test: "{% if ironic_inspector_enable_healthchecks | bool %}{{ ironic_inspector_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ ironic_inspector_healthcheck_timeout }}" + +ironic_ipxe_enable_healthchecks: "{{ enable_container_healthchecks }}" +ironic_ipxe_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +ironic_ipxe_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +ironic_ipxe_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +ironic_ipxe_healthcheck_test: ["CMD-SHELL", "healthcheck_listen httpd {{ ironic_ipxe_port }}"] +ironic_ipxe_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +ironic_ipxe_healthcheck: + interval: "{{ ironic_ipxe_healthcheck_interval }}" + retries: "{{ ironic_ipxe_healthcheck_retries }}" + start_period: "{{ ironic_ipxe_healthcheck_start_period }}" + test: "{% if ironic_ipxe_enable_healthchecks | bool %}{{ ironic_ipxe_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ ironic_ipxe_healthcheck_timeout }}" + ironic_api_default_volumes: - "{{ node_config_directory }}/ironic-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/ironic/handlers/main.yml b/ansible/roles/ironic/handlers/main.yml index a1b701506e..cf0a4967f5 100644 --- a/ansible/roles/ironic/handlers/main.yml +++ b/ansible/roles/ironic/handlers/main.yml @@ -12,6 +12,7 @@ privileged: "{{ service.privileged | default(False) }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -27,6 +28,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -63,6 +65,7 @@ privileged: "{{ service.privileged | default(False) }}" volumes: "{{ service.volumes|reject('equalto', '')|list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -93,6 +96,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" diff --git a/ansible/roles/ironic/tasks/check-containers.yml b/ansible/roles/ironic/tasks/check-containers.yml index 273cd3ae20..da2c4cf1ea 100644 --- a/ansible/roles/ironic/tasks/check-containers.yml +++ b/ansible/roles/ironic/tasks/check-containers.yml @@ -10,6 +10,7 @@ cap_add: "{{ item.value.cap_add|default([]) }}" 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-ironic-26df3f8c96ab70c7.yaml b/releasenotes/notes/implement-docker-healthchecks-for-ironic-26df3f8c96ab70c7.yaml new file mode 100644 index 0000000000..394346551d --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-ironic-26df3f8c96ab70c7.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for ironic services. + See `blueprint + `__