From 26a7fc04c646ed540cfa5c8d2337deb69ec0a42e Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Sat, 20 Feb 2021 10:28:25 -0500 Subject: [PATCH] Use Docker healthchecks for magnum services This change enables the use of Docker healthchecks for magnum services. Implements: blueprint container-health-check Change-Id: I14d862aa599915c781d02b71a0e57d2124de9abc --- ansible/roles/magnum/defaults/main.yml | 28 +++++++++++++++++++ ansible/roles/magnum/handlers/main.yml | 2 ++ .../roles/magnum/tasks/check-containers.yml | 1 + ...lthchecks-for-magnum-0e92b0645fcdeb61.yaml | 6 ++++ 4 files changed, 37 insertions(+) create mode 100644 releasenotes/notes/implement-docker-healthchecks-for-magnum-0e92b0645fcdeb61.yaml diff --git a/ansible/roles/magnum/defaults/main.yml b/ansible/roles/magnum/defaults/main.yml index da7ac8730f..8333bb6734 100644 --- a/ansible/roles/magnum/defaults/main.yml +++ b/ansible/roles/magnum/defaults/main.yml @@ -11,6 +11,7 @@ magnum_services: DUMMY_ENVIRONMENT: kolla_useless_env volumes: "{{ magnum_api_default_volumes + magnum_api_extra_volumes }}" dimensions: "{{ magnum_api_dimensions }}" + healthcheck: "{{ magnum_api_healthcheck }}" haproxy: magnum_api: enabled: "{{ enable_magnum }}" @@ -30,6 +31,7 @@ magnum_services: environment: "{{ magnum_conductor_container_proxy }}" volumes: "{{ magnum_conductor_default_volumes + magnum_conductor_extra_volumes }}" dimensions: "{{ magnum_conductor_dimensions }}" + healthcheck: "{{ magnum_conductor_healthcheck }}" #################### @@ -66,6 +68,32 @@ magnum_conductor_image_full: "{{ magnum_conductor_image }}:{{ magnum_conductor_t magnum_api_dimensions: "{{ default_container_dimensions }}" magnum_conductor_dimensions: "{{ default_container_dimensions }}" +magnum_api_enable_healthchecks: "{{ enable_container_healthchecks }}" +magnum_api_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +magnum_api_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +magnum_api_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +magnum_api_healthcheck_test: ["CMD-SHELL", "healthcheck_curl http://{{ api_interface_address | put_address_in_context('url') }}:{{ magnum_api_port }}"] +magnum_api_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +magnum_api_healthcheck: + interval: "{{ magnum_api_healthcheck_interval }}" + retries: "{{ magnum_api_healthcheck_retries }}" + start_period: "{{ magnum_api_healthcheck_start_period }}" + test: "{% if magnum_api_enable_healthchecks | bool %}{{ magnum_api_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ magnum_api_healthcheck_timeout }}" + +magnum_conductor_enable_healthchecks: "{{ enable_container_healthchecks }}" +magnum_conductor_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +magnum_conductor_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +magnum_conductor_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +magnum_conductor_healthcheck_test: ["CMD-SHELL", "healthcheck_port magnum-conductor {{ om_rpc_port }}"] +magnum_conductor_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +magnum_conductor_healthcheck: + interval: "{{ magnum_conductor_healthcheck_interval }}" + retries: "{{ magnum_conductor_healthcheck_retries }}" + start_period: "{{ magnum_conductor_healthcheck_start_period }}" + test: "{% if magnum_conductor_enable_healthchecks | bool %}{{ magnum_conductor_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ magnum_conductor_healthcheck_timeout }}" + magnum_api_default_volumes: - "{{ node_config_directory }}/magnum-api/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/magnum/handlers/main.yml b/ansible/roles/magnum/handlers/main.yml index 1fd190f17d..4bb021191e 100644 --- a/ansible/roles/magnum/handlers/main.yml +++ b/ansible/roles/magnum/handlers/main.yml @@ -12,6 +12,7 @@ volumes: "{{ service.volumes|reject('equalto', '')|list }}" environment: "{{ service.environment }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" @@ -28,5 +29,6 @@ volumes: "{{ service.volumes|reject('equalto', '')|list }}" environment: "{{ service.environment }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck | default(omit) }}" when: - kolla_action != "config" diff --git a/ansible/roles/magnum/tasks/check-containers.yml b/ansible/roles/magnum/tasks/check-containers.yml index 519bdaefe7..3264f01a57 100644 --- a/ansible/roles/magnum/tasks/check-containers.yml +++ b/ansible/roles/magnum/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) }}" environment: "{{ item.value.environment }}" when: - inventory_hostname in groups[item.value.group] diff --git a/releasenotes/notes/implement-docker-healthchecks-for-magnum-0e92b0645fcdeb61.yaml b/releasenotes/notes/implement-docker-healthchecks-for-magnum-0e92b0645fcdeb61.yaml new file mode 100644 index 0000000000..2e72d7e67e --- /dev/null +++ b/releasenotes/notes/implement-docker-healthchecks-for-magnum-0e92b0645fcdeb61.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Implements container healthchecks for magnum services. + See `blueprint + `__