Update ELevate patch

This commit is contained in:
Andrew Lukoshko 2023-03-27 14:33:31 +02:00
parent 97519ae71b
commit 6b5ce215b1
2 changed files with 106 additions and 12 deletions

View File

@ -823,10 +823,10 @@ index c9c2741..911d11d 100644
diff --git a/commands/upgrade/util.py b/commands/upgrade/util.py diff --git a/commands/upgrade/util.py b/commands/upgrade/util.py
index 75ffa6a..27970b4 100644 index 75ffa6a..de021a5 100644
--- a/commands/upgrade/util.py --- a/commands/upgrade/util.py
+++ b/commands/upgrade/util.py +++ b/commands/upgrade/util.py
@@ -2,18 +2,24 @@ import functools @@ -2,18 +2,25 @@ import functools
import itertools import itertools
import json import json
import os import os
@ -836,6 +836,7 @@ index 75ffa6a..27970b4 100644
+import six.moves +import six.moves
from datetime import datetime from datetime import datetime
+from contextlib import contextmanager +from contextlib import contextmanager
+import six
from leapp.cli.commands import command_utils from leapp.cli.commands import command_utils
from leapp.cli.commands.config import get_config from leapp.cli.commands.config import get_config
@ -853,7 +854,7 @@ index 75ffa6a..27970b4 100644
def disable_database_sync(): def disable_database_sync():
@@ -167,6 +173,44 @@ def warn_if_unsupported(configuration): @@ -167,6 +174,44 @@ def warn_if_unsupported(configuration):
report_unsupported(devel_vars, configuration["whitelist_experimental"]) report_unsupported(devel_vars, configuration["whitelist_experimental"])
@ -898,7 +899,7 @@ index 75ffa6a..27970b4 100644
def handle_output_level(args): def handle_output_level(args):
""" """
Set environment variables following command line arguments. Set environment variables following command line arguments.
@@ -236,3 +280,61 @@ def process_report_schema(args, configuration): @@ -236,3 +281,65 @@ def process_report_schema(args, configuration):
raise CommandError('--report-schema version can not be greater that the ' raise CommandError('--report-schema version can not be greater that the '
'actual {} one.'.format(default_report_schema)) 'actual {} one.'.format(default_report_schema))
return args.report_schema or default_report_schema return args.report_schema or default_report_schema
@ -938,9 +939,13 @@ index 75ffa6a..27970b4 100644
+ +
+ for error in errors: + for error in errors:
+ model = ErrorModel.create(json.loads(error['message']['data'])) + model = ErrorModel.create(json.loads(error['message']['data']))
+ error_message = model.message
+ if six.PY2:
+ error_message = model.message.encode('utf-8', 'xmlcharrefreplace')
+
+ logger.error("{time} [{severity}] Actor: {actor}\nMessage: {message}\n".format( + logger.error("{time} [{severity}] Actor: {actor}\nMessage: {message}\n".format(
+ severity=model.severity.upper(), + severity=model.severity.upper(),
+ message=model.message, time=model.time, actor=model.actor)) + message=error_message, time=model.time, actor=model.actor))
+ if model.details: + if model.details:
+ print('Summary:') + print('Summary:')
+ details = json.loads(model.details) + details = json.loads(model.details)
@ -2195,6 +2200,58 @@ index 0000000..8e27d99
+ reporting.Tags([reporting.Tags.UPGRADE_PROCESS]), + reporting.Tags([reporting.Tags.UPGRADE_PROCESS]),
+ ] + ]
+ ) + )
diff --git a/repos/system_upgrade/cloudlinux/actors/restorerepositoryconfigurations/actor.py b/repos/system_upgrade/cloudlinux/actors/restorerepositoryconfigurations/actor.py
new file mode 100644
index 0000000..5b90c59
--- /dev/null
+++ b/repos/system_upgrade/cloudlinux/actors/restorerepositoryconfigurations/actor.py
@@ -0,0 +1,46 @@
+from leapp.actors import Actor
+from leapp.libraries.stdlib import api
+from leapp.libraries.common import dnfconfig, mounting, repofileutils
+from leapp.libraries.common.cllaunch import run_on_cloudlinux
+from leapp.models import (
+ RepositoriesFacts,
+)
+from leapp.tags import ApplicationsPhaseTag, IPUWorkflowTag
+
+
+class RestoreRepositoryConfigurations(Actor):
+ """
+ Go over the list of repositories that were present on the pre-upgrade system and compare them to the
+ current list (after the main upgrade transaction).
+ If any of the repositories with same repoIDs have changed their enabled state, due to changes coming
+ from RPM package updates or something else, restore their enabled settings to the pre-upgrade state.
+ """
+
+ name = 'restore_repository_configurations'
+ consumes = (RepositoriesFacts)
+ produces = ()
+ tags = (ApplicationsPhaseTag.After, IPUWorkflowTag)
+
+ @run_on_cloudlinux
+ def process(self):
+ current_repofiles = repofileutils.get_parsed_repofiles()
+ current_repository_list = []
+ for repofile in current_repofiles:
+ current_repository_list.extend(repofile.data)
+ current_repodict = dict((repo.repoid, repo) for repo in current_repository_list)
+
+ current_repoids_string = ", ".join(current_repodict.keys())
+ self.log.debug("Repositories currently present on the system: {}".format(current_repoids_string))
+
+ cmd_context = mounting.NotIsolatedActions(base_dir='/')
+
+ for repos_facts in api.consume(RepositoriesFacts):
+ for repo_file in repos_facts.repositories:
+ for repo_data in repo_file.data:
+ if repo_data.repoid in current_repodict:
+ if repo_data.enabled and not current_repodict[repo_data.repoid].enabled:
+ self.log.debug("Repository {} was enabled pre-upgrade, restoring".format(repo_data.repoid))
+ dnfconfig.enable_repository(cmd_context, repo_data.repoid)
+ elif not repo_data.enabled and current_repodict[repo_data.repoid].enabled:
+ self.log.debug("Repository {} was disabled pre-upgrade, restoring".format(repo_data.repoid))
+ dnfconfig.disable_repository(cmd_context, repo_data.repoid)
diff --git a/repos/system_upgrade/cloudlinux/actors/scancontrolpanel/actor.py b/repos/system_upgrade/cloudlinux/actors/scancontrolpanel/actor.py diff --git a/repos/system_upgrade/cloudlinux/actors/scancontrolpanel/actor.py b/repos/system_upgrade/cloudlinux/actors/scancontrolpanel/actor.py
new file mode 100644 new file mode 100644
index 0000000..96524ed index 0000000..96524ed
@ -3402,10 +3459,10 @@ index f4b02e9..c22165e 100644
def test_pes_data_not_found(monkeypatch): def test_pes_data_not_found(monkeypatch):
def read_or_fetch_mocked(filename, directory="/etc/leapp/files", service=None, allow_empty=False): def read_or_fetch_mocked(filename, directory="/etc/leapp/files", service=None, allow_empty=False):
diff --git a/repos/system_upgrade/common/actors/redhatsignedrpmscanner/actor.py b/repos/system_upgrade/common/actors/redhatsignedrpmscanner/actor.py diff --git a/repos/system_upgrade/common/actors/redhatsignedrpmscanner/actor.py b/repos/system_upgrade/common/actors/redhatsignedrpmscanner/actor.py
index 01f6df3..9a4990e 100644 index 01f6df3..8464970 100644
--- a/repos/system_upgrade/common/actors/redhatsignedrpmscanner/actor.py --- a/repos/system_upgrade/common/actors/redhatsignedrpmscanner/actor.py
+++ b/repos/system_upgrade/common/actors/redhatsignedrpmscanner/actor.py +++ b/repos/system_upgrade/common/actors/redhatsignedrpmscanner/actor.py
@@ -1,27 +1,67 @@ @@ -1,27 +1,69 @@
from leapp.actors import Actor from leapp.actors import Actor
from leapp.libraries.common import rhui from leapp.libraries.common import rhui
-from leapp.models import InstalledRedHatSignedRPM, InstalledRPM, InstalledUnsignedRPM -from leapp.models import InstalledRedHatSignedRPM, InstalledRPM, InstalledUnsignedRPM
@ -3422,7 +3479,9 @@ index 01f6df3..9a4990e 100644
+ '45689c882fa658e0'], + '45689c882fa658e0'],
+ 'centos': ['24c6a8a7f4a80eb5', + 'centos': ['24c6a8a7f4a80eb5',
+ '05b555b38483c65d', + '05b555b38483c65d',
+ '4eb84e71f2ee9d55'], + '4eb84e71f2ee9d55',
+ 'a963bbdbf533f4fa',
+ '6c7cb6ef305d49d6'],
+ 'cloudlinux': ['8c55a6628608cb71'], + 'cloudlinux': ['8c55a6628608cb71'],
+ 'almalinux': ['51d6647ec21ad6ea', + 'almalinux': ['51d6647ec21ad6ea',
+ 'd36cb86cb86b3716'], + 'd36cb86cb86b3716'],
@ -3483,7 +3542,7 @@ index 01f6df3..9a4990e 100644
signed_pkgs = InstalledRedHatSignedRPM() signed_pkgs = InstalledRedHatSignedRPM()
unsigned_pkgs = InstalledUnsignedRPM() unsigned_pkgs = InstalledUnsignedRPM()
@@ -32,11 +72,11 @@ class RedHatSignedRpmScanner(Actor): @@ -32,11 +74,11 @@ class RedHatSignedRpmScanner(Actor):
all_signed = [ all_signed = [
env env
for env in env_vars for env in env_vars
@ -3498,7 +3557,7 @@ index 01f6df3..9a4990e 100644
def is_gpg_pubkey(pkg): def is_gpg_pubkey(pkg):
"""Check if gpg-pubkey pkg exists or LEAPP_DEVEL_RPMS_ALL_SIGNED=1 """Check if gpg-pubkey pkg exists or LEAPP_DEVEL_RPMS_ALL_SIGNED=1
@@ -44,15 +84,30 @@ class RedHatSignedRpmScanner(Actor): @@ -44,15 +86,30 @@ class RedHatSignedRpmScanner(Actor):
gpg-pubkey is not signed as it would require another package gpg-pubkey is not signed as it would require another package
to verify its signature to verify its signature
""" """
@ -3534,7 +3593,7 @@ index 01f6df3..9a4990e 100644
def is_azure_pkg(pkg): def is_azure_pkg(pkg):
"""Whitelist Azure config package.""" """Whitelist Azure config package."""
@@ -68,16 +123,25 @@ class RedHatSignedRpmScanner(Actor): @@ -68,16 +125,25 @@ class RedHatSignedRpmScanner(Actor):
for pkg in rpm_pkgs.items: for pkg in rpm_pkgs.items:
if any( if any(
[ [
@ -4766,6 +4825,41 @@ index 03f3cd4..2ab78ea 100644
} }
diff --git a/repos/system_upgrade/common/libraries/dnfconfig.py b/repos/system_upgrade/common/libraries/dnfconfig.py
index 2125f6d..f1dbf70 100644
--- a/repos/system_upgrade/common/libraries/dnfconfig.py
+++ b/repos/system_upgrade/common/libraries/dnfconfig.py
@@ -114,3 +114,30 @@ def exclude_leapp_rpms(context):
"""
to_exclude = list(set(_get_excluded_pkgs(context) + get_leapp_packages()))
_set_excluded_pkgs(context, to_exclude)
+
+
+def enable_repository(context, reponame):
+ _set_repository_state(context, reponame, "enabled")
+
+
+def disable_repository(context, reponame):
+ _set_repository_state(context, reponame, "disabled")
+
+
+def _set_repository_state(context, repo_id, new_state):
+ """
+ Set the Yum repository with the provided ID as enabled or disabled.
+ """
+ if new_state == "enabled":
+ cmd_flag = '--set-enabled'
+ elif new_state == "disabled":
+ cmd_flag = '--set-disabled'
+
+ cmd = ['dnf', 'config-manager', cmd_flag, repo_id]
+
+ try:
+ context.call(cmd)
+ except CalledProcessError:
+ api.current_logger().error('Cannot set the dnf configuration')
+ raise
+ api.current_logger().debug('Repository {} has been {}'.format(repo_id, new_state))
diff --git a/repos/system_upgrade/common/libraries/dnfplugin.py b/repos/system_upgrade/common/libraries/dnfplugin.py diff --git a/repos/system_upgrade/common/libraries/dnfplugin.py b/repos/system_upgrade/common/libraries/dnfplugin.py
index 4010e9f..f095575 100644 index 4010e9f..f095575 100644
--- a/repos/system_upgrade/common/libraries/dnfplugin.py --- a/repos/system_upgrade/common/libraries/dnfplugin.py

View File

@ -43,7 +43,7 @@ py2_byte_compile "%1" "%2"}
Epoch: 1 Epoch: 1
Name: leapp-repository Name: leapp-repository
Version: 0.16.0 Version: 0.16.0
Release: 6%{?dist}.elevate.10 Release: 6%{?dist}.elevate.11
Summary: Repositories for leapp Summary: Repositories for leapp
License: ASL 2.0 License: ASL 2.0