forked from rpms/leapp-repository
102 lines
5.0 KiB
Diff
102 lines
5.0 KiB
Diff
From e26359877b1d90d1f95a424216a00e711c72c923 Mon Sep 17 00:00:00 2001
|
|
From: karolinku <kkula@redhat.com>
|
|
Date: Tue, 9 Sep 2025 13:56:37 +0200
|
|
Subject: [PATCH 05/55] Prevent sssdupdate actor from rising errors
|
|
|
|
Potential error rise (StopActorExecutionError) is replaced with
|
|
warning logs in the SSSD update file processing function. This
|
|
prevents the upgrade from failing when accessing non-critical files.
|
|
Also fix minor formatting nit picks.
|
|
|
|
Jira: RHEL-108992
|
|
---
|
|
.../sssd/sssdchecks/libraries/sssdchecks.py | 4 ++--
|
|
.../sssd/sssdfacts/libraries/sssdfacts.py | 5 ++++-
|
|
.../sssd/sssdupdate/libraries/sssdupdate.py | 18 +++++++-----------
|
|
3 files changed, 13 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/repos/system_upgrade/el9toel10/actors/sssd/sssdchecks/libraries/sssdchecks.py b/repos/system_upgrade/el9toel10/actors/sssd/sssdchecks/libraries/sssdchecks.py
|
|
index 0a86fa7b..cb95026c 100644
|
|
--- a/repos/system_upgrade/el9toel10/actors/sssd/sssdchecks/libraries/sssdchecks.py
|
|
+++ b/repos/system_upgrade/el9toel10/actors/sssd/sssdchecks/libraries/sssdchecks.py
|
|
@@ -15,8 +15,8 @@ def check_config(model):
|
|
'SSSD\'s sss_ssh_knownhostsproxy tool is replaced by the more '
|
|
'reliable sss_ssh_knownhosts tool. SSH\'s configuration will be updated '
|
|
'to reflect this by updating every mention of sss_ssh_knownhostsproxy by '
|
|
- 'the corresponding mention of sss_ssh_knownhosts, even those commented out.\n'
|
|
- 'SSSD\'s ssh service will be enabled if not already done.\n'
|
|
+ 'the corresponding mention of sss_ssh_knownhosts, even those commented out. '
|
|
+ 'SSSD\'s ssh service will be enabled if not already done.\n\n'
|
|
'The following files will be updated:{}{}'.format(
|
|
FMT_LIST_SEPARATOR,
|
|
FMT_LIST_SEPARATOR.join(model.sssd_config_files + model.ssh_config_files)
|
|
diff --git a/repos/system_upgrade/el9toel10/actors/sssd/sssdfacts/libraries/sssdfacts.py b/repos/system_upgrade/el9toel10/actors/sssd/sssdfacts/libraries/sssdfacts.py
|
|
index 0ae9d93f..7d343229 100644
|
|
--- a/repos/system_upgrade/el9toel10/actors/sssd/sssdfacts/libraries/sssdfacts.py
|
|
+++ b/repos/system_upgrade/el9toel10/actors/sssd/sssdfacts/libraries/sssdfacts.py
|
|
@@ -19,7 +19,10 @@ def _does_file_contain_expression(file_path, expression):
|
|
)
|
|
return False
|
|
except OSError as e:
|
|
- raise StopActorExecutionError('Could not open file ' + file_path, details={'details': str(e)})
|
|
+ raise StopActorExecutionError(
|
|
+ 'Could not open configuration file',
|
|
+ details={'details': 'Coudn\'t open {} file with error: {}.'.format(file_path, str(e))}
|
|
+ )
|
|
|
|
|
|
def _look_for_files(expression: str, path_list: list[str]) -> list[str]:
|
|
diff --git a/repos/system_upgrade/el9toel10/actors/sssd/sssdupdate/libraries/sssdupdate.py b/repos/system_upgrade/el9toel10/actors/sssd/sssdupdate/libraries/sssdupdate.py
|
|
index 6d745ead..5b96bcc6 100644
|
|
--- a/repos/system_upgrade/el9toel10/actors/sssd/sssdupdate/libraries/sssdupdate.py
|
|
+++ b/repos/system_upgrade/el9toel10/actors/sssd/sssdupdate/libraries/sssdupdate.py
|
|
@@ -1,7 +1,7 @@
|
|
import os
|
|
import re
|
|
|
|
-from leapp.exceptions import StopActorExecutionError
|
|
+from leapp.libraries.stdlib import api
|
|
|
|
|
|
def _process_knownhosts(line: str) -> str:
|
|
@@ -29,30 +29,26 @@ def _process_enable_svc(line: str) -> str:
|
|
|
|
|
|
def _update_file(filename, process_function):
|
|
- newname = filename + '.new'
|
|
- oldname = filename + '.old'
|
|
+ newname = '{}.leappnew'.format(filename)
|
|
+ oldname = '{}.leappsave'.format(filename)
|
|
try:
|
|
- with open(filename, 'r') as input_file, open(newname, 'x') as output_file:
|
|
+ with open(filename, 'r') as input_file, open(newname, 'w') as output_file:
|
|
istat = os.fstat(input_file.fileno())
|
|
os.fchmod(output_file.fileno(), istat.st_mode)
|
|
for line in input_file:
|
|
try:
|
|
output_file.write(process_function(line))
|
|
except OSError as e:
|
|
- raise StopActorExecutionError('Failed to write to {}'.format(newname),
|
|
- details={'details': str(e)})
|
|
+ api.current_logger().warning('Failed to write to {}'.format(newname), details={'details': str(e)})
|
|
|
|
- except FileExistsError as e:
|
|
- raise StopActorExecutionError('Temporary file already exists: {}'.format(newname),
|
|
- details={'details': str(e)})
|
|
except OSError as e:
|
|
try:
|
|
os.unlink(newname)
|
|
except FileNotFoundError:
|
|
pass
|
|
- raise StopActorExecutionError('Failed to access the required files', details={'details': str(e)})
|
|
+ api.current_logger().error('Failed to access the required files', details={'details': str(e)})
|
|
|
|
- # Let's make sure the old configuration is preserverd if something goes wrong
|
|
+ # Let's make sure the old configuration is preserved if something goes wrong
|
|
os.replace(filename, oldname)
|
|
os.replace(newname, filename)
|
|
os.unlink(oldname)
|
|
--
|
|
2.51.1
|
|
|