Open alaviss opened 5 months ago
quadlet uses systemd-%P_%I
for templates as name so it doesn't actually parse the name at all currently. I am not sure how qualdet should fix this, i.e. how can we convert a unit name to a valid container name?
cc @ygalblum @alexlarsson
@Luap99 what if we just add something at the end of the string. Not sure what, but whatever string. Will that do the trick?
Container names (pods, networks, volumes as well) must confirm to this regex [a-zA-Z0-9][a-zA-Z0-9_.-]*
so no.
This seems a general problem, unit names allow different chars than our names so using any of the systemd specifies for names makes quadlet incompatible with podman in such case. One thing is to tell users to not name units like this but given the example is here template units with Accept=yes the users has no control over the name AFAICT
But even if we try to stop using the systemd specifiers and make qualdet convert the name it still cannot work for template units as it does not know the instance names ahead of time. I see there is %i
that contains the escaped name so maybe using this over %I
(unescaped) makes it work? Although if it used the normal escape logic it writes special chars as \x...
and the back slash would not be accepted either by podman.
So really I see no way to fix this besides patching podman to allow such names which I think would have a lot of other consequences we do not like.
I thought the specifiers where returning an empty string. But, now I realize that no and that there is even more to it.
In testing this issue, I found that systemd replaces -
with /
for both the I
and P
specifiers. As a result naming either the template Quadlet file or the instance with -
will result in an error.
For reference, in order to test different cases I used this service unit file:
[Unit]
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/usr/bin/echo systemd-%P_%I
Type=oneshot
RemainAfterExit=yes
So, I think that at minimum, we should consider replacing I
and P
with i
and p
. But, I'm not sure it won't open a new can of worms.
see https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#String%20Escaping%20for%20Inclusion%20in%20Unit%20Names for the escape rules, the -
to /
is expected as they use this for path escaping.
Using %i
and %p
seems logical in that regard because we can at least keep the dash. I don't think it would cause other problems. All the special chars that might be used currently where not accepted by podman in the first place.
I've opened this PR: #23029 to change the behavior. I did not mark it as resolving this issue because from what I can tell, this specific case will still not work
A friendly reminder that this issue had no activity for 30 days.
Maybe I'm reading the MR (#23029) incorrectly, but it seems to me the change was only done for .container, not for .pod?
Issue Description
Templated containers will not start if invalid characters (ie.
:
) are present in the instance name. This will happen if systemd socket activation withAccept=true
is used.Sample files:
test@.container
:test.socket
:Steps to reproduce the issue
Steps to reproduce the issue
test@.container
andtest.socket
in appropriate locationstest.socket
socat tcp:localhost:8080 stdout
Describe the results you received
Got no output, related journal entries:
Describe the results you expected
This should show up:
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
No response
Additional information
No response