Skip to contentSkip to conversation

RFC???

PATCH In review Armin Kuster 2 participants 4 messages May 31, 2021

lore
Share & tools
lore
#0 lore raw

cover RFC???

I ran into an issue with a systemd service that had a depend. The post init error message was a bit misleading;

ERROR: security-build-image-1.0-r0 do_rootfs: Postinstall scriptlets of ['clamav-daemon'] have failed. If the intention is to defer them to first boot, then please place them into pkg_postinst_ontarget_${PN} ().
Deferring to first boot via 'exit 1' is no longer supported.
Details of the failure are in /home/build/builds/master/tmp/work/qemux86_64-poky-linux/security-build-image/1.0-r0/temp/log.do_rootfs.

All I found was a python trace back in the logs. I have provided a version of an error message that I hope is acceptable. The second patch is for RPM adapting to use the 'error message' to help provide a bit more info.

The RPM solusion has been tested and before porting this to the other package managers, I want to make sure the 'error message' was accepted.

Armin Kuster (2):
systemctl: Stop tracebacks use formated error messages package_manager/rpm: decode systemctl failures

 meta/lib/oe/package_manager/rpm/__init__.py   |  3 +++
 .../systemd/systemd-systemctl/systemctl       | 24 +++++++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 systemctl: Stop tracebacks use formated error messages

When systemctl fail it would throw an exception and dump a traceback. Lets use a more controlled workflow.

[Yocto #14395]

---
 .../systemd/systemd-systemctl/systemctl       | 24 +++++++++++++++----
 1 file changed, 19 insertions(+), 5 deletions(-)
meta/recipes-core/systemd/systemd-systemctl/systemctl +19 -5
index de733e255b..e8c3d2d1ee 100755
@@ -160,7 +160,9 @@ def add_link(path, target):
 
 
 class SystemdUnitNotFoundError(Exception):
-    pass
+    def __init__(self, path, unit):
+        self.path = path
+        self.unit = unit
 
 
 class SystemdUnit():
@@ -224,7 +226,10 @@ class SystemdUnit():
 
         try:
             for also in config.get('Install', 'Also'):
-                SystemdUnit(self.root, also).enable()
+                try:
+                    SystemdUnit(self.root, also).enable()
+                except SystemdUnitNotFoundError as e:
+                    sys.exit("Error: Systemctl also enable issue with  %s (%s)" % (service, e.unit))
 
         except KeyError:
             pass
@@ -265,7 +270,10 @@ def preset_all(root):
         state = presets.state(service)
 
         if state == "enable" or state is None:
-            SystemdUnit(root, service).enable()
+            try:
+                SystemdUnit(root, service).enable()
+            except SystemdUnitNotFoundError:
+                sys.exit("Error: Systemctl preset_all issue in %s" % service)
 
     # If we populate the systemd links we also create /etc/machine-id, which
     # allows systemd to boot with the filesystem read-only before generating
@@ -307,10 +315,16 @@ def main():
 
     if command == "mask":
         for service in args.service:
-            SystemdUnit(root, service).mask()
+            try:
+                SystemdUnit(root, service).mask()
+            except SystemdUnitNotFoundError as e:
+                sys.exit("Error: Systemctl main mask issue in %s (%s)" % (service, e.unit))
     elif command == "enable":
         for service in args.service:
-            SystemdUnit(root, service).enable()
+            try:
+                SystemdUnit(root, service).enable()
+            except SystemdUnitNotFoundError as e:
+                sys.exit("Error: Systemctl main enable issue in %s (%s)" % (service, e.unit))
     elif command == "preset-all":
         if len(args.service) != 0:
             sys.exit("Too many arguments.")
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/2 package_manager/rpm: decode systemctl failures

In reply to Armin Kuster

Parse systemctl error to provide more info

[Yocto #14395]

---
 meta/lib/oe/package_manager/rpm/__init__.py | 3 +++
 1 file changed, 3 insertions(+)
meta/lib/oe/package_manager/rpm/__init__.py +3 -0
index 6df0092281..b392581069 100644
@@ -199,6 +199,9 @@ class RpmPM(PackageManager):
 
         failed_scriptlets_pkgnames = collections.OrderedDict()
         for line in output.splitlines():
+            if line.startswith("Error: Systemctl"):
+                bb.error(line)
+
             if line.startswith("Error in POSTIN scriptlet in rpm package"):
                 failed_scriptlets_pkgnames[line.split()[-1]] = True
 
Signature · 1 line
2.25.1
#3 lore raw
In reply to Armin Kuster

If you attach log.do_rootfs, that would help. It is supposed to contain full information about the failure, and I would not want to start special-casing those.

Alex

Quoted 37 lines · Armin Kuster

I ran into an issue with a systemd service that had a depend. The post init error message was a bit misleading;

ERROR: security-build-image-1.0-r0 do_rootfs: Postinstall scriptlets of ['clamav-daemon'] have failed. If the intention is to defer them to first
boot,
then please place them into pkg_postinst_ontarget_${PN} ().
Deferring to first boot via 'exit 1' is no longer supported.
Details of the failure are in /home/build/builds/master/tmp/work/qemux86_64-poky-linux/security-build-image/1.0-r0/temp/log.do_rootfs.

All I found was a python trace back in the logs. I have provided a version of an
error message that I hope is acceptable. The second patch is for RPM adapting
to use the 'error message' to help provide a bit more info.

The RPM solusion has been tested and before porting this to the other package managers, I want to make sure the 'error message' was accepted.

Armin Kuster (2):
systemctl: Stop tracebacks use formated error messages package_manager/rpm: decode systemctl failures

 meta/lib/oe/package_manager/rpm/__init__.py   |  3 +++
 .../systemd/systemd-systemctl/systemctl       | 24 +++++++++++++++----
 2 files changed, 22 insertions(+), 5 deletions(-)

--
2.25.1