All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] RFC???
@ 2021-05-31 19:11 Armin Kuster
  2021-05-31 19:11 ` [PATCH 1/2] systemctl: Stop tracebacks use formated error messages Armin Kuster
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Armin Kuster @ 2021-05-31 19:11 UTC (permalink / raw)
  To: openembedded-core

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] systemctl: Stop tracebacks use formated error messages
  2021-05-31 19:11 [PATCH 0/2] RFC??? Armin Kuster
@ 2021-05-31 19:11 ` Armin Kuster
  2021-05-31 19:11 ` [PATCH 2/2] package_manager/rpm: decode systemctl failures Armin Kuster
  2021-05-31 19:20 ` [OE-core] [PATCH 0/2] RFC??? Alexander Kanavin
  2 siblings, 0 replies; 4+ messages in thread
From: Armin Kuster @ 2021-05-31 19:11 UTC (permalink / raw)
  To: openembedded-core

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

[Yocto #14395]

Signed-off-by: Armin Kuster <akuster808@gmail.com>
---
 .../systemd/systemd-systemctl/systemctl       | 24 +++++++++++++++----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd-systemctl/systemctl b/meta/recipes-core/systemd/systemd-systemctl/systemctl
index de733e255b..e8c3d2d1ee 100755
--- a/meta/recipes-core/systemd/systemd-systemctl/systemctl
+++ b/meta/recipes-core/systemd/systemd-systemctl/systemctl
@@ -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.")
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] package_manager/rpm: decode systemctl failures
  2021-05-31 19:11 [PATCH 0/2] RFC??? Armin Kuster
  2021-05-31 19:11 ` [PATCH 1/2] systemctl: Stop tracebacks use formated error messages Armin Kuster
@ 2021-05-31 19:11 ` Armin Kuster
  2021-05-31 19:20 ` [OE-core] [PATCH 0/2] RFC??? Alexander Kanavin
  2 siblings, 0 replies; 4+ messages in thread
From: Armin Kuster @ 2021-05-31 19:11 UTC (permalink / raw)
  To: openembedded-core

Parse systemctl error to provide more info

[Yocto #14395]

Signed-off-by: Armin Kuster <akuster808@gmail.com>
---
 meta/lib/oe/package_manager/rpm/__init__.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/meta/lib/oe/package_manager/rpm/__init__.py b/meta/lib/oe/package_manager/rpm/__init__.py
index 6df0092281..b392581069 100644
--- a/meta/lib/oe/package_manager/rpm/__init__.py
+++ b/meta/lib/oe/package_manager/rpm/__init__.py
@@ -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
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [OE-core] [PATCH 0/2] RFC???
  2021-05-31 19:11 [PATCH 0/2] RFC??? Armin Kuster
  2021-05-31 19:11 ` [PATCH 1/2] systemctl: Stop tracebacks use formated error messages Armin Kuster
  2021-05-31 19:11 ` [PATCH 2/2] package_manager/rpm: decode systemctl failures Armin Kuster
@ 2021-05-31 19:20 ` Alexander Kanavin
  2 siblings, 0 replies; 4+ messages in thread
From: Alexander Kanavin @ 2021-05-31 19:20 UTC (permalink / raw)
  To: Armin Kuster; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 1555 bytes --]

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

On Mon, 31 May 2021 at 21:12, Armin Kuster <akuster808@gmail.com> wrote:

> 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
>
>
> 
>
>

[-- Attachment #2: Type: text/html, Size: 1966 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-31 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-31 19:11 [PATCH 0/2] RFC??? Armin Kuster
2021-05-31 19:11 ` [PATCH 1/2] systemctl: Stop tracebacks use formated error messages Armin Kuster
2021-05-31 19:11 ` [PATCH 2/2] package_manager/rpm: decode systemctl failures Armin Kuster
2021-05-31 19:20 ` [OE-core] [PATCH 0/2] RFC??? Alexander Kanavin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.