Fedora Account System
Red Hat Associate
Red Hat Customer
Podman allows the configuration of restart containers. # podman run --restart=always nginx When the system reboots, users expect that this container will be running. In Docker this happens because the user enables the docker service, to create the container in the first place. When the docker daemon starts, it checks to see if their are any containers configured with restart, then it starts them. With Podman we rely on systemd an the podman-restart service to handle this. Thus we would like podman on installation to configure the podman-restart service to run at boot by default. When the system boots, systemd launches podman-service unit file which execs /usr/bin/podman start --all --filter restart-policy=always This service then runs through the podman database looking for containers with restart=always and starts them. Since this is a oneshot unit file, podman exits and is never run again. * Does the service require post-rpm-installation configuration in order to be useful (for example, does it need manual edits to a configuration file)? No, * Does the service listen on a network socket for connections originating on a separate physical or virtual machine? No. * Is the service non-persistent (i.e. run once at startup and exit)? Yes it only runs at boot, checks if there are any containers to start, starts them then exit. Never runs again until next reboot. * What is the exact name (or names) of the systemd unit files to be enabled? /usr/lib/systemd/system/podman-restart.service * Is this request for all Fedora deliverables or only for some Editions (list them)? All
This service pulls in network-online.target. As documented in https://systemd.io/NETWORK_ONLINE/, network-online.target in general should be avoided in favour of more dynamic approaches. It's unfortunate to have an enabled-by-default service using it. Since `--restart=always` is documented as "retrying indefinitely", it seems reasonable to instead have it automatically keep retrying if networking isn't yet up. Another approach would be for podman to only enable this service when a `--restart=always` container is actually started (and disabled if the last `--restart=always` container is removed).
For the record, we've been bit by having `network-online.target` enabled in FCOS in the past so we wrote a test that now fails if it gets pulled in by default, which is why we ended up here. https://github.com/coreos/fedora-coreos-tracker/issues/1380#issuecomment-1382221004
A slightly more efficient approach here would be to: - Change podman to have a file /var/lib/containers/autostart-enabled that exists iff an autostart container exists - Have the systemd unit use ConditionPathExists=/var/lib/containers/autostart-enabled This way we shave off loading and executing podman and scanning all containers (right?) on every boot even for people who don't use this feature
> - Have the systemd unit use ConditionPathExists=/var/lib/containers/autostart-enabled This won't work because systemd doesn't consider ConditionPathExists when setting up the transaction. Conditions are evaluated right before the service is scheduled to start IIRC. We use generators to work around this in our code, which would work here too of course.
Right sorry, I was not trying to directly solve the Requires=network-online.target problem. Why would that even be required?
Probably a cut and paste from an existing PR. I guess they wanted to start the service as soon as the network is up. Please open a PR to how you would like it to look.
Yeah agree, time to stop writing text in bugzilla and write code in a PR. Filed https://github.com/containers/podman/pull/17110