From 1e9506a45bc4159a4fab957b45c652eb7c3dae21 Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Tue, 1 Dec 2020 15:21:29 +0800 Subject: [PATCH] Use Docker healthchecks for cinder services This change enables the use of Docker healthchecks for cinder services. Change-Id: I9bef02a66aae2024052078d8354059ab28a71e1e Implements: blueprint container-health-check --- ansible/roles/cinder/defaults/main.yml | 56 +++++++++++++++++++ ansible/roles/cinder/handlers/main.yml | 4 ++ .../roles/cinder/tasks/check-containers.yml | 1 + ...lthchecks-for-cinder-518d4d6457703b7e.yaml | 6 ++ 4 files changed, 67 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-cinder-518d4d6457703b7e.yaml diff --git a/ansible/roles/cinder/defaults/main.yml b/ansible/roles/cinder/defaults/main.yml index ba447d6a6b..4a318b6743 100644 --- a/ansible/roles/cinder/defaults/main.yml +++ b/ansible/roles/cinder/defaults/main.yml @@ -9,6 +9,7 @@ cinder_services: image: "{{ cinder_api_image_full }}" volumes: "{{ cinder_api_default_volumes + cinder_api_extra_volumes }}" dimensions: "{{ cinder_api_dimensions }}" + healthcheck: "{{ cinder_api_healthcheck }}" haproxy: cinder_api: enabled: "{{ enable_cinder }}" @@ -31,6 +32,7 @@ cinder_services: image: "{{ cinder_scheduler_image_full }}" volumes: "{{ cinder_scheduler_default_volumes + cinder_scheduler_extra_volumes }}" dimensions: "{{ cinder_scheduler_dimensions }}" + healthcheck: "{{ cinder_scheduler_healthcheck }}" cinder-volume: container_name: cinder_volume group: cinder-volume @@ -41,6 +43,7 @@ cinder_services: tmpfs: "{{ cinder_volume_tmpfs }}" volumes: "{{ cinder_volume_default_volumes + cinder_volume_extra_volumes }}" dimensions: "{{ cinder_volume_dimensions }}" + healthcheck: "{{ cinder_volume_healthcheck }}" cinder-backup: container_name: cinder_backup group: cinder-backup @@ -49,6 +52,7 @@ cinder_services: privileged: True volumes: "{{ cinder_backup_default_volumes + cinder_backup_extra_volumes }}" dimensions: "{{ cinder_backup_dimensions }}" + healthcheck: "{{ cinder_backup_healthcheck }}" #################### # Database @@ -84,6 +88,58 @@ cinder_backup_dimensions: "{{ default_container_dimensions }}" cinder_scheduler_dimensions: "{{ default_container_dimensions }}" cinder_volume_dimensions: "{{ default_container_dimensions }}" +cinder_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +cinder_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +cinder_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +cinder_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +cinder_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl {{ 'https' if cinder_enable_tls_backend | bool else 'http' }}://{{ api_interface_address | put_address_in_context('url') }}:{{ cinder_api_listen_port}}"] +cinder_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +cinder_api_healthcheck: + interval: "{{ cinder_api_healthcheck_interval }}" + retries: "{{ cinder_api_healthcheck_retries }}" + start_period: "{{ cinder_api_healthcheck_start_period }}" + test: "{% if cinder_api_enable_healthchecks | bool %}{{ cinder_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ cinder_api_healthcheck_timeout }}" + +cinder_scheduler_enable_healthchecks: "{{ enable_container_healthchecks }}" +cinder_scheduler_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +cinder_scheduler_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +cinder_scheduler_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +cinder_scheduler_healthcheck_test: ["CMD-SHELL", "healthcheck_port cinder-scheduler {{ om_rpc_port }}"] +cinder_scheduler_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +cinder_scheduler_healthcheck: + interval: "{{ cinder_scheduler_healthcheck_interval }}" + retries: "{{ cinder_scheduler_healthcheck_retries }}" + start_period: "{{ cinder_scheduler_healthcheck_start_period }}" + test: "{% if cinder_scheduler_enable_healthchecks | bool %}{{ cinder_scheduler_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ cinder_scheduler_healthcheck_timeout }}" + +cinder_volume_enable_healthchecks: "{{ enable_container_healthchecks }}" +cinder_volume_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +cinder_volume_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +cinder_volume_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +cinder_volume_healthcheck_test: ["CMD-SHELL", "healthcheck_port cinder-volume {{ om_rpc_port }}"] +cinder_volume_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +cinder_volume_healthcheck: + interval: "{{ cinder_volume_healthcheck_interval }}" + retries: "{{ cinder_volume_healthcheck_retries }}" + start_period: "{{ cinder_volume_healthcheck_start_period }}" + test: "{% if cinder_volume_enable_healthchecks | bool %}{{ cinder_volume_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ cinder_volume_healthcheck_timeout }}" + +cinder_backup_enable_healthchecks: "{{ enable_container_healthchecks }}" +cinder_backup_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +cinder_backup_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +cinder_backup_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +cinder_backup_healthcheck_test: ["CMD-SHELL", "healthcheck_port cinder-backup {{ om_rpc_port }}"] +cinder_backup_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +cinder_backup_healthcheck: + interval: "{{ cinder_backup_healthcheck_interval }}" + retries: "{{ cinder_backup_healthcheck_retries }}" + start_period: "{{ cinder_backup_healthcheck_start_period }}" + test: "{% if cinder_backup_enable_healthchecks | bool %}{{ cinder_backup_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ cinder_backup_healthcheck_timeout }}" + cinder_api_default_volumes: - "{{ node_config_directory }}/cinder-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/cinder/handlers/main.yml b/ansible/roles/cinder/handlers/main.yml index ddad53b805..ecd3b8f069 100644 --- a/ansible/roles/cinder/handlers/main.yml +++ b/ansible/roles/cinder/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" @@ -44,6 +46,7 @@ tmpfs: "{{ service.tmpfs | default(omit) }}" volumes: "{{ service.volumes | reject('equalto', '') | list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -60,5 +63,6 @@ privileged: "{{ service.privileged | default(False) }}" volumes: "{{ service.volumes | reject('equalto', '') | list }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" diff --git a/ansible/roles/cinder/tasks/check-containers.yml b/ansible/roles/cinder/tasks/check-containers.yml index 9f483539f0..3f71fa8f49 100644 --- a/ansible/roles/cinder/tasks/check-containers.yml +++ b/ansible/roles/cinder/tasks/check-containers.yml @@ -9,6 +9,7 @@ tmpfs: "{{ item.value.tmpfs | default(omit) }}" volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" + healthcheck: "{{ item.value.healthcheck | default(omit) }}" privileged: "{{ item.value.privileged | default(False) }}" ipc_mode: "{{ item.value.ipc_mode | default('') }}" when: diff --git a/releasenotes/notes/implement-docker-healthchecks-for-cinder-518d4d6457703b7e.yaml b/releasenotes/notes/implement-docker-healthchecks-for-cinder-518d4d6457703b7e.yaml new file mode 100644 index 0000000000..e425db8e5b --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-cinder-518d4d6457703b7e.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for cinder services. + See `blueprint + `__