From b377dc77666483559dd0374cba2ca35c9d3b5744 Mon Sep 17 00:00:00 2001 From: Mihaela Balutoiu Date: Tue, 21 Jul 2026 15:25:51 +0300 Subject: [PATCH] Move SELinux autorelabeling to base classes This ensures all Red Hat and SUSE distribution variants execute SELinux autorelabeling consistently at the same point in the post-install lifecycle. Signed-off-by: Mihaela Balutoiu --- coriolis/osmorphing/redhat.py | 1 + coriolis/osmorphing/suse.py | 1 + coriolis/tests/osmorphing/test_redhat.py | 5 ++++- coriolis/tests/osmorphing/test_suse.py | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/coriolis/osmorphing/redhat.py b/coriolis/osmorphing/redhat.py index b2b08ccc6..3d0d7d730 100644 --- a/coriolis/osmorphing/redhat.py +++ b/coriolis/osmorphing/redhat.py @@ -235,6 +235,7 @@ def pre_packages_install(self, package_names): def post_packages_install(self, package_names): self._configure_cloud_init() self._run_dracut() + self._set_selinux_autorelabel() super(BaseRedHatMorphingTools, self).post_packages_install( package_names) diff --git a/coriolis/osmorphing/suse.py b/coriolis/osmorphing/suse.py index 9dd4125dc..6e0cf06f5 100644 --- a/coriolis/osmorphing/suse.py +++ b/coriolis/osmorphing/suse.py @@ -189,6 +189,7 @@ def pre_packages_install(self, package_names): def post_packages_install(self, package_names): self._configure_cloud_init() self._run_dracut() + self._set_selinux_autorelabel() super(BaseSUSEMorphingTools, self).post_packages_install(package_names) def _enable_sles_module(self, module): diff --git a/coriolis/tests/osmorphing/test_redhat.py b/coriolis/tests/osmorphing/test_redhat.py index 761d07252..f2d06f849 100644 --- a/coriolis/tests/osmorphing/test_redhat.py +++ b/coriolis/tests/osmorphing/test_redhat.py @@ -687,17 +687,20 @@ def test_pre_packages_install_has_grubby( mock_yum_clean_all.assert_called_once() mock_yum_install.assert_not_called() + @mock.patch.object( + redhat.BaseRedHatMorphingTools, '_set_selinux_autorelabel') @mock.patch.object(redhat.BaseRedHatMorphingTools, '_configure_cloud_init') @mock.patch.object(redhat.BaseRedHatMorphingTools, '_run_dracut') @mock.patch.object(base.BaseLinuxOSMorphingTools, 'post_packages_install') def test_post_packages_install( self, mock_post_packages_install, mock__run_dracut, - mock__configure_cloud_init): + mock__configure_cloud_init, mock__set_selinux_autorelabel): self.morphing_tools.post_packages_install(self.package_names) mock__configure_cloud_init.assert_called_once() mock__run_dracut.assert_called_once() + mock__set_selinux_autorelabel.assert_called_once() mock_post_packages_install.assert_called_once_with(self.package_names) @mock.patch.object(redhat.BaseRedHatMorphingTools, '_yum_install') diff --git a/coriolis/tests/osmorphing/test_suse.py b/coriolis/tests/osmorphing/test_suse.py index fe0006c71..c6da736a8 100644 --- a/coriolis/tests/osmorphing/test_suse.py +++ b/coriolis/tests/osmorphing/test_suse.py @@ -205,17 +205,19 @@ def test__has_systemd_with_exception(self, mock_exec_cmd_chroot): self.assertFalse(result) + @mock.patch.object(suse.BaseSUSEMorphingTools, '_set_selinux_autorelabel') @mock.patch.object(suse.BaseSUSEMorphingTools, '_configure_cloud_init') @mock.patch.object(suse.BaseSUSEMorphingTools, '_run_dracut') @mock.patch.object(base.BaseLinuxOSMorphingTools, 'post_packages_install') def test_post_packages_install( self, mock_post_packages_install, mock__run_dracut, - mock__configure_cloud_init): + mock__configure_cloud_init, mock__set_selinux_autorelabel): self.morphing_tools.post_packages_install(self.package_names) mock__configure_cloud_init.assert_called_once() mock__run_dracut.assert_called_once() + mock__set_selinux_autorelabel.assert_called_once() mock_post_packages_install.assert_called_once_with(self.package_names) @mock.patch.object(base.BaseLinuxOSMorphingTools, '_exec_cmd_chroot')