0

I'm trying to force one unit to run to completion before another unit starts, and all docs say that I should trust Requires= but it's not working as advertised.

Here is the actual unit I'm starting (it's generated from a quadlet).

# Automatically generated by /usr/lib/systemd/system-generators/podman-system-generator # [Unit] Description=Traefik Wants=network-online.target After=network-online.target [email protected] SourcePath=/etc/containers/systemd/traefik.container RequiresMountsFor=%t/containers RequiresMountsFor=/var/opt/traefik/traefik.toml RequiresMountsFor=/var/opt/traefik/dynamic.toml Requires=acme-volume.service After=acme-volume.service [X-Container] ContainerName=traefik Image=docker.io/traefik:v2.10 Volume=/var/opt/traefik/traefik.toml:/var/opt/traefik/traefik.toml:Z Volume=/var/opt/traefik/dynamic.toml:/var/opt/traefik/dynamic.toml:Z Volume=acme.volume:/var/opt/traefik/letsencrypt/:Z PublishPort=80:80 PublishPort=443:443 EnvironmentFile=/var/opt/traefik/environment Exec=--configFile=/var/opt/traefik/traefik.toml [Service] Restart=always Environment=PODMAN_SYSTEMD_UNIT=%n KillMode=mixed ExecStop=/usr/bin/podman rm -f -i --cidfile=%t/%N.cid ExecStopPost=-/usr/bin/podman rm -f -i --cidfile=%t/%N.cid Delegate=yes Type=notify NotifyAccess=all SyslogIdentifier=%N ExecStart=/usr/bin/podman run --name=traefik --cidfile=%t/%N.cid --replace --rm --cgroups=split --sdnotify=conmon -d -v /var/opt/traefik/traefik.toml:/var/opt/traefik/traefik.toml:Z -v /var/opt/traefik/dynamic.toml:/var/opt/traefik/dynamic.toml:Z -v systemd-acme:/var/opt/traefik/letsencrypt/:Z --publish 80:80 --publish 443:443 --env-file /var/opt/traefik/environment docker.io/traefik:v2.10 --configFile=/var/opt/traefik/traefik.toml [Install] WantedBy=multi-user.target default.target 

Note that it has the line [email protected].

Here is that unit /etc/systemd/system/[email protected].

[Unit] Description=podman volume import %i Wants=network-online.target After=network-online.target [Service] Type=oneshot EnvironmentFile=/etc/podman-volume-backup/environment ExecStart=/usr/local/bin/podman-volume-restore.bash %i Restart=on-failure KillMode=process TimeoutStopSec=300 

When I run systemctl start traefik and check the logs for both units I see that traefik starts simultaneously as podman-volume-restore. It's not at all waiting for it to exit as the docs say it should.

What is wrong with my dependencies?

1 Answer 1

0

I spoke too soon. I had missed that Requires only works in order if you also specify After=.

So now after changing the After line to After=network-online.target [email protected] it works as intended.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.