Please check the status of this specification in Launchpad before editing it. If it is Approved, contact the Assignee or another knowledgeable person before making changes.
Events currently have both arguments and environment, where arguments are used for matching in job definitions and environment is available to the job processes itself. This specification proposes removing arguments in favour of matching on environment instead.
Arguments to events used to be passed to the job processes as positional arguments, but JobEventExpressions removed this since there is no logical way to do this given the more complex event matching it allows; States reduces their usefulness even further. Since only environment is passed to job processes now, information would need to be needlessly duplicated in both.
This scope of this specification is limited to the removal of arguments from the event, and redefining how events are matched based on environment.
- Arguments are removed from events.
- Environment to the event is considered to have an order, thus matching may be done using this order.
path-mounted PATH=/usr start on path-mounted /usr
- Matching may also be done by variable name.
start on path-mounted DEVICE=/dev/sd*
- Quoting of the variable name may be done over the entire argument, or over the value part; both are equivalent.
start on example "FOO=foo bar" start on example FOO="foo bar"
- Matches on position must precede matches by name.
start on path-mounted /usr DEVICE=/dev/sd*
- Failure to adhere to above will result in the job definition failing to parse.
- To match an environment variable containing an equals sign, the variable name must be used.
start on example FOO=foo=bar
- Job events will receive the same combination of arguments and environment, except that the arguments will now be named.
stopped JOB=apache RESULT=failed PROCESS=main EXIT_SIGNAL=SEGV
Code changes are primarily limited to init/event.c and init/event.h.
The args member will be removed from the Event structure and code that uses it removed.
The args member of the EventOperator structure will be changed to env and code that uses it changed to match.
event_operator_match will be modified to match against the env table by position and name as described.
job_emit_event will be modified to produce the new event format.
parse_on_operand will be modified to ensure that positional arguments do not follow name-based ones.
Data preservation and migration
These changes are largely backwards compatible with the previous behaviour.