Render corosync.conf file prior to pkg install
Starting in focal, the ubuntu version of corosync package synced in from debian includes node1 as the default name for the local node with a nodeid of 1. This causes the cluster to have knowledge of this extra node1 node, which affects quorum, etc. Installing the charm's corosync.conf file before package installation prevents this conditioning from happening. Additionally this change removes some Xenial bits in the charm and always includes a nodelist in corosync.conf as it is compulsory in focal and newer. It is optional in the bionic packages, so we'll always just render the nodelist. Change-Id: I06b9c23eb57274f0c99a3a05979c0cabf87c8118 Closes-Bug: #1874719
This commit is contained in:
parent
ecceb52f33
commit
d1191dbcab
@ -14,7 +14,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
@ -143,7 +142,8 @@ COROSYNC_CONF_FILES = [
|
||||
]
|
||||
|
||||
PACKAGES = ['crmsh', 'corosync', 'pacemaker', 'python3-netaddr', 'ipmitool',
|
||||
'libmonitoring-plugin-perl', 'python3-requests-oauthlib']
|
||||
'libmonitoring-plugin-perl', 'python3-requests-oauthlib',
|
||||
'python3-libmaas']
|
||||
|
||||
SUPPORTED_TRANSPORTS = ['udp', 'udpu', 'multicast', 'unicast']
|
||||
DEPRECATED_TRANSPORT_VALUES = {"multicast": "udp", "unicast": "udpu"}
|
||||
@ -151,23 +151,20 @@ DEPRECATED_TRANSPORT_VALUES = {"multicast": "udp", "unicast": "udpu"}
|
||||
|
||||
@hooks.hook('install.real')
|
||||
def install():
|
||||
pkgs = copy.deepcopy(PACKAGES)
|
||||
ubuntu_release = lsb_release()['DISTRIB_CODENAME'].lower()
|
||||
if CompareHostReleases(ubuntu_release) < 'xenial':
|
||||
# use libnagios on anything older than Xenial
|
||||
pkgs.remove('libmonitoring-plugin-perl')
|
||||
pkgs.append('libnagios-plugin-perl')
|
||||
|
||||
pkgs.remove('python3-netaddr')
|
||||
pkgs.append('python-netaddr')
|
||||
|
||||
elif CompareHostReleases(ubuntu_release) >= 'bionic':
|
||||
pkgs.append('python3-libmaas')
|
||||
# LP:1874719 Configure a corosync.conf file to avoid a spurious node1 to
|
||||
# be created in the cluster.
|
||||
os.mkdir('/etc/corosync', mode=0o755)
|
||||
if emit_corosync_conf():
|
||||
log('Installed initial corosync.conf file', level=INFO)
|
||||
else:
|
||||
log('Failed to install initial corosync.conf file. May have an '
|
||||
'extra node1 in cluster members due to default package install.',
|
||||
level=ERROR)
|
||||
|
||||
# NOTE(dosaboy): we currently disallow upgrades due to bug #1382842. This
|
||||
# should be removed once the pacemaker package is fixed.
|
||||
status_set('maintenance', 'Installing apt packages')
|
||||
apt_install(filter_installed_packages(pkgs), fatal=True)
|
||||
apt_install(filter_installed_packages(PACKAGES), fatal=True)
|
||||
setup_ocf_files()
|
||||
|
||||
|
||||
|
@ -67,7 +67,6 @@ quorum {
|
||||
{% endif -%}
|
||||
}
|
||||
|
||||
{% if transport == "udpu" %}
|
||||
nodelist {
|
||||
{% for nodeid, ip in ha_nodes.items() %}
|
||||
node {
|
||||
@ -76,7 +75,6 @@ nodelist {
|
||||
}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
logging {
|
||||
fileline: off
|
||||
|
@ -379,42 +379,22 @@ class TestHooks(test_utils.CharmTestCase):
|
||||
super(TestHooks, self).setUp(hooks, self.TO_PATCH)
|
||||
self.config.side_effect = self.test_config.get
|
||||
|
||||
@mock.patch.object(hooks, 'emit_corosync_conf')
|
||||
@mock.patch.object(hooks.os, 'mkdir')
|
||||
@mock.patch.object(hooks, 'filter_installed_packages')
|
||||
@mock.patch.object(hooks, 'setup_ocf_files')
|
||||
@mock.patch.object(hooks, 'apt_install')
|
||||
@mock.patch.object(hooks, 'status_set')
|
||||
@mock.patch.object(hooks, 'lsb_release')
|
||||
def test_install_xenial(self, lsb_release, status_set, apt_install,
|
||||
setup_ocf_files, filter_installed_packages):
|
||||
lsb_release.return_value = {
|
||||
'DISTRIB_CODENAME': 'xenial'}
|
||||
filter_installed_packages.side_effect = lambda x: x
|
||||
expected_pkgs = [
|
||||
'crmsh', 'corosync', 'pacemaker', 'python3-netaddr', 'ipmitool',
|
||||
'libmonitoring-plugin-perl', 'python3-requests-oauthlib']
|
||||
hooks.install()
|
||||
status_set.assert_called_once_with(
|
||||
'maintenance',
|
||||
'Installing apt packages')
|
||||
filter_installed_packages.assert_called_once_with(expected_pkgs)
|
||||
apt_install.assert_called_once_with(expected_pkgs, fatal=True)
|
||||
setup_ocf_files.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(hooks, 'filter_installed_packages')
|
||||
@mock.patch.object(hooks, 'setup_ocf_files')
|
||||
@mock.patch.object(hooks, 'apt_install')
|
||||
@mock.patch.object(hooks, 'status_set')
|
||||
@mock.patch.object(hooks, 'lsb_release')
|
||||
def test_install_bionic(self, lsb_release, status_set, apt_install,
|
||||
setup_ocf_files, filter_installed_packages):
|
||||
lsb_release.return_value = {
|
||||
'DISTRIB_CODENAME': 'bionic'}
|
||||
def test_install(self, status_set, apt_install, setup_ocf_files,
|
||||
filter_installed_packages, mkdir, emit_corosync_conf):
|
||||
filter_installed_packages.side_effect = lambda x: x
|
||||
expected_pkgs = [
|
||||
'crmsh', 'corosync', 'pacemaker', 'python3-netaddr', 'ipmitool',
|
||||
'libmonitoring-plugin-perl', 'python3-requests-oauthlib',
|
||||
'python3-libmaas']
|
||||
hooks.install()
|
||||
mkdir.assert_called_once_with('/etc/corosync', mode=0o755)
|
||||
emit_corosync_conf.assert_called_once_with()
|
||||
status_set.assert_called_once_with(
|
||||
'maintenance',
|
||||
'Installing apt packages')
|
||||
|
Loading…
x
Reference in New Issue
Block a user