e0acabf core: emit nicer log message for exiting ConditionExec processes

Authored and Committed by zbyszek 2 years ago
    core: emit nicer log message for exiting ConditionExec processes
    
    See https://bugzilla.redhat.com/show_bug.cgi?id=1973058:
    
    we would log something like:
    systemd[244]: Starting willskip.service...
    systemd[244]: willskip.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
    systemd[244]: willskip.service: Skipped due to 'exec-condition'.
    systemd[244]: Condition check resulted in willskip.service being skipped.
    
    The line with 'Control process exited' would be at LOG_NOTICE level.
    
    With the patch:
    systemd[244]: Starting willskip.service...
    systemd[244]: willskip.service: Skipped due to 'exec-condition'.
    systemd[244]: Condition check resulted in willskip.service being skipped.
    
    Debug logs:
    systemd[244]: Starting willskip.service...
    systemd[244]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/willskip_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=8 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
    systemd[244]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/unit/willskip_2eservice interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=9 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
    systemd[244]: Sent message type=signal sender=org.freedesktop.systemd1 destination=n/a path=/org/freedesktop/systemd1/job/46 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=10 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
    systemd[11020]: Skipping PR_SET_MM, as we don't have privileges.
    systemd[11020]: willskip.service: Executing: sh -c 'exit 2'
    systemd[244]: Received SIGCHLD from PID 11020 (sh).
    systemd[244]: Child 11020 (sh) died (code=exited, status=2/INVALIDARGUMENT)
    systemd[244]: willskip.service: Child 11020 belongs to willskip.service.
    systemd[244]: willskip.service: Condition check process exited, code=exited, status=2/INVALIDARGUMENT (success)
    systemd[244]: willskip.service: Got final SIGCHLD for state condition.
    systemd[244]: willskip.service: Skipped due to 'exec-condition'.
    systemd[244]: willskip.service: Service will not restart (restart setting)
    systemd[244]: willskip.service: Changed condition -> dead
    systemd[244]: willskip.service: Job 46 willskip.service/start finished, result=done
    systemd[244]: Condition check resulted in willskip.service being skipped.
    
    (cherry picked from commit 58441bc177bb1bcdeceff74d3ae6b6d9f93a7fbe)
    
        
file modified
+15 -3
file modified
+3 -2