southalc / podman

Puppet module for podman
Apache License 2.0
13 stars 30 forks source link

[0.6.4] creates invalid systemd service file #56

Closed tuxmaster5000 closed 1 year ago

tuxmaster5000 commented 1 year ago

The created service file will contains an invalid line break and the start of the service fails. Example:

 # container-52fc759bdd6b25e3a22cb34d6071cace0adda6ae40dce292867321f4f7aaef9d.service
# autogenerated by Podman 4.2.0
# Tue Mar 21 08:07:05 CET 2023

[Unit]
Description=Podman container-52fc759bdd6b25e3a22cb34d6071cace0adda6ae40dce292867321f4f7aaef9d.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman container run \
        --cidfile=%t/%n.ctr-id \
        --cgroups=no-conmon \
        --rm \
        --sdnotify=conmon \
        -d \
        --replace \
        --name keycloak \
        --label io.containers.autoupdate=registry \
        --label puppet_resource_flags=eyJsYWJlbCI9PlsiaW8uY29udGFpbmVycy5hdXRvdXBkYXRlPXJlZ2lzdHJ5
Il0sICJwdWJsaXNoIj0+Ils6OjFdOjgwODA6ODA4MCIsICJlbnYtZmlsZSI9
PiIvdmFyL2xpYi9rZXljbG9hay9lbnYifQ== \
        --publish [::1]:8080:8080 \
        --env-file /var/lib/keycloak/env quay.io/keycloak/keycloak:21.0.0 start \
        --hostname=foo.foo.foo
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=default.target

systemd will report this error:

systemd[862]: /var/lib/keycloak/.config/systemd/user/podman-keycloak.service:27: Missing '=', ignoring line.
systemd[862]: /var/lib/keycloak/.config/systemd/user/podman-keycloak.service:31: Unknown key name 'PiIvdmFyL2xpYi9rZXljbG9hay9lbnYifQ' in section 'Service', ignoring

And start start fails with:

2023-03-21T08:07:05+0100 systemd[862]: podman-keycloak.service: Main process exited, code=exited, status=125/n/a
2023-03-21T08:07:05+0100 podman[14918]: Error: error reading CIDFile: open /run/user/990/podman-keycloak.service.ctr-id: no such file or directory
southalc commented 1 year ago

This must be the result of using the "--new" flag for the service with the recent change? It looks like we can use strict encoding on the "puppet_resource_flags" to create the value without the newlines. I'll try to get another bugfix release out this week.

tuxmaster5000 commented 1 year ago

Thank you. I will wait for it. And then testing it.

southalc commented 1 year ago

I created the new "issue56" branch with this fix. I've only done limited testing, but was able to create and start a container with the service using the --new flag. Note that this change will cause all podman containers managed by puppet to detect a state change and be re-deployed. Let me know if you're able to test this and if you encounter any problems.

tuxmaster5000 commented 1 year ago

I have tested it and it looks fine. Thanks.

southalc commented 1 year ago

I've merged the "issue56" branch with the master and tagged the new release 0.6.5. Closing this issue