Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable and persistent systemd units #9948

Closed
jpf91 opened this issue Apr 6, 2021 · 5 comments
Closed

Portable and persistent systemd units #9948

jpf91 opened this issue Apr 6, 2021 · 5 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@jpf91
Copy link

jpf91 commented Apr 6, 2021

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind feature

Description

I have some services which perform some expensive initial setup and for some this setup shouldn't even be run unattended. Because of that, I can't use the podman systemd generate --new units, as I don't want to create new containers on each restart. OTOH the podman systemd generate services are not portable: I can't really use them on coreos, as the initial setup does not have any containers initialized. I came up with these unit template for myself, which I hope doesn't have any hidden issues:

[Unit]
Description=Podman test.service
Wants=network.target
After=network-online.target

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
ExecStartPre=/bin/rm -f %t/test-fedora.pid
ExecStartPre=-/bin/podman create \
  --log-driver journald \
  --conmon-pidfile %t/test-fedora.pid \
  --label "io.containers.autoupdate=image" \
  --cgroups=no-conmon \
  --name test-fedora \
  registry.fedoraproject.org/fedora-minimal:33 /bin/bash -c "while true; do sleep 10; echo foo; done"
ExecStart=/usr/bin/podman start test-fedora
ExecStop=/usr/bin/podman stop --ignore test-fedora -t 10
PIDFile=%t/test-fedora.pid
KillMode=none
Type=forking

[Install]
WantedBy=multi-user.target default.target

Here if "test-fedora" does not exists, a new container is created. Otherwise the create command fails (and is ignored) and the unit calls start anyway. Maybe it'd make sense to include a stop/kill before the create, just to be safe?

BTW: I think --log-driver journald should really be included in all systemd units.

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 6, 2021
@vrothberg
Copy link
Member

Thanks for opening the issue and apologies for the long silence, we've been super busy.

--label "io.containers.autoupdate=image" \

That would not work. podman auto-update restart the systemd unit, so even if there's a newer image the old container would continue running.

I am open to add a new template to generate systemd but the mentioned use case does not seem sufficiently generic to me. If container creation doesn't work unattended, then it seems like a red flag for automation to me.

@github-actions
Copy link

github-actions bot commented Jun 4, 2021

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Jun 7, 2021

@vrothberg Where do we stand on this one?

@vrothberg
Copy link
Member

@vrothberg Where do we stand on this one?

No progress since we're in bug-scrubbing mode. But I am also not yet convinced about the idea. The underlying assumption would be that podman create is a bottle neck and I have not seen evidence for it yet.

One thing, I do want to tackle now is enforcing the journald logger in the units.

@vrothberg
Copy link
Member

I am going to close this issue.

@rhatdan is currently working on making journald the the default log-driver.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

4 participants