containers / quadlet

GNU General Public License v2.0
347 stars 14 forks source link

Support for UDP Ports #18

Closed b-m-f closed 2 years ago

b-m-f commented 3 years ago

Currently is does not seem possible to add the protocol for PublishPort.

What should be possible? -> 80:80/udp

I guess this code https://github.com/containers/quadlet/blob/main/src/generator.c#L519 would need one more switch case?

I have not written any C code before, but if you think this would be a good addition I can give it a try over the weekend :)

XenGi commented 3 years ago

Seems like it's just splitting the string up on the : so the /udp or /tcp should stay with the port number. Are you sure it doesn't work? I haven't tested it myself yet.

b-m-f commented 3 years ago

@XenGi will recheck this these days! Maybe I made a mistake somewhere

XenGi commented 3 years ago

So it seems, something isn't working correctly.

I tried this:

$ podman run -it --rm -u 900 -p 7777:7777/udp mycontainer:latest

And got this result:

$ ss -tulpen | grep 7777
udp   UNCONN 0      0                    0.0.0.0:7777       0.0.0.0:*    ino:15848781 sk:11 cgroup:/ <->

Then I created the following container:

[Unit]
Description=My container

[Container]
Image=mycontainer:latest
PublishPort=7777:7777/udp
PublishPort=8080:8080/tcp
User=900

[Service]
Restart=always

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

It starts up but it doesn't seem to bind to the UDP ports.

Also gives these errors:

[1037581.475790] quadlet-generator[3681084]: Invalid port format '7777/udp'
[1037581.475801] quadlet-generator[3681084]: Invalid port format '8080/tcp'

Adding the line PublishPort=8080:8080 to the mycontainer.container file results in the param -p 8080:8080 in the file /run/systemd/generator/mycontainer.service. But the lines that end with /udp don't create such params. The line PublishPort=8080:8080/tcp also doesn't create a corresponding parameter. So I guess the problem is the detection of the slash. I'm trying to find the issue in the code and maybe provide a pull request later.

XenGi commented 3 years ago

I found the issue. The regex that detects ports and ranges simply needed an addition for detecting the protocol suffix. I also added test cases and created a pull request: https://github.com/containers/quadlet/pull/19 @alexlarsson could you have a look?

b-m-f commented 3 years ago

Thanks @XenGi !

XenGi commented 2 years ago

Is this project still alive?

rhatdan commented 2 years ago

Yes, I am not sure what is going on with @alexlarsson

XenGi commented 2 years ago

@rhatdan Can someone ping @alexlarsson? I hope he's alright. Last activity on GitHub was just 14 days ago. Maybe someone else from the containers project could support in the mean time. I mean live and paying work is always more important then open source work. So having multiple maintainers per project makes sense. The bus factor, you know. ;)

XenGi commented 2 years ago

Hi @alexlarsson, good to see you. Thx for merging. I'll try to implement something for my other issue when I find time.