Handle uninstantiated template quadlets#28380
Conversation
|
The issue proposes to diff --git a/pkg/domain/infra/abi/quadlet.go b/pkg/domain/infra/abi/quadlet.go
index 34652ebbc4..c8a4dc24ed 100644
--- a/pkg/domain/infra/abi/quadlet.go
+++ b/pkg/domain/infra/abi/quadlet.go
@@ -708,6 +708,12 @@ func (ic *ContainerEngine) QuadletList(ctx context.Context, options entities.Qua
reports = append(reports, &report)
continue
}
+
+ if strings.Contains(serviceName, "@.") {
+ // Template file, skipping
+ continue
+ }
+
partialReports[serviceName] = report
allServiceNames = append(allServiceNames, serviceName)
}I will try to use a different way to query systemd, so that templates could also be included in the listing. |
64918ba to
8194502
Compare
e27140d to
28a5a12
Compare
c20f56e to
9266aa5
Compare
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
bd08c84 to
36d7f3c
Compare
| } | ||
| } | ||
|
|
||
| if len(templateServiceNames) != 0 { |
There was a problem hiding this comment.
There can still be running instances of the templates removed, right? I wonder if we should distinguish between the removal of concrete services and templated ones. Because while concrete services are stopped before they are removed, it's not the same for template services, and iiuc the user can't really tell the difference while running podman quadlet rm <concrete_svc> <template_svc>, unless I'm missing something.
There was a problem hiding this comment.
Yes, that is right. I documented it that way
When the argument is uninstantiated template quadlet, this command removes the
template quadlet file (e.g. `templateName@.container`) and the generated systemd
template unit (e.g. `templateName@.service`, unless **--reload-systemd** is set to `false`).
Instances of the systemd template unit (e.g. `templateName@instanceName.service`)
may persist, and can be removed with **systemctl(1)**.
It seemed reasonable to do it this way for the minimal fix of the issue, but there could be a follow up which elaborates on this.
On one hand, perhaps it would be nice to help users to manage instances, but there are plenty of ways how instances can be created:
- from a file which has instance name already -
podman quadlet install templateName@instanceName.container - by creating a symlink to template name in
~/.config/containers/systemd/ DefaultInstancesystemctl --user start- Systemd dependency (
Wantskey for example)
so it could be messy to cover all the cases.
On the other hand, instances of templates could be even considered out of scope, as quadlets are about generating services, and what the services are used for is responsibility of systemd. So from this point of view - my fix is consistent, it removes the .container file and the .service file generated from it for both concrete units and templates.
There was a problem hiding this comment.
This changed. For templates, rm without --force fails if there are running instances. With --force the instances are stopped.
36d7f3c to
c3ecb25
Compare
|
/packit rebuild-failed |
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
|
/packit rebuild-failed |
|
Removing all instances when template is removed could be tricky as but https://0pointer.de/blog/projects/instances.html I'll try to solve it by looking at the |
dbc709c to
c4f2d02
Compare
c4f2d02 to
bcfa34a
Compare
bcfa34a to
63181d3
Compare
63181d3 to
f52c922
Compare
f52c922 to
b25bb53
Compare
|
/packit rebuild-failed |
Honny1
left a comment
There was a problem hiding this comment.
Just non-blocking comments.
8b94ab1 to
e36f1d3
Compare
|
LGTM |
|
@simonbrauner any thoughts on the test issues? |
e36f1d3 to
e0d0d5b
Compare
Fixes: podman-container-tools#26960 Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
e0d0d5b to
4866cba
Compare
|
The labels |
Checklist
Ensure you have completed the following checklist for your pull request to be reviewed:
commits. (
git commit -s). (If needed, usegit commit -s --amend). The author email must matchthe sign-off email address. See CONTRIBUTING.md
for more information.
Fixes: #00000in commit message (if applicable)make validatepr(format/lint checks)Noneif no user-facing changes)Does this PR introduce a user-facing change?