Merge "Catch FileExistsError when creating /etc/corosync dir."

This commit is contained in:
Zuul 2022-05-10 17:28:09 +00:00 committed by Gerrit Code Review
commit 073095a613
2 changed files with 13 additions and 1 deletions

View File

@ -153,7 +153,10 @@ DEPRECATED_TRANSPORT_VALUES = {"multicast": "udp", "unicast": "udpu"}
def install():
# LP:1874719 Configure a corosync.conf file to avoid a spurious node1 to
# be created in the cluster.
os.mkdir('/etc/corosync', mode=0o755)
try:
os.mkdir('/etc/corosync', mode=0o755)
except FileExistsError:
pass
if emit_corosync_conf():
log('Installed initial corosync.conf file', level=INFO)
else:

View File

@ -402,6 +402,15 @@ class TestHooks(test_utils.CharmTestCase):
apt_install.assert_called_once_with(expected_pkgs, fatal=True)
setup_ocf_files.assert_called_once_with()
mkdir.reset_mock()
def raise_():
raise FileExistsError()
mkdir.side_effect = lambda p, mode: raise_()
hooks.install()
mkdir.assert_called_once_with('/etc/corosync', mode=0o755)
@mock.patch('pcmk.set_property')
@mock.patch.object(hooks, 'is_stonith_configured')
@mock.patch.object(hooks, 'configure_stonith')