From 9d662382858bc7e0cc965ad79ecf7998550fdd02 Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Wed, 2 Dec 2020 22:04:13 +0800 Subject: [PATCH] Use Docker healthchecks for barbican services This change enables the use of Docker healthchecks for barbican services. Implements: blueprint container-health-check Change-Id: Iffda6569103f95733bd7fb80aef31c6a608a55b7 --- ansible/roles/barbican/defaults/main.yml | 42 +++++++++++++++++++ ansible/roles/barbican/handlers/main.yml | 3 ++ .../roles/barbican/tasks/check-containers.yml | 1 + ...hchecks-for-barbican-8cccb703a7c8d674.yaml | 6 +++ 4 files changed, 52 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-barbican-8cccb703a7c8d674.yaml diff --git a/ansible/roles/barbican/defaults/main.yml b/ansible/roles/barbican/defaults/main.yml index 491d9c3fe5..ccbbd04988 100644 --- a/ansible/roles/barbican/defaults/main.yml +++ b/ansible/roles/barbican/defaults/main.yml @@ -9,6 +9,7 @@ barbican_services: image: "{{ barbican_api_image_full }}" volumes: "{{ barbican_api_default_volumes + barbican_api_extra_volumes }}" dimensions: "{{ barbican_api_dimensions }}" + healthcheck: "{{ barbican_api_healthcheck }}" haproxy: barbican_api: enabled: "{{ enable_barbican }}" @@ -31,6 +32,7 @@ barbican_services: image: "{{ barbican_keystone_listener_image_full }}" volumes: "{{ barbican_keystone_listener_default_volumes + barbican_keystone_listener_extra_volumes }}" dimensions: "{{ barbican_keystone_listener_dimensions }}" + healthcheck: "{{ barbican_keystone_listener_healthcheck }}" barbican-worker: container_name: barbican_worker group: barbican-worker @@ -38,6 +40,7 @@ barbican_services: image: "{{ barbican_worker_image_full }}" volumes: "{{ barbican_worker_default_volumes + barbican_worker_extra_volumes }}" dimensions: "{{ barbican_worker_dimensions }}" + healthcheck: "{{ barbican_worker_healthcheck }}" #################### @@ -70,6 +73,45 @@ barbican_api_dimensions: "{{ default_container_dimensions }}" barbican_keystone_listener_dimensions: "{{ default_container_dimensions }}" barbican_worker_dimensions: "{{ default_container_dimensions }}" +barbican_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +barbican_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +barbican_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +barbican_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +barbican_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl {{ 'https' if barbican_enable_tls_backend | bool else 'http' }}://{{ api_interface_address | put_address_in_context('url') }}:{{ barbican_api_listen_port}}"] +barbican_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +barbican_api_healthcheck: + interval: "{{ barbican_api_healthcheck_interval }}" + retries: "{{ barbican_api_healthcheck_retries }}" + start_period: "{{ barbican_api_healthcheck_start_period }}" + test: "{% if barbican_api_enable_healthchecks | bool %}{{ barbican_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ barbican_api_healthcheck_timeout }}" + +barbican_keystone_listener_enable_healthchecks: "{{ enable_container_healthchecks }}" +barbican_keystone_listener_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +barbican_keystone_listener_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +barbican_keystone_listener_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +barbican_keystone_listener_healthcheck_test: ["CMD-SHELL", "healthcheck_port barbican-keystone-listener {{ om_rpc_port }}"] +barbican_keystone_listener_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +barbican_keystone_listener_healthcheck: + interval: "{{ barbican_keystone_listener_healthcheck_interval }}" + retries: "{{ barbican_keystone_listener_healthcheck_retries }}" + start_period: "{{ barbican_keystone_listener_healthcheck_start_period }}" + test: "{% if barbican_keystone_listener_enable_healthchecks | bool %}{{ barbican_keystone_listener_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ barbican_keystone_listener_healthcheck_timeout }}" + +barbican_worker_enable_healthchecks: "{{ enable_container_healthchecks }}" +barbican_worker_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +barbican_worker_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +barbican_worker_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +barbican_worker_healthcheck_test: ["CMD-SHELL", "healthcheck_port barbican-worker {{ om_rpc_port }}"] +barbican_worker_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +barbican_worker_healthcheck: + interval: "{{ barbican_worker_healthcheck_interval }}" + retries: "{{ barbican_worker_healthcheck_retries }}" + start_period: "{{ barbican_worker_healthcheck_start_period }}" + test: "{% if barbican_worker_enable_healthchecks | bool %}{{ barbican_worker_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ barbican_worker_healthcheck_timeout }}" + barbican_api_default_volumes: - "{{ node_config_directory }}/barbican-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/barbican/handlers/main.yml b/ansible/roles/barbican/handlers/main.yml index 5b4e487667..577f3f7473 100644 --- a/ansible/roles/barbican/handlers/main.yml +++ b/ansible/roles/barbican/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,5 +43,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/barbican/tasks/check-containers.yml b/ansible/roles/barbican/tasks/check-containers.yml index 0afc847261..42b241d375 100644 --- a/ansible/roles/barbican/tasks/check-containers.yml +++ b/ansible/roles/barbican/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-barbican-8cccb703a7c8d674.yaml b/releasenotes/notes/implement-docker-healthchecks-for-barbican-8cccb703a7c8d674.yaml new file mode 100644 index 0000000000..bd4b64c976 --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-barbican-8cccb703a7c8d674.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for barbican services. + See `blueprint + `__