From df06af99e3b6f30cebdc572726e1702b352923f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Nasiadka?= Date: Thu, 25 Mar 2021 10:22:24 +0100 Subject: [PATCH] openvswitch: Add healthchecks Depends-On: https://review.opendev.org/c/openstack/kolla/+/782815 Change-Id: I5230f017f1fa99629b81d944ba245c5778411b1f --- ansible/roles/openvswitch/defaults/main.yml | 28 +++++++++++++++++++ ansible/roles/openvswitch/handlers/main.yml | 2 ++ .../openvswitch/tasks/check-containers.yml | 1 + 3 files changed, 31 insertions(+) diff --git a/ansible/roles/openvswitch/defaults/main.yml b/ansible/roles/openvswitch/defaults/main.yml index 8fae2b385b..9bdc13bf46 100644 --- a/ansible/roles/openvswitch/defaults/main.yml +++ b/ansible/roles/openvswitch/defaults/main.yml @@ -17,6 +17,7 @@ openvswitch_services: }} volumes: "{{ openvswitch_db_default_volumes + openvswitch_db_extra_volumes }}" dimensions: "{{ openvswitch_db_dimensions }}" + healthcheck: "{{ openvswitch_db_healthcheck }}" openvswitch-vswitchd: container_name: "openvswitch_vswitchd" image: "{{ openvswitch_vswitchd_image_full }}" @@ -33,6 +34,7 @@ openvswitch_services: privileged: True volumes: "{{ openvswitch_vswitchd_default_volumes + openvswitch_vswitchd_extra_volumes }}" dimensions: "{{ openvswitch_vswitchd_dimensions }}" + healthcheck: "{{ openvswitch_vswitchd_healthcheck }}" #################### # Docker @@ -51,6 +53,32 @@ openvswitch_vswitchd_image_full: "{{ openvswitch_vswitchd_image }}:{{ openvswitc openvswitch_db_dimensions: "{{ default_container_dimensions }}" openvswitch_vswitchd_dimensions: "{{ default_container_dimensions }}" +openvswitch_db_enable_healthchecks: "{{ enable_container_healthchecks }}" +openvswitch_db_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +openvswitch_db_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +openvswitch_db_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +openvswitch_db_healthcheck_test: ["CMD-SHELL", "healthcheck_socket ovsdb-server /run/openvswitch/db.sock"] +openvswitch_db_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +openvswitch_db_healthcheck: + interval: "{{ openvswitch_db_healthcheck_interval }}" + retries: "{{ openvswitch_db_healthcheck_retries }}" + start_period: "{{ openvswitch_db_healthcheck_start_period }}" + test: "{% if openvswitch_db_enable_healthchecks | bool %}{{ openvswitch_db_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ openvswitch_db_healthcheck_timeout }}" + +openvswitch_vswitchd_enable_healthchecks: "{{ enable_container_healthchecks }}" +openvswitch_vswitchd_healthcheck_interval: "{{ default_container_healthcheck_interval }}" +openvswitch_vswitchd_healthcheck_retries: "{{ default_container_healthcheck_retries }}" +openvswitch_vswitchd_healthcheck_start_period: "{{ default_container_healthcheck_start_period }}" +openvswitch_vswitchd_healthcheck_test: ["CMD-SHELL", "ovs-appctl version"] +openvswitch_vswitchd_healthcheck_timeout: "{{ default_container_healthcheck_timeout }}" +openvswitch_vswitchd_healthcheck: + interval: "{{ openvswitch_vswitchd_healthcheck_interval }}" + retries: "{{ openvswitch_vswitchd_healthcheck_retries }}" + start_period: "{{ openvswitch_vswitchd_healthcheck_start_period }}" + test: "{% if openvswitch_vswitchd_enable_healthchecks | bool %}{{ openvswitch_vswitchd_healthcheck_test }}{% else %}NONE{% endif %}" + timeout: "{{ openvswitch_vswitchd_healthcheck_timeout }}" + openvswitch_db_default_volumes: - "{{ node_config_directory }}/openvswitch-db-server/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" diff --git a/ansible/roles/openvswitch/handlers/main.yml b/ansible/roles/openvswitch/handlers/main.yml index 11d4b5e199..3fbf322a31 100644 --- a/ansible/roles/openvswitch/handlers/main.yml +++ b/ansible/roles/openvswitch/handlers/main.yml @@ -11,6 +11,7 @@ image: "{{ service.image }}" volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck }}" when: - kolla_action != "config" notify: @@ -38,5 +39,6 @@ volumes: "{{ service.volumes }}" privileged: "{{ service.privileged | default(False) }}" dimensions: "{{ service.dimensions }}" + healthcheck: "{{ service.healthcheck }}" when: - kolla_action != "config" diff --git a/ansible/roles/openvswitch/tasks/check-containers.yml b/ansible/roles/openvswitch/tasks/check-containers.yml index 1e5fa464fe..81f05f012e 100644 --- a/ansible/roles/openvswitch/tasks/check-containers.yml +++ b/ansible/roles/openvswitch/tasks/check-containers.yml @@ -9,6 +9,7 @@ privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" + healthcheck: "{{ item.value.healthcheck }}" when: - item.value.enabled | bool - item.value.host_in_groups | bool