diff options
author | Peter Morrow <pemorrow@linux.microsoft.com> | 2021-09-23 16:54:32 +0100 |
---|---|---|
committer | Peter Morrow <pemorrow@linux.microsoft.com> | 2021-12-13 11:25:57 +0000 |
commit | cdebedb4d40277aad62a7734ba920b4033228197 (patch) | |
tree | 7523417a1b08669301aa1dafacab30342f54e5b6 /src/core/unit-dependency-atom.h | |
parent | a0630d46a59d5c8296c71413eb50c2572e20f046 (diff) | |
download | systemd-cdebedb4d40277aad62a7734ba920b4033228197.tar.gz |
service: pass service exit status to spawned On{Failure,Success}= dependency
When a service exits and triggers either an OnFailure= or OnSuccess=
dependency we now set a new environment variable for the ExecStart= and
ExecStartPre= process. This variable $MONITOR_METADATA exposes the
metadata relating to the service which triggered the dependency.
MONITOR_METADATA takes the following form:
MONITOR_METADATA="SERVICE_RESULT=<result-string0>,EXIT_CODE=<exit-code0>,EXIT_STATUS=<exit-status0>,INVOCATION_ID=<id>,UNIT=<triggering-unit0.service>;SERVICE_RESULT=<result-stringN>,EXIT_CODE=<exit-codeN>,=EXIT_STATUS=<exit-statusN>,INVOCATION_ID=<id>,UNIT=<triggering-unitN.service>"
MONITOR_METADATA is space separated set of metadata relating to the
service(s) which triggered the dependency. This is a list since if we
have 2 services which trigger the same dependency then the dependency
start job may be merged. In this case we need to pass both service
metadata to the triggered service. If there is no job merging then
MONITOR_METADATA will be a single entry.
For example, in the case we had a service "failer.service" which
triggers "failer-handler.service", the following variable is exported to
the ExecStart= and ExecStartPre= processes in failer-handler.service:
MONITOR_METADATA="SERVICE_RESULT=exit-code,EXIT_CODE=exited,EXIT_STATUS=1,INVOCATION_ID=67c657ed7b34466ea369abdf994c6393,UNIT=failer.service"
In another example where we have failer.service and failer2.service
which both also trigger failer-handler.service then the start job for
failer-handler.service may be merged and we might get the following:
MONITOR_METADATA="SERVICE_RESULT=exit-code,EXIT_CODE=exited,EXIT_STATUS=1,INVOCATION_ID=16a93ad196c94109990fb8b9aa5eef5f,UNIT=failer.service;SERVICE_RESULT=exit-code,EXIT_CODE=exited,EXIT_STATUS=1,INVOCATION_ID=ff70131e4cc145e994fb621de25a3e8f,UNIT=failer2.service"
Diffstat (limited to 'src/core/unit-dependency-atom.h')
-rw-r--r-- | src/core/unit-dependency-atom.h | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/core/unit-dependency-atom.h b/src/core/unit-dependency-atom.h index c5f8f5d400..1cf9795786 100644 --- a/src/core/unit-dependency-atom.h +++ b/src/core/unit-dependency-atom.h @@ -66,20 +66,27 @@ typedef enum UnitDependencyAtom { /* Recheck default target deps on other units (which are target units) */ UNIT_ATOM_DEFAULT_TARGET_DEPENDENCIES = UINT64_C(1) << 21, + /* Dependencies which include this atom automatically get a reverse + * REFERENCES/REFERENCED_BY dependency. */ + UNIT_ATOM_BACK_REFERENCE_IMPLIED = UINT64_C(1) << 22, + + /* Trigger a dependency on successful service exit. */ + UNIT_ATOM_ON_SUCCESS = UINT64_C(1) << 23, + /* Trigger a dependency on unsuccessful service exit. */ + UNIT_ATOM_ON_FAILURE = UINT64_C(1) << 24, + /* The remaining atoms map 1:1 to the equally named high-level deps */ - UNIT_ATOM_BEFORE = UINT64_C(1) << 22, - UNIT_ATOM_AFTER = UINT64_C(1) << 23, - UNIT_ATOM_ON_SUCCESS = UINT64_C(1) << 24, - UNIT_ATOM_ON_FAILURE = UINT64_C(1) << 25, - UNIT_ATOM_TRIGGERS = UINT64_C(1) << 26, - UNIT_ATOM_TRIGGERED_BY = UINT64_C(1) << 27, - UNIT_ATOM_PROPAGATES_RELOAD_TO = UINT64_C(1) << 28, - UNIT_ATOM_JOINS_NAMESPACE_OF = UINT64_C(1) << 29, - UNIT_ATOM_REFERENCES = UINT64_C(1) << 30, - UNIT_ATOM_REFERENCED_BY = UINT64_C(1) << 31, - UNIT_ATOM_IN_SLICE = UINT64_C(1) << 32, - UNIT_ATOM_SLICE_OF = UINT64_C(1) << 33, - _UNIT_DEPENDENCY_ATOM_MAX = (UINT64_C(1) << 34) - 1, + UNIT_ATOM_BEFORE = UINT64_C(1) << 25, + UNIT_ATOM_AFTER = UINT64_C(1) << 26, + UNIT_ATOM_TRIGGERS = UINT64_C(1) << 27, + UNIT_ATOM_TRIGGERED_BY = UINT64_C(1) << 28, + UNIT_ATOM_PROPAGATES_RELOAD_TO = UINT64_C(1) << 29, + UNIT_ATOM_JOINS_NAMESPACE_OF = UINT64_C(1) << 30, + UNIT_ATOM_REFERENCES = UINT64_C(1) << 31, + UNIT_ATOM_REFERENCED_BY = UINT64_C(1) << 32, + UNIT_ATOM_IN_SLICE = UINT64_C(1) << 33, + UNIT_ATOM_SLICE_OF = UINT64_C(1) << 34, + _UNIT_DEPENDENCY_ATOM_MAX = (UINT64_C(1) << 35) - 1, _UNIT_DEPENDENCY_ATOM_INVALID = -EINVAL, } UnitDependencyAtom; |