[systemd-devel] Ordering of oneshot services and path units?
Andrei Borzenkov
arvidjaar at gmail.com
Sat Mar 27 09:58:54 UTC 2021
On 27.03.2021 10:11, John Ioannidis wrote:
...
>
> *workdir.path *
>
> [Unit]
> Description=Trigger workdir.service when a job starts, creating a directory
> in /opt/circleci/workdir
> After=ccistated.service
> ConditionPathExists=/run/metadata/tags/resource_class
> [Path]
> PathChanged=/opt/circleci/workdir
> [Install]
> WantedBy=multi-user.target
>
>
...
>
> 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?
>
By default all path units have Before=paths.target dependency which puts
them before basic.target and all service units have default dependency
After=basic.target. So you have dependency loop which systemd needs to
break; results are unpredictable.
You will need DefaultDependencies=false in your path unit (and likely
usual Conflicts=shutdown.target in addition to make sure unit is stopped
on shutdown).
More information about the systemd-devel
mailing list