138 lines
7.6 KiB
Diff
138 lines
7.6 KiB
Diff
From 00ab521d952d413a095b8b48e5615bedaed41c13 Mon Sep 17 00:00:00 2001
|
|
From: Evgeni Golov <evgeni@golov.de>
|
|
Date: Thu, 12 Jan 2023 12:37:36 +0100
|
|
Subject: [PATCH 61/63] BZ#2142270 - run reindexdb to fix issues due to new
|
|
locales in RHEL8
|
|
|
|
---
|
|
.../libraries/satellite_upgrade_check.py | 12 +++++++++---
|
|
.../tests/unit_test_satellite_upgrade_check.py | 6 +++++-
|
|
.../el7toel8/actors/satellite_upgrader/actor.py | 7 +++++++
|
|
.../tests/unit_test_satellite_upgrader.py | 17 +++++++++++++++--
|
|
4 files changed, 36 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_check/libraries/satellite_upgrade_check.py b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_check/libraries/satellite_upgrade_check.py
|
|
index c33e4f6e..6954dd50 100644
|
|
--- a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_check/libraries/satellite_upgrade_check.py
|
|
+++ b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_check/libraries/satellite_upgrade_check.py
|
|
@@ -23,9 +23,13 @@ def satellite_upgrade_check(facts):
|
|
title = "Satellite PostgreSQL data migration"
|
|
flags = []
|
|
severity = reporting.Severity.MEDIUM
|
|
+ reindex_msg = textwrap.dedent("""
|
|
+ After the data has been moved to the new location, all databases will require a REINDEX.
|
|
+ This will happen automatically during the first boot of the system.
|
|
+ """).strip()
|
|
|
|
if facts.postgresql.same_partition:
|
|
- summary = "Your PostgreSQL data will be automatically migrated."
|
|
+ migration_msg = "Your PostgreSQL data will be automatically migrated."
|
|
else:
|
|
scl_psql_path = '/var/opt/rh/rh-postgresql12/lib/pgsql/data/'
|
|
if facts.postgresql.space_required > facts.postgresql.space_available:
|
|
@@ -36,7 +40,7 @@ def satellite_upgrade_check(facts):
|
|
else:
|
|
storage_message = """You currently have enough free storage to move the data.
|
|
This operation can be performed by the upgrade process."""
|
|
- summary = """
|
|
+ migration_msg = """
|
|
Your PostgreSQL data in {} is currently on a dedicated volume.
|
|
PostgreSQL on RHEL8 expects the data to live in /var/lib/pgsql/data.
|
|
{}
|
|
@@ -44,9 +48,11 @@ def satellite_upgrade_check(facts):
|
|
so that the contents of {} are available in /var/lib/pgsql/data.
|
|
""".format(scl_psql_path, storage_message, scl_psql_path)
|
|
|
|
+ summary = "{}\n{}".format(textwrap.dedent(migration_msg).strip(), reindex_msg)
|
|
+
|
|
reporting.create_report([
|
|
reporting.Title(title),
|
|
- reporting.Summary(textwrap.dedent(summary).strip()),
|
|
+ reporting.Summary(summary),
|
|
reporting.Severity(severity),
|
|
reporting.Groups([]),
|
|
reporting.Groups(flags)
|
|
diff --git a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_check/tests/unit_test_satellite_upgrade_check.py b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_check/tests/unit_test_satellite_upgrade_check.py
|
|
index 0e1969b7..8b75adf7 100644
|
|
--- a/repos/system_upgrade/el7toel8/actors/satellite_upgrade_check/tests/unit_test_satellite_upgrade_check.py
|
|
+++ b/repos/system_upgrade/el7toel8/actors/satellite_upgrade_check/tests/unit_test_satellite_upgrade_check.py
|
|
@@ -42,9 +42,11 @@ def test_same_disk(monkeypatch):
|
|
|
|
expected_title = 'Satellite PostgreSQL data migration'
|
|
expected_summary = 'Your PostgreSQL data will be automatically migrated.'
|
|
+ expected_reindex = 'all databases will require a REINDEX'
|
|
|
|
assert expected_title == reporting.create_report.report_fields['title']
|
|
- assert expected_summary == reporting.create_report.report_fields['summary']
|
|
+ assert expected_summary in reporting.create_report.report_fields['summary']
|
|
+ assert expected_reindex in reporting.create_report.report_fields['summary']
|
|
|
|
|
|
def test_different_disk_sufficient_storage(monkeypatch):
|
|
@@ -58,9 +60,11 @@ def test_different_disk_sufficient_storage(monkeypatch):
|
|
|
|
expected_title = 'Satellite PostgreSQL data migration'
|
|
expected_summary = 'You currently have enough free storage to move the data'
|
|
+ expected_reindex = 'all databases will require a REINDEX'
|
|
|
|
assert expected_title == reporting.create_report.report_fields['title']
|
|
assert expected_summary in reporting.create_report.report_fields['summary']
|
|
+ assert expected_reindex in reporting.create_report.report_fields['summary']
|
|
|
|
|
|
def test_different_disk_insufficient_storage(monkeypatch):
|
|
diff --git a/repos/system_upgrade/el7toel8/actors/satellite_upgrader/actor.py b/repos/system_upgrade/el7toel8/actors/satellite_upgrader/actor.py
|
|
index bd1a5d68..b699e6de 100644
|
|
--- a/repos/system_upgrade/el7toel8/actors/satellite_upgrader/actor.py
|
|
+++ b/repos/system_upgrade/el7toel8/actors/satellite_upgrader/actor.py
|
|
@@ -32,3 +32,10 @@ class SatelliteUpgrader(Actor):
|
|
api.current_logger().error(
|
|
'Could not run the installer, please inspect the logs in /var/log/foreman-installer!'
|
|
)
|
|
+
|
|
+ if facts.postgresql.local_postgresql:
|
|
+ api.current_actor().show_message('Re-indexing the database. This can take a while.')
|
|
+ try:
|
|
+ run(['runuser', '-u', 'postgres', '--', 'reindexdb', '-a'])
|
|
+ except (OSError, CalledProcessError) as e:
|
|
+ api.current_logger().error('Failed to run `reindexdb`: {}'.format(str(e)))
|
|
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 d62815ca..21dce7f2 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
|
|
@@ -17,7 +17,8 @@ class MockedRun(object):
|
|
def test_run_installer(monkeypatch, current_actor_context):
|
|
mocked_run = MockedRun()
|
|
monkeypatch.setattr('leapp.libraries.stdlib.run', mocked_run)
|
|
- current_actor_context.feed(SatelliteFacts(has_foreman=True, postgresql=SatellitePostgresqlFacts()))
|
|
+ current_actor_context.feed(SatelliteFacts(has_foreman=True,
|
|
+ postgresql=SatellitePostgresqlFacts(local_postgresql=False)))
|
|
current_actor_context.run()
|
|
assert mocked_run.commands
|
|
assert len(mocked_run.commands) == 1
|
|
@@ -28,8 +29,20 @@ 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()))
|
|
+ postgresql=SatellitePostgresqlFacts(local_postgresql=False)))
|
|
current_actor_context.run()
|
|
assert mocked_run.commands
|
|
assert len(mocked_run.commands) == 1
|
|
assert mocked_run.commands[0] == ['foreman-installer']
|
|
+
|
|
+
|
|
+def test_run_reindexdb(monkeypatch, current_actor_context):
|
|
+ mocked_run = MockedRun()
|
|
+ monkeypatch.setattr('leapp.libraries.stdlib.run', mocked_run)
|
|
+ current_actor_context.feed(SatelliteFacts(has_foreman=True,
|
|
+ postgresql=SatellitePostgresqlFacts(local_postgresql=True)))
|
|
+ current_actor_context.run()
|
|
+ assert mocked_run.commands
|
|
+ assert len(mocked_run.commands) == 2
|
|
+ assert mocked_run.commands[0] == ['foreman-installer', '--disable-system-checks']
|
|
+ assert mocked_run.commands[1] == ['runuser', '-u', 'postgres', '--', 'reindexdb', '-a']
|
|
--
|
|
2.39.0
|
|
|