From 32ab2d4bda69b7dff695ff0170d3c51cecac0b36 Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Fri, 6 May 2022 09:55:15 -0400 Subject: [PATCH] Install resource-agents-extra on jammy. The install hooks rsync a set of scripts and one of the destinations is /usr/lib/stonith/plugins/external, this directory is created by the installation of the package cluster-glue which is a pulled as an indirect dependency of pacemaker, this changed on >=jammy where an intermediate package named resource-agents was split into resource-agents-base and resource-agents-extra wher the latter doesn't get installed and it's the one that depends on cluster-glue. The specific chain of dependencies are: focal: pacemaker -> pacemaker-resource-agents -> resource-agents -> cluster-glue jammy pacemaker -> pacemaker-resource-agents -> resource-agents-base Change-Id: Ia00061bff2ebe16d35d52b256c61243935edabba Closes-Bug: #1971841 --- hooks/hooks.py | 6 +++++- unit_tests/test_hacluster_hooks.py | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hooks/hooks.py b/hooks/hooks.py index df3610b..fae5411 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -167,7 +167,11 @@ def install(): # 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(PACKAGES), fatal=True) + if CompareHostReleases(get_distrib_codename()) >= 'jammy': + pkgs = PACKAGES + ['resource-agents-extra'] + else: + pkgs = PACKAGES + apt_install(filter_installed_packages(pkgs), fatal=True) setup_ocf_files() diff --git a/unit_tests/test_hacluster_hooks.py b/unit_tests/test_hacluster_hooks.py index f99b875..d9ed231 100644 --- a/unit_tests/test_hacluster_hooks.py +++ b/unit_tests/test_hacluster_hooks.py @@ -379,6 +379,7 @@ 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, 'get_distrib_codename') @mock.patch.object(hooks, 'emit_corosync_conf') @mock.patch.object(hooks.os, 'mkdir') @mock.patch.object(hooks, 'filter_installed_packages') @@ -386,7 +387,9 @@ class TestHooks(test_utils.CharmTestCase): @mock.patch.object(hooks, 'apt_install') @mock.patch.object(hooks, 'status_set') def test_install(self, status_set, apt_install, setup_ocf_files, - filter_installed_packages, mkdir, emit_corosync_conf): + filter_installed_packages, mkdir, emit_corosync_conf, + get_distrib_codename): + get_distrib_codename.return_value = 'focal' filter_installed_packages.side_effect = lambda x: x expected_pkgs = [ 'crmsh', 'corosync', 'pacemaker', 'python3-netaddr', 'ipmitool', @@ -403,6 +406,8 @@ class TestHooks(test_utils.CharmTestCase): setup_ocf_files.assert_called_once_with() mkdir.reset_mock() + apt_install.reset_mock() + get_distrib_codename.return_value = 'jammy' def raise_(): raise FileExistsError() @@ -410,6 +415,8 @@ class TestHooks(test_utils.CharmTestCase): mkdir.side_effect = lambda p, mode: raise_() hooks.install() mkdir.assert_called_once_with('/etc/corosync', mode=0o755) + apt_install.assert_called_once_with( + expected_pkgs + ['resource-agents-extra'], fatal=True) @mock.patch('pcmk.set_property') @mock.patch.object(hooks, 'is_stonith_configured')