containers / podlet

Generate Podman Quadlet files from a Podman command, compose file, or existing object
https://crates.io/crates/podlet
Mozilla Public License 2.0
422 stars 12 forks source link

Converting docker compose file does not append necessary `.network` to network names #90

Closed puresick closed 5 days ago

puresick commented 3 months ago

Hey :wave:

After setting up Penpot with its official docker compose file I wanted to add Quadlet systemd units to keep its containers restarted after a server reboot.

Using Podlet I converted the compose file, which resulted in the postgres and redis container to fail starting properly. systemctl --user status penpot-redis.service gave the following error (it was similar for penpot-postgres.service:

Failed to start penpot-redis.service.                                                                                    
penpot-redis.service: Scheduled restart job, restart counter is at 5.                                                    
penpot-redis.service: Start request repeated too quickly.                                                                
penpot-redis.service: Failed with result 'exit-code'.                                                                    
Failed to start penpot-redis.service.

Unfortunately journalctl -xe did not show any more detail on this error.

While trying to understand this and fiddling around with a simple quadlet file setting up redis, I notices that adding Network=penpot was causing the same issue on the test quadlet file. Researching a bit lead me to the clue to append .networkto that line resulting in Network=penpot.network, which solved the issue.

I assume this might be something getting lost in the convertion process?

Please let me know if any more details will help solving this issue.

System Info:

eKristensen commented 2 months ago

I've just had the same issue just now.

eKristensen commented 2 months ago

You get more details in journalctl from root

bishtawi commented 1 month ago

I ran into this problem as well. It looks like a regression as it used to properly append .network to network names. See https://github.com/containers/podlet/issues/48

Hopefully this can be fixed but in the meantime, here is a bash script to fixup your generated quadlets:

for file in ./*.container; do
    sed -i 's/^Network=.*/&.network/' "${file}"
done

EDIT: Did a little bit of diving through the git history to see if I could identify when the regression happened and see if I can quickly fix it. Turned out it happened as part of the big refactor done in https://github.com/containers/podlet/pull/73 If you look at file src/cli/container/quadlet.rs and search for ".network" (including the quotes) you can see that entire file was heavily refactored and an unfortunate side effect was that this bug got introduced. I dont know this code base at all so I can't quickly fix it but hopefully someone with an understanding of the code can easily address it.

Perhaps @k9withabone can fix it?

k9withabone commented 2 weeks ago

Oops, my bad. I'll fix it for the next release.