forked from rpms/leapp-repository
91 lines
3.5 KiB
Diff
91 lines
3.5 KiB
Diff
From ae40cb78af75ff0901280b624e6d633a55023933 Mon Sep 17 00:00:00 2001
|
|
From: Michal Reznik <mreznik@redhat.com>
|
|
Date: Thu, 26 May 2022 13:02:31 +0200
|
|
Subject: [PATCH 39/39] Improve Leapp resume service cleanup + logging
|
|
|
|
---
|
|
.../actors/createresumeservice/actor.py | 15 ++++++++---
|
|
.../actors/removeresumeservice/actor.py | 25 +++++++++++--------
|
|
2 files changed, 26 insertions(+), 14 deletions(-)
|
|
|
|
diff --git a/repos/system_upgrade/common/actors/createresumeservice/actor.py b/repos/system_upgrade/common/actors/createresumeservice/actor.py
|
|
index 3019c611..eae4aa8f 100644
|
|
--- a/repos/system_upgrade/common/actors/createresumeservice/actor.py
|
|
+++ b/repos/system_upgrade/common/actors/createresumeservice/actor.py
|
|
@@ -1,11 +1,12 @@
|
|
-import shutil
|
|
import os
|
|
+import shutil
|
|
|
|
-from leapp.exceptions import StopActorExecutionError
|
|
+from leapp import reporting
|
|
from leapp.actors import Actor
|
|
+from leapp.exceptions import StopActorExecutionError
|
|
+from leapp.libraries.stdlib import api
|
|
+from leapp.reporting import create_report, Report
|
|
from leapp.tags import FinalizationPhaseTag, IPUWorkflowTag
|
|
-from leapp.reporting import Report, create_report
|
|
-from leapp import reporting
|
|
|
|
|
|
class CreateSystemdResumeService(Actor):
|
|
@@ -36,6 +37,12 @@ class CreateSystemdResumeService(Actor):
|
|
except OSError:
|
|
pass
|
|
|
|
+ if os.path.exists(symlink_path):
|
|
+ api.current_logger().debug(
|
|
+ 'Symlink {} already exists (from previous upgrade?). Removing... '.format(symlink_path)
|
|
+ )
|
|
+ os.unlink(symlink_path)
|
|
+
|
|
try:
|
|
os.symlink(service_path, symlink_path)
|
|
except OSError as e:
|
|
diff --git a/repos/system_upgrade/common/actors/removeresumeservice/actor.py b/repos/system_upgrade/common/actors/removeresumeservice/actor.py
|
|
index c69816d5..07e96eae 100644
|
|
--- a/repos/system_upgrade/common/actors/removeresumeservice/actor.py
|
|
+++ b/repos/system_upgrade/common/actors/removeresumeservice/actor.py
|
|
@@ -1,10 +1,10 @@
|
|
-import os
|
|
import errno
|
|
+import os
|
|
|
|
-from leapp.actors import Actor
|
|
-from leapp.libraries.stdlib import run
|
|
-from leapp.reporting import Report, create_report
|
|
from leapp import reporting
|
|
+from leapp.actors import Actor
|
|
+from leapp.libraries.stdlib import api, run
|
|
+from leapp.reporting import create_report, Report
|
|
from leapp.tags import FirstBootPhaseTag, IPUWorkflowTag
|
|
|
|
|
|
@@ -24,12 +24,17 @@ class RemoveSystemdResumeService(Actor):
|
|
service_name = 'leapp_resume.service'
|
|
if os.path.isfile('/etc/systemd/system/{}'.format(service_name)):
|
|
run(['systemctl', 'disable', service_name])
|
|
- try:
|
|
- os.unlink('/etc/systemd/system/{}'.format(service_name))
|
|
- os.unlink('/etc/systemd/system/default.target.wants/{}'.format(service_name))
|
|
- except OSError as e:
|
|
- if e.errno != errno.ENOENT:
|
|
- raise
|
|
+ paths_to_unlink = [
|
|
+ '/etc/systemd/system/{}'.format(service_name),
|
|
+ '/etc/systemd/system/default.target.wants/{}'.format(service_name),
|
|
+ ]
|
|
+ for path in paths_to_unlink:
|
|
+ try:
|
|
+ os.unlink(path)
|
|
+ except OSError as e:
|
|
+ api.current_logger().debug('Failed removing {}: {}'.format(path, str(e)))
|
|
+ if e.errno != errno.ENOENT:
|
|
+ raise
|
|
|
|
create_report([
|
|
reporting.Title('"{}" service deleted'.format(service_name)),
|
|
--
|
|
2.35.3
|
|
|