[hostmonitor] Add pacemaker_node_type option

When running in a container, it might not be possible to use systemd
to verify the status of Corosync and Pacemaker.
In such case, allow the user to choose the stack being used.

Change-Id: I44ce3be6b6fda3834f6df63861b0dcf546da46a1
Co-Authored-By: Radosław Piliszek <radoslaw.piliszek@gmail.com>
This commit is contained in:
Mark Goddard 2020-07-29 09:40:07 +00:00 committed by Radosław Piliszek
parent be42d99854
commit 0cdbb23587
3 changed files with 37 additions and 7 deletions

View File

@ -79,6 +79,17 @@ like '5405,5406'.
The number of port numbers you specify must be equal to the number of
corosync_multicast_interfaces values and must be in correct order with
relevant interfaces in corosync_multicast_interfaces.
'''),
cfg.StrOpt('pacemaker_node_type',
default='autodetect',
choices=('autodetect', 'cluster', 'remote'),
help='''
Using this option, one can avoid systemd checks that would establish whether
this hostmonitor is running alongside Corosync and Pacemaker (the ``cluster``
stack) or Pacemaker Remote (the ``remote`` stack).
The default (``autodetect``) ensures backward compatibility and means systemd
is used to check the stack.
'''),
]

View File

@ -79,11 +79,19 @@ class HandleHost(driver.DriverBase):
:returns: 0 if normal, 1 if abnormal, 2 if configuration file is
wrong or neither pacemaker nor pacemaker-remote is running.
"""
# Check whether the pacemaker services is normal.
corosync_status = self._check_pacemaker_services('corosync')
pacemaker_status = self._check_pacemaker_services('pacemaker')
pacemaker_remote_status = self._check_pacemaker_services(
'pacemaker_remote')
if CONF.host.pacemaker_node_type == 'autodetect':
# Check whether the Corosync/Pacemaker services are running.
corosync_status = self._check_pacemaker_services('corosync')
pacemaker_status = self._check_pacemaker_services('pacemaker')
pacemaker_remote_status = self._check_pacemaker_services(
'pacemaker_remote')
else:
corosync_status = (
CONF.host.pacemaker_node_type == 'cluster')
pacemaker_status = (
CONF.host.pacemaker_node_type == 'cluster')
pacemaker_remote_status = (
CONF.host.pacemaker_node_type == 'remote')
if corosync_status is False or pacemaker_status is False:
if pacemaker_remote_status is False:
@ -402,11 +410,16 @@ class HandleHost(driver.DriverBase):
eventlet.greenthread.sleep(CONF.host.monitoring_interval)
continue
if CONF.host.pacemaker_node_type == 'autodetect':
pacemaker_remote_status = self._check_pacemaker_services(
'pacemaker_remote')
else:
pacemaker_remote_status = (
CONF.host.pacemaker_node_type == 'remote')
# Check the host status is stable or unstable by crmadmin.
# It only checks when this process runs on the full cluster
# stack of corosync.
pacemaker_remote_status = self._check_pacemaker_services(
'pacemaker_remote')
if pacemaker_remote_status is False:
if self._check_host_status_by_crmadmin() != 0:
LOG.warning("hostmonitor skips monitoring hosts.")

View File

@ -0,0 +1,6 @@
---
features:
- |
Adds ``pacemaker_node_type`` option to ``hostmonitor`` to allow
skipping systemd service status checks which are often impossible in
containerised deployments.