leapp-repository/SOURCES/0028-call-Satellite-install...

136 lines
6.7 KiB
Diff

From f858a2a87edc602c976342e22538bf44249f9d1e Mon Sep 17 00:00:00 2001
From: Evgeni Golov <evgeni@golov.de>
Date: Mon, 4 Apr 2022 09:10:45 +0200
Subject: [PATCH 28/39] call Satellite installer with --disable-system-checks
if possible
The installer has a set of checks to verify whether the current system
is suitable for running Satellite. The administrator of the system can
choose to ignore those checks with `--disable-system-checks`.
As the installer invocation inside LEAPP is non-interactive, we should
err on the side of not running checks, so that the upgrade doesn't abort
in the case where the administrator has chosen to ignore the warnings.
This is in line with other non-interactive invocations of the installer
that other tools (like foreman-maintain) do.
The "if katello installer" logic is needed, as the checks and the cli
parameter is only present in Katello installations, not plain Foreman.
---
.../actors/satellite_upgrade_facts/actor.py | 3 +++
.../tests/unit_test_satellite_upgrade_facts.py | 15 +++++++++++++++
.../el7toel8/actors/satellite_upgrader/actor.py | 6 +++++-
.../tests/unit_test_satellite_upgrader.py | 11 +++++++++++
repos/system_upgrade/el7toel8/models/satellite.py | 2 ++
5 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/actor.py b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/actor.py
index 12c0fa53..c837b449 100644
--- a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/actor.py
+++ b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/actor.py
@@ -32,6 +32,8 @@ class SatelliteUpgradeFacts(Actor):
if not has_foreman:
return
+ has_katello_installer = has_package(InstalledRPM, 'foreman-installer-katello')
+
local_postgresql = has_package(InstalledRPM, 'rh-postgresql12-postgresql-server')
postgresql_contrib = has_package(InstalledRPM, 'rh-postgresql12-postgresql-contrib')
postgresql_evr = has_package(InstalledRPM, 'rh-postgresql12-postgresql-evr')
@@ -114,6 +116,7 @@ class SatelliteUpgradeFacts(Actor):
self.produce(SatelliteFacts(
has_foreman=has_foreman,
+ has_katello_installer=has_katello_installer,
postgresql=SatellitePostgresqlFacts(
local_postgresql=local_postgresql,
old_var_lib_pgsql_data=old_pgsql_data,
diff --git a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/tests/unit_test_satellite_upgrade_facts.py b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/tests/unit_test_satellite_upgrade_facts.py
index 28b9f44b..fceda925 100644
--- a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/tests/unit_test_satellite_upgrade_facts.py
+++ b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_facts/tests/unit_test_satellite_upgrade_facts.py
@@ -21,6 +21,7 @@ def fake_package(pkg_name):
FOREMAN_RPM = fake_package('foreman')
FOREMAN_PROXY_RPM = fake_package('foreman-proxy')
+KATELLO_INSTALLER_RPM = fake_package('foreman-installer-katello')
KATELLO_RPM = fake_package('katello')
POSTGRESQL_RPM = fake_package('rh-postgresql12-postgresql-server')
@@ -46,6 +47,20 @@ def test_satellite_capsule_present(current_actor_context):
assert message.has_foreman
+def test_no_katello_installer_present(current_actor_context):
+ current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM]))
+ current_actor_context.run()
+ message = current_actor_context.consume(SatelliteFacts)[0]
+ assert not message.has_katello_installer
+
+
+def test_katello_installer_present(current_actor_context):
+ current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM, KATELLO_INSTALLER_RPM]))
+ current_actor_context.run()
+ message = current_actor_context.consume(SatelliteFacts)[0]
+ assert message.has_katello_installer
+
+
def test_enables_ruby_module(current_actor_context):
current_actor_context.feed(InstalledRPM(items=[FOREMAN_RPM]))
current_actor_context.run()
diff --git a/repos/system_upgrade/el7toel8/actors/satellite_upgrader/actor.py b/repos/system_upgrade/el7toel8/actors/satellite_upgrader/actor.py
index 28d5edd9..bd1a5d68 100644
--- a/repos/system_upgrade/el7toel8/actors/satellite_upgrader/actor.py
+++ b/repos/system_upgrade/el7toel8/actors/satellite_upgrader/actor.py
@@ -19,9 +19,13 @@ class SatelliteUpgrader(Actor):
if not facts or not facts.has_foreman:
return
+ installer_cmd = ['foreman-installer']
+ if facts.has_katello_installer:
+ installer_cmd.append('--disable-system-checks')
+
api.current_actor().show_message('Running the installer. This can take a while.')
try:
- run(['foreman-installer'])
+ run(installer_cmd)
except OSError as e:
api.current_logger().error('Failed to run `foreman-installer`: {}'.format(str(e)))
except CalledProcessError:
diff --git a/repos/system_upgrade/el7toel8/actors/satellite_upgrader/tests/unit_test_satellite_upgrader.py b/repos/system_upgrade/el7toel8/actors/satellite_upgrader/tests/unit_test_satellite_upgrader.py
index 886d6879..d62815ca 100644
--- a/repos/system_upgrade/el7toel8/actors/satellite_upgrader/tests/unit_test_satellite_upgrader.py
+++ b/repos/system_upgrade/el7toel8/actors/satellite_upgrader/tests/unit_test_satellite_upgrader.py
@@ -21,4 +21,15 @@ def test_run_installer(monkeypatch, current_actor_context):
current_actor_context.run()
assert mocked_run.commands
assert len(mocked_run.commands) == 1
+ assert mocked_run.commands[0] == ['foreman-installer', '--disable-system-checks']
+
+
+def test_run_installer_without_katello(monkeypatch, current_actor_context):
+ mocked_run = MockedRun()
+ monkeypatch.setattr('leapp.libraries.stdlib.run', mocked_run)
+ current_actor_context.feed(SatelliteFacts(has_foreman=True, has_katello_installer=False,
+ postgresql=SatellitePostgresqlFacts()))
+ current_actor_context.run()
+ assert mocked_run.commands
+ assert len(mocked_run.commands) == 1
assert mocked_run.commands[0] == ['foreman-installer']
diff --git a/repos/system_upgrade/el7toel8/models/satellite.py b/repos/system_upgrade/el7toel8/models/satellite.py
index 9f962c7f..b4282790 100644
--- a/repos/system_upgrade/el7toel8/models/satellite.py
+++ b/repos/system_upgrade/el7toel8/models/satellite.py
@@ -22,5 +22,7 @@ class SatelliteFacts(Model):
has_foreman = fields.Boolean(default=False)
"""Whether or not foreman is installed on this system"""
+ has_katello_installer = fields.Boolean(default=True)
+ """Whether or not the installer supports Katello additions"""
postgresql = fields.Model(SatellitePostgresqlFacts)
""" Foreman related PostgreSQL facts """
--
2.35.3