Your message dated Wed, 20 Oct 2021 20:39:51 +0200
with message-id <[email protected]>
and subject line Re: Bug#996911: systemd: dbus signal JobRemoved for a failed 
job is 'done' instead of 'failed'
has caused the Debian Bug report #996911,
regarding systemd: dbus signal JobRemoved for a failed job is 'done' instead of 
'failed'
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
996911: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=996911
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: systemd
Version: 247.3-6
Severity: normal

Dear Maintainer,

man:org.freedesktop.systemd1 says:

    JobRemoved() are sent out each time a new job is queued or dequeued.
    [...] done indicates successful execution of a job.

However, when I subscribe to the JobRemoved signal and I restart a failing
job, I get 'done' as a result.

I used the following script:

--
#!/usr/bin/python3

from gi.repository import GLib

import dbus
import dbus.mainloop.glib


def systemd_event_cb(pid, jobid, unit, result):
    print('received event for unit %s with result %s'
          % (unit, result))

def subscribe():
    sysbus = dbus.SystemBus()
    systemd1 = sysbus.get_object('org.freedesktop.systemd1',
                                 '/org/freedesktop/systemd1')
    systemd1.connect_to_signal('JobRemoved', systemd_event_cb)
    manager = dbus.Interface(systemd1,
                             'org.freedesktop.systemd1.Manager')
    manager.Subscribe()

GLib.timeout_add(100, subscribe)

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
loop = GLib.MainLoop()

loop.run()
--

The output of the script is:

        received event for unit davmail.service with result done

However:

--
$ sudo systemctl status davmail
× davmail.service - Davmail Exchange gateway
     Loaded: loaded (/lib/systemd/system/davmail.service; disabled; vendor 
preset: enabled)
     Active: failed (Result: exit-code) since Wed 2021-10-20 17:15:21 CEST; 12s 
ago
    Process: 10271 ExecStartPre=/usr/share/davmail/service-prepare 
(code=exited, status=0/SUCCESS)
    Process: 10274 ExecStart=/usr/bin/davmail -server 
/etc/davmail/davmail.properties (code=exited, status=1/FAILURE)
   Main PID: 10274 (code=exited, status=1/FAILURE)
        CPU: 27ms

oct. 20 17:15:21 skade systemd[1]: Starting Davmail Exchange gateway...
oct. 20 17:15:21 skade systemd[1]: Started Davmail Exchange gateway.
oct. 20 17:15:21 skade systemd[1]: davmail.service: Main process exited, 
code=exited, status=1/FAILURE
oct. 20 17:15:21 skade systemd[1]: davmail.service: Failed with result 
'exit-code'.
--

Thanks,

Alex

-- Package-specific info:

-- System Information:
Debian Release: 11.1
  APT prefers stable-security
  APT policy: (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-9-amd64 (SMP w/4 CPU threads)
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages systemd depends on:
ii  adduser               3.118
ii  chrony [time-daemon]  4.0-8
ii  libacl1               2.2.53-10
ii  libapparmor1          2.13.6-10
ii  libaudit1             1:3.0-2
ii  libblkid1             2.36.1-8
ii  libc6                 2.31-13+deb11u2
ii  libcap2               1:2.44-1
ii  libcrypt1             1:4.4.18-4
ii  libcryptsetup12       2:2.3.5-1
ii  libgcrypt20           1.8.7-6
ii  libgnutls30           3.7.1-5
ii  libgpg-error0         1.38-2
ii  libip4tc2             1.8.7-1
ii  libkmod2              28-1
ii  liblz4-1              1.9.3-2
ii  liblzma5              5.2.5-2
ii  libmount1             2.36.1-8
ii  libpam0g              1.4.0-9+deb11u1
ii  libseccomp2           2.5.1-1
ii  libselinux1           3.1-3
ii  libsystemd0           247.3-6
ii  libzstd1              1.4.8+dfsg-2.1
ii  mount                 2.36.1-8
ii  util-linux            2.36.1-8

Versions of packages systemd recommends:
ii  dbus  1.12.20-2

Versions of packages systemd suggests:
ii  policykit-1        0.105-31
ii  systemd-container  247.3-6

Versions of packages systemd is related to:
pn  dracut           <none>
ii  initramfs-tools  0.140
pn  libnss-systemd   <none>
ii  libpam-systemd   247.3-6
ii  udev             247.3-6

-- Configuration Files:
/etc/systemd/journald.conf changed [not included]

-- no debconf information

--- End Message ---
--- Begin Message ---
Am 20.10.21 um 18:46 schrieb Alexandre Rossi:
Do you get the same result with Type=simple ?

Ah, Type=simple

If you read the documentation of Type=simple carefully, there is the following

"the service manager will consider the unit started immediately
after the main service process has been forked off."

This means, the actual status/return code of the service is not reported back.

For systemd, the job is considered successful, as it was able to succesfully fork of the process. The only way this can fail is e.g. if the binary is missing, has unmet library dependencies etc.

This is btw. the reason why I do *not* recommend Type=simple for long running processes, where the status of the service actually matter.

See also Luca's blog entry regarding this (subtle) issue
https://www.lucas-nussbaum.net/blog/?p=877

I usually recommend to use Type=notify or if that is not possible, I think forking is better then simple for most cases.

So what you get is by design, even if the result might be unexpected to you. I hope this clarifies the issue.

I'm closing this bug report given the above explanation.

Regards,
Michael

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


--- End Message ---

Reply via email to