-
Notifications
You must be signed in to change notification settings - Fork 539
Description
Describe the bug
Somehow, generated systemd unit files from a pod and containers using podman-compose
are not cohesive; if I start the pod service, all containers will start, but if I stop the pod service, not all containers stop and the pod is left in a "degraded" state.
To Reproduce
Create a compose file called foo.yaml
with these contents:
version: "2.1"
services:
app:
image: docker.io/python
container_name: app
ports:
- 5000:5000
web:
image: docker.io/nginx
container_name: web
ports:
- 8080:80
then modify the podman-compose
script such that pods are created with --infra=true
. Then create the pod/containers and generate systemd files with:
podman-compose -f foo.yaml -p foo up -d
podman pod stop pod_foo
podman generate systemd pod_foo --files --name
Install the unit files to ~/.config/systemd/user/
and start the pod with:
systemctl --user start pod-pod_foo.service
and stop the pod with:
systemctl --user stop pod-pod_foo.service
Expected behavior
systemctl --user stop pod-pod_foo.service
will stop the pod and all containers therein.
Actual behavior
systemctl --user stop pod-pod_foo.service
only stops the infra container, and all other containers are left running and the pod is in a "degraded" state.
Output
For reference, the same deployment can be created with only podman
commands using the following:
# Create pod
podman pod create --infra=true --name foo
# Create containers and run them in the pod
podman run --name app -dt --pod foo docker.io/python
podman run --name web -dt --pod foo docker.io/nginx
# The pod will be running now, so let's stop it:
podman pod stop foo
# Generate systemd unit files
podman generate systemd foo --files --name
That generates systemd unit files that work as expected, and look like this:
# pod-foo.service
# autogenerated by Podman 3.4.4
# Mon Feb 28 20:40:12 PST 2022
[Unit]
Description=Podman pod-foo.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=
Requires=container-app.service container-web.service
Before=container-app.service container-web.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStart=/usr/bin/podman start f1292dabc396-infra
ExecStop=/usr/bin/podman stop -t 10 f1292dabc396-infra
ExecStopPost=/usr/bin/podman stop -t 10 f1292dabc396-infra
PIDFile=/run/user/1000/containers/overlay-containers/e24a0d50b5666215946963a9219bb35b4f26f1ae75c1d09c151ea381f0155eab/userdata/conmon.pid
Type=forking
[Install]
WantedBy=default.target
# container-app.service
# autogenerated by Podman 3.4.4
# Mon Feb 28 20:40:12 PST 2022
[Unit]
Description=Podman container-app.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/run/user/1000/containers
BindsTo=pod-foo.service
After=pod-foo.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStart=/usr/bin/podman start app
ExecStop=/usr/bin/podman stop -t 10 app
ExecStopPost=/usr/bin/podman stop -t 10 app
PIDFile=/run/user/1000/containers/overlay-containers/6ed0b973ec269542c7376eca7e302679f565cb292d703525b70884bf74513ada/userdata/conmon.pid
Type=forking
[Install]
WantedBy=default.target
# container-web.service
# autogenerated by Podman 3.4.4
# Mon Feb 28 20:40:12 PST 2022
[Unit]
Description=Podman container-web.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/run/user/1000/containers
BindsTo=pod-foo.service
After=pod-foo.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStart=/usr/bin/podman start web
ExecStop=/usr/bin/podman stop -t 10 web
ExecStopPost=/usr/bin/podman stop -t 10 web
PIDFile=/run/user/1000/containers/overlay-containers/1c36d668d474366f427ccde2b344728c63bf1dc9d68bf30af34dabb2fe82ca1d/userdata/conmon.pid
Type=forking
[Install]
WantedBy=default.target
Notice that the units for the containers have BindsTo
and After
referencing pod-foo.service
.
However, with the podman-compose
reproduction steps above, I get systemd unit files that look like this:
# pod-pod_foo.service
# autogenerated by Podman 3.4.4
# Mon Feb 28 21:15:15 PST 2022
[Unit]
Description=Podman pod-pod_foo.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=
Requires=container-app.service container-web.service
Before=container-app.service container-web.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStart=/usr/bin/podman start caf63e041bfc-infra
ExecStop=/usr/bin/podman stop -t 10 caf63e041bfc-infra
ExecStopPost=/usr/bin/podman stop -t 10 caf63e041bfc-infra
PIDFile=/run/user/1000/containers/overlay-containers/3e02551e71997ec7739d62405961a6761bbad34e73e7a348f6434330bd5a58bd/userdata/conmon.pid
Type=forking
[Install]
WantedBy=default.target
# container-app.service
# autogenerated by Podman 3.4.4
# Mon Feb 28 21:15:15 PST 2022
[Unit]
Description=Podman container-app.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/run/user/1000/containers
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStart=/usr/bin/podman start app
ExecStop=/usr/bin/podman stop -t 10 app
ExecStopPost=/usr/bin/podman stop -t 10 app
PIDFile=/run/user/1000/containers/overlay-containers/1ab907341ee16531bace29b1ba64031f31eae0b21edbd9b60c5be6eb0af43c42/userdata/conmon.pid
Type=forking
[Install]
WantedBy=default.target
# container-web.service
# autogenerated by Podman 3.4.4
# Mon Feb 28 21:15:15 PST 2022
[Unit]
Description=Podman container-web.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/run/user/1000/containers
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStart=/usr/bin/podman start web
ExecStop=/usr/bin/podman stop -t 10 web
ExecStopPost=/usr/bin/podman stop -t 10 web
PIDFile=/run/user/1000/containers/overlay-containers/116a9f7f05750d890dbff368dcfe3e28b0157c848ca9cc42df925d35c9954652/userdata/conmon.pid
Type=forking
[Install]
WantedBy=default.target
$ podman-compose version
podman-compose version: 1.0.4
['podman', '--version', '']
using podman version: 3.4.4
podman-composer version 1.0.4
podman --version
podman version 3.4.4
exit code: 0
(Using latest master)
Environment:
- OS: Arch Linux
Additional context