From db517a44e4bc9cbc9cdf402981e04b7cd7bacd7b Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 29 Jul 2020 10:30:52 +0000 Subject: [PATCH] masakari: support host monitor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3f43df7766c57622ab8d01a759fbeeef0a0c2b93 Implements: blueprint masakari-hostmonitor Co-Authored-By: Radosław Piliszek --- ansible/group_vars/all.yml | 7 +++++++ ansible/inventory/all-in-one | 5 ++++- ansible/inventory/multinode | 5 ++++- ansible/roles/hacluster/defaults/main.yml | 7 ------- ansible/roles/masakari/defaults/main.yml | 18 ++++++++++++++++- ansible/roles/masakari/handlers/main.yml | 16 +++++++++++++++ .../roles/masakari/tasks/check-containers.yml | 1 + ansible/roles/masakari/tasks/config.yml | 1 + .../templates/masakari-hostmonitor.json.j2 | 18 +++++++++++++++++ .../templates/masakari-monitors.conf.j2 | 20 +++++++++++++++++++ ansible/site.yml | 3 ++- etc/kolla/globals.yml | 7 +++++++ ...masakari-hostmonitor-c9b1b6872deef4b1.yaml | 4 ++++ tests/templates/inventory.j2 | 5 ++++- 14 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 ansible/roles/masakari/templates/masakari-hostmonitor.json.j2 create mode 100644 releasenotes/notes/add-masakari-hostmonitor-c9b1b6872deef4b1.yaml diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 575f1fbf9c..c8c19cf306 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -1228,3 +1228,10 @@ octavia_public_endpoint: "{{ public_protocol }}://{{ octavia_external_fqdn | put # file: "/full/qualified/path/to/mapping/json/file/to/mappingId3" keystone_identity_providers: [] keystone_identity_mappings: [] + +#################### +# Corosync options +#################### + +# this is UDP port +hacluster_corosync_port: 5405 diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index 63963e0e50..bc1a56c396 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -735,7 +735,10 @@ control [masakari-engine:children] control -[masakari-monitors:children] +[masakari-hostmonitor:children] +control + +[masakari-instancemonitor:children] compute [ovn-controller:children] diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index 3c23f25ec2..8b3f83e0fa 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -753,7 +753,10 @@ control [masakari-engine:children] control -[masakari-monitors:children] +[masakari-hostmonitor:children] +control + +[masakari-instancemonitor:children] compute [ovn-controller:children] diff --git a/ansible/roles/hacluster/defaults/main.yml b/ansible/roles/hacluster/defaults/main.yml index 18ca3969c7..6b9d44c55b 100644 --- a/ansible/roles/hacluster/defaults/main.yml +++ b/ansible/roles/hacluster/defaults/main.yml @@ -85,13 +85,6 @@ hacluster_pacemaker_extra_volumes: "{{ hacluster_extra_volumes }}" hacluster_pacemaker_remote_extra_volumes: "{{ hacluster_extra_volumes }}" -#################### -# Corosync options -#################### - -# this is UDP port -hacluster_corosync_port: 5405 - #################### # Pacemaker options #################### diff --git a/ansible/roles/masakari/defaults/main.yml b/ansible/roles/masakari/defaults/main.yml index 2ae14924d9..28d8bb57ef 100644 --- a/ansible/roles/masakari/defaults/main.yml +++ b/ansible/roles/masakari/defaults/main.yml @@ -29,12 +29,20 @@ masakari_services: dimensions: "{{ masakari_engine_dimensions }}" masakari-instancemonitor: container_name: masakari_instancemonitor - group: masakari-monitors + group: masakari-instancemonitor enabled: true image: "{{ masakari_monitors_image_full }}" volumes: "{{ masakari_instancemonitor_default_volumes + masakari_instancemonitor_extra_volumes }}" privileged: True dimensions: "{{ masakari_instancemonitor_dimensions }}" + masakari-hostmonitor: + container_name: masakari_hostmonitor + group: masakari-hostmonitor + enabled: true + ipc_mode: host + image: "{{ masakari_monitors_image_full }}" + volumes: "{{ masakari_hostmonitor_default_volumes + masakari_hostmonitor_extra_volumes }}" + dimensions: "{{ masakari_hostmonitor_dimensions }}" #################### @@ -67,11 +75,13 @@ masakari_engine_dimensions: "{{ default_container_dimensions }}" # NOTE(mgoddard): Allow masakari_monitors_dimensions for backwards # compatibility. masakari_instancemonitor_dimensions: "{{ masakari_monitors_dimensions | default(default_container_dimensions) }}" +masakari_hostmonitor_dimensions: "{{ default_container_dimensions }}" masakari_extra_volumes: "{{ default_extra_volumes }}" masakari_api_extra_volumes: "{{ masakari_extra_volumes }}" masakari_engine_extra_volumes: "{{ masakari_extra_volumes }}" masakari_instancemonitor_extra_volumes: "{{ masakari_extra_volumes }}" +masakari_hostmonitor_extra_volumes: "{{ masakari_extra_volumes }}" masakari_api_default_volumes: - "{{ node_config_directory }}/masakari-api/:{{ container_config_directory }}/:ro" @@ -92,6 +102,12 @@ masakari_instancemonitor_default_volumes: - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_os_family == 'Debian' else '' }}" - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/masakari-monitors/masakarimonitors:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/masakarimonitors' if masakari_dev_mode | bool else '' }}" +masakari_hostmonitor_default_volumes: + - "{{ node_config_directory }}/masakari-hostmonitor/:{{ container_config_directory }}/:ro" + - "/etc/localtime:/etc/localtime:ro" + - "{{ '/etc/timezone:/etc/timezone:ro' if kolla_base_distro in ['debian', 'ubuntu'] else '' }}" + - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/masakari-monitors/masakarimonitors:/var/lib/kolla/venv/lib/python' ~ distro_python_version ~ '/site-packages/masakarimonitors' if masakari_dev_mode | bool else '' }}" #################### diff --git a/ansible/roles/masakari/handlers/main.yml b/ansible/roles/masakari/handlers/main.yml index a6e63facb1..c2108b7587 100644 --- a/ansible/roles/masakari/handlers/main.yml +++ b/ansible/roles/masakari/handlers/main.yml @@ -46,3 +46,19 @@ dimensions: "{{ service.dimensions }}" when: - kolla_action != "config" + +- name: Restart masakari-hostmonitor container + vars: + service_name: "masakari-hostmonitor" + service: "{{ masakari_services[service_name] }}" + become: true + kolla_docker: + action: "recreate_or_restart_container" + common_options: "{{ docker_common_options }}" + name: "{{ service.container_name }}" + image: "{{ service.image }}" + ipc_mode: "{{ service.ipc_mode }}" + volumes: "{{ service.volumes|reject('equalto', '')|list }}" + dimensions: "{{ service.dimensions }}" + when: + - kolla_action != "config" diff --git a/ansible/roles/masakari/tasks/check-containers.yml b/ansible/roles/masakari/tasks/check-containers.yml index 37ab002434..027f2d3318 100644 --- a/ansible/roles/masakari/tasks/check-containers.yml +++ b/ansible/roles/masakari/tasks/check-containers.yml @@ -6,6 +6,7 @@ common_options: "{{ docker_common_options }}" name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" + ipc_mode: "{{ item.value.ipc_mode | default(omit) }}" privileged: "{{ item.value.privileged | default(False) }}" volumes: "{{ item.value.volumes | reject('equalto', '') | list }}" dimensions: "{{ item.value.dimensions }}" diff --git a/ansible/roles/masakari/tasks/config.yml b/ansible/roles/masakari/tasks/config.yml index da55677baf..95603d7f3b 100644 --- a/ansible/roles/masakari/tasks/config.yml +++ b/ansible/roles/masakari/tasks/config.yml @@ -104,6 +104,7 @@ - service.enabled | bool with_items: - masakari-instancemonitor + - masakari-hostmonitor notify: - Restart {{ service_name }} container diff --git a/ansible/roles/masakari/templates/masakari-hostmonitor.json.j2 b/ansible/roles/masakari/templates/masakari-hostmonitor.json.j2 new file mode 100644 index 0000000000..15dff56a4a --- /dev/null +++ b/ansible/roles/masakari/templates/masakari-hostmonitor.json.j2 @@ -0,0 +1,18 @@ +{ + "command": "masakari-hostmonitor --config-file /etc/masakari-monitors/masakari-monitors.conf", + "config_files": [ + { + "source": "{{ container_config_directory }}/masakari-monitors.conf", + "dest": "/etc/masakari-monitors/masakari-monitors.conf", + "owner": "masakari", + "perm": "0600" + } + ], + "permissions": [ + { + "path": "/var/log/kolla/masakari", + "owner": "masakari:masakari", + "recurse": true + } + ] +} diff --git a/ansible/roles/masakari/templates/masakari-monitors.conf.j2 b/ansible/roles/masakari/templates/masakari-monitors.conf.j2 index 39675e3a09..7ccd6781ec 100644 --- a/ansible/roles/masakari/templates/masakari-monitors.conf.j2 +++ b/ansible/roles/masakari/templates/masakari-monitors.conf.j2 @@ -13,5 +13,25 @@ password = {{ masakari_keystone_password }} cafile = {{ openstack_cacert }} api_interface = internal +{% if service_name == 'masakari-instancemonitor' %} [libvirt] connection_uri = "qemu+tcp://{{ migration_interface_address | put_address_in_context('url') }}/system" +{% endif %} + +{% if service_name == 'masakari-hostmonitor' %} +[host] +{# + NOTE(yoctozepto): ``restrict_to_remotes`` is due to being unable to monitor + both types at once and Kolla has remotes on dedicated computes so it is + a better default choice. + This limitation may be lifted in the near future (Xena+). +#} +restrict_to_remotes = True +{% if inventory_hostname in groups['hacluster'] %} +pacemaker_node_type = cluster +corosync_multicast_interfaces = {{ api_interface }} +corosync_multicast_ports = {{ hacluster_corosync_port }} +{% elif inventory_hostname in groups['hacluster-remote'] %} +pacemaker_node_type = remote +{% endif %} +{% endif %} diff --git a/ansible/site.yml b/ansible/site.yml index 040fe29a84..d724f6b2a7 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -1158,7 +1158,8 @@ hosts: - masakari-api - masakari-engine - - masakari-monitors + - masakari-hostmonitor + - masakari-instancemonitor - '&enable_masakari_True' serial: '{{ kolla_serial|default("0") }}' roles: diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 40e98748f1..5b595322b1 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -803,3 +803,10 @@ #octavia_amp_boot_network_list: #octavia_amp_secgroup_list: #octavia_amp_flavor_id: + +#################### +# Corosync options +#################### + +# this is UDP port +#hacluster_corosync_port: 5405 diff --git a/releasenotes/notes/add-masakari-hostmonitor-c9b1b6872deef4b1.yaml b/releasenotes/notes/add-masakari-hostmonitor-c9b1b6872deef4b1.yaml new file mode 100644 index 0000000000..ab918faa84 --- /dev/null +++ b/releasenotes/notes/add-masakari-hostmonitor-c9b1b6872deef4b1.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Adds support for Masakari host monitor. diff --git a/tests/templates/inventory.j2 b/tests/templates/inventory.j2 index e4b05f0221..2224094272 100644 --- a/tests/templates/inventory.j2 +++ b/tests/templates/inventory.j2 @@ -802,7 +802,10 @@ control [masakari-engine:children] control -[masakari-monitors:children] +[masakari-hostmonitor:children] +control + +[masakari-instancemonitor:children] compute [ovn-controller:children]