tl;dr: a .path unit does not appear to be waiting for the After= unit to run first.
I have a one-shot service, mktags.service, a long-running job of type notify, ccistated.service, and a path unit with its corresponding service, workdir.path and workdir.service. Here are the relevant parts of the unit files:
mktags.service
[Unit]Description=Populate /run/metadata/tagsAfter=network.target[Service]ExecStart=/usr/local/sbin/mktags.pyType=oneshot[Install]WantedBy=multi-user.target
ccistated.service
[Unit]Description=State Machine ManagerAfter=mktags.serviceConditionPathExists=/run/metadata/tags/resource_class[Service]ExecStart=/usr/local/sbin/ccistated.pyType=notifyNotifyAccess=all[Install]WantedBy = multi-user.target
workdir.path
[Unit]Description=Trigger workdir.service when a job starts, creating a directory in /opt/circleci/workdirAfter=ccistated.serviceConditionPathExists=/run/metadata/tags/resource_class[Path]PathChanged=/opt/circleci/workdir[Install]WantedBy=multi-user.target
What mktags does is extract the metadata tags from the metadata service, and populate /run/metadata/tags/.
$ systemctl status mktags.service
* mktags.service - Populate /run/metadata/tags
Loaded: loaded (/etc/systemd/system/mktags.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2021-03-27 05:34:00 UTC; 10min ago
Process: 454 ExecStart=/usr/local/sbin/mktags.py (code=exited, status=0/SUCCESS)
Main PID: 454 (code=exited, status=0/SUCCESS)
Loaded: loaded (/etc/systemd/system/mktags.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2021-03-27 05:34:00 UTC; 10min ago
Process: 454 ExecStart=/usr/local/sbin/mktags.py (code=exited, status=0/SUCCESS)
Main PID: 454 (code=exited, status=0/SUCCESS)
Sure enough, it ran:
$ cat /run/metadata/tags/resource_class
waw
waw
$ systemctl status ccistated.service
* ccistated.service - State Machine Manager
Loaded: loaded (/etc/systemd/system/ccistated.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-03-27 05:36:00 UTC; 8min ago
Main PID: 1420 (python3)
Tasks: 1 (limit: 9544)
Memory: 8.5M
CGroup: /system.slice/ccistated.service
`-1420 python3 /usr/local/sbin/ccistated.py
* ccistated.service - State Machine Manager
Loaded: loaded (/etc/systemd/system/ccistated.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-03-27 05:36:00 UTC; 8min ago
Main PID: 1420 (python3)
Tasks: 1 (limit: 9544)
Memory: 8.5M
CGroup: /system.slice/ccistated.service
`-1420 python3 /usr/local/sbin/ccistated.py
But look at the old workdir.path:
$ systemctl status workdir.path
* workdir.path - Trigger workdir.service when a job starts, creating a directory in /opt/circleci/workdir
Loaded: loaded (/etc/systemd/system/workdir.path; enabled; vendor preset: enabled)
Active: inactive (dead)
Triggers: * workdir.service
Condition: start condition failed at Sat 2021-03-27 05:33:59 UTC; 22min ago
`- ConditionPathExists=/run/metadata/tags/resource_class was not met
* workdir.path - Trigger workdir.service when a job starts, creating a directory in /opt/circleci/workdir
Loaded: loaded (/etc/systemd/system/workdir.path; enabled; vendor preset: enabled)
Active: inactive (dead)
Triggers: * workdir.service
Condition: start condition failed at Sat 2021-03-27 05:33:59 UTC; 22min ago
`- ConditionPathExists=/run/metadata/tags/resource_class was not met
Huh?!?!?! It's supposed to run after ccistated, and of course after mktags (highlighted in cyan above). It appears to be running anyway, and of course mktags has not gotten a chance to finish, and the ConditionExists file has not been created yet.
Do .path units not obey the same startup rules?
_______________________________________________ systemd-devel mailing list systemd-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/systemd-devel