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

[Quadlet] Escape @ in container names by default #18705

Closed
matt-allan opened this issue May 26, 2023 · 8 comments
Closed

[Quadlet] Escape @ in container names by default #18705

matt-allan opened this issue May 26, 2023 · 8 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

@matt-allan
Copy link

Feature request description

Context

I am using the Quadlet .container files to generate template units.

The filename is [email protected] and the relevant part of the file looks like this:

[Unit]
Description=Memsol index container wrk.%I
After=network.target

[Container]
Image=example-internal-registry.com/orca/memsol:latest
ContainerName=systemd-memsol-index-%I
Exec=bin/memsol --index --consumer %i

I start the units like this:

systemctl --user start [email protected]
systemctl --user start [email protected]

I'm using the template units because I need to run N services where the only difference is the --consumer option's value.

The Problem

It took me a while to figure this out. If I don't specify ContainerName manually I get an error because the @ symbol is not allowed in a ContainerName, it is required to use a template unit, and the Quadlet generator does not escape or remove the @ when generating the ContainerName. Specifying the ContainerName manually to omit the @ and include the %I placeholder instead avoids the issue and gives me the container names systemd-memsol-index-1, systemd-memsol-index-2, etc.

Suggest potential solution

Ideally Quadlet would generate a valid and unique name for instantiated template units.

If the unit file is a template unit, instead of using systemd-%N as the default ContainerName it would use systemd-%p-%I.

For example, with the file [email protected], running systemctl --user daemon-reload && systemctl --user start [email protected] would start a container named http-server-8080.

I don't believe this would count as a breaking change since the generated default ContainerName is not usable as-is?

Have you considered any alternatives?

  • The manual workaround I am using now works but it's a bit repetitive and the error message is confusing
  • If container names could contain @ this wouldn't be an issue but that may have other ramifications
  • The @ could be replaced with a different symbol than a -
  • The Quadlet docs could include an example of using template units to document this workaround

Additional context

Add any other context or screenshots about the feature request here.

@matt-allan matt-allan added the kind/feature Categorizes issue or PR as related to a new feature. label May 26, 2023
@rhatdan
Copy link
Member

rhatdan commented May 26, 2023

Interested in opening a PR to add this functionality?

@alexlarsson @vrothberg @ygalblum PTAL

@ygalblum
Copy link
Contributor

Currently, Quadlet does not support templating. There is an open discussion on this issue #17744.
@alexlarsson did you get any response from the Systemd team?

@github-actions
Copy link

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

@rhatdan
Copy link
Member

rhatdan commented Jul 3, 2023

Still waiting for @alexlarsson response.

@alexlarsson
Copy link
Contributor

@ygalblum No response, but this is the upstream issue:
systemd/systemd#28006

I think changing the default to systemd-%p-%I if there is an @in the name makes a lot of sense. However, I agree with @ygalblum that there are more issues here related to the automatic enabling of such files.

Maybe we can decouple these for now by just saying we don't support the Install section on templates for now? That way we get part of this going, and can address easy auto-starting of templates later.

@github-actions
Copy link

github-actions bot commented Aug 5, 2023

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

@rhatdan
Copy link
Member

rhatdan commented Aug 9, 2023

No update on this.

@Luap99
Copy link
Member

Luap99 commented Apr 4, 2024

I assume this can be closed after #21068

@Luap99 Luap99 closed this as completed Apr 4, 2024
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Jul 4, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Jul 4, 2024
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

5 participants