Skip to content

Handle uninstantiated template quadlets#28380

Open
simonbrauner wants to merge 1 commit into
podman-container-tools:mainfrom
simonbrauner:issue-26960
Open

Handle uninstantiated template quadlets#28380
simonbrauner wants to merge 1 commit into
podman-container-tools:mainfrom
simonbrauner:issue-26960

Conversation

@simonbrauner

@simonbrauner simonbrauner commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

`podman quadlet list` and `podman quadlet rm` works with uninstantiated templates

@simonbrauner

Copy link
Copy Markdown
Contributor Author

The issue proposes to disregard template files, so this would be a quick fix.

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.

@simonbrauner simonbrauner force-pushed the issue-26960 branch 2 times, most recently from 64918ba to 8194502 Compare March 30, 2026 10:33
@simonbrauner simonbrauner force-pushed the issue-26960 branch 3 times, most recently from e27140d to 28a5a12 Compare April 14, 2026 09:28
@simonbrauner simonbrauner changed the title Handle template files in quadlet list Handle uninstantiated template quadlets Apr 14, 2026
@simonbrauner simonbrauner force-pushed the issue-26960 branch 2 times, most recently from c20f56e to 9266aa5 Compare April 15, 2026 11:25
@packit-as-a-service

Copy link
Copy Markdown

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@simonbrauner simonbrauner marked this pull request as ready for review April 15, 2026 12:46
@simonbrauner simonbrauner force-pushed the issue-26960 branch 2 times, most recently from bd08c84 to 36d7f3c Compare April 20, 2026 14:40
@packit-as-a-service

Copy link
Copy Markdown

tmt tests failed for commit 36d7f3c. @lsm5, @psss, @thrix please check.

Comment thread pkg/domain/infra/abi/quadlet.go Outdated
}
}

if len(templateServiceNames) != 0 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/
  • DefaultInstance
  • systemctl --user start
  • Systemd dependency (Wants key 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changed. For templates, rm without --force fails if there are running instances. With --force the instances are stopped.

Comment thread docs/source/markdown/podman-quadlet-list.1.md.in Outdated
Comment thread pkg/systemd/quadlet/quadlet.go Outdated
@packit-as-a-service

Copy link
Copy Markdown

tmt tests failed for commit c3ecb25. @lsm5, @psss, @thrix please check.

@simonbrauner

Copy link
Copy Markdown
Contributor Author

/packit rebuild-failed

@packit-as-a-service

Copy link
Copy Markdown

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@simonbrauner

Copy link
Copy Markdown
Contributor Author

/packit rebuild-failed

@packit-as-a-service

Copy link
Copy Markdown

tmt tests failed for commit c3ecb25. @lsm5, @psss, @thrix please check.

@psss

psss commented May 4, 2026

Copy link
Copy Markdown

tmt tests failed for commit c3ecb25. @lsm5, @psss, @thrix please check.

Should be fixed once rebased on the latest main.

@simonbrauner

simonbrauner commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

Removing all instances when template is removed could be tricky as sleep@1.service is an instance of template:

sleep@1.service - A templated sleepy container
   Loaded: loaded (/home/sbrauner/.config/containers/systemd/sleep@.container; generated)

but sleep@2.service is just a service which supports the %i substitution but otherwise works just as regular concrete service and is not related to sleep@.container at all:

sleep@2.service - A templated sleepy container
   Loaded: loaded (/home/sbrauner/.config/containers/systemd/sleep@2.container; generated)

https://0pointer.de/blog/projects/instances.html

I'll try to solve it by looking at the SourcePath property in systemd.

@mheon mheon added the 6.0 Breaking changes for Podman 6.0 label May 4, 2026
@simonbrauner simonbrauner marked this pull request as draft May 5, 2026 13:18
@simonbrauner simonbrauner marked this pull request as ready for review May 6, 2026 16:27
@simonbrauner simonbrauner force-pushed the issue-26960 branch 4 times, most recently from dbc709c to c4f2d02 Compare June 2, 2026 15:19
@simonbrauner simonbrauner marked this pull request as draft June 10, 2026 14:52
@simonbrauner simonbrauner marked this pull request as ready for review June 10, 2026 16:25
@simonbrauner simonbrauner requested a review from Honny1 June 10, 2026 16:44
@packit-as-a-service

Copy link
Copy Markdown

tmt tests failed for commit b25bb53. @lsm5, @psss, @thrix please check.

@simonbrauner

Copy link
Copy Markdown
Contributor Author

/packit rebuild-failed

@Honny1 Honny1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just non-blocking comments.

Comment thread pkg/domain/infra/abi/quadlet_utils.go Outdated
Comment thread pkg/domain/infra/abi/quadlet_utils.go
Comment thread pkg/domain/infra/abi/quadlet_utils.go Outdated
Comment thread pkg/domain/infra/abi/quadlet_utils.go Outdated
Comment thread pkg/domain/infra/abi/quadlet_utils.go
@simonbrauner simonbrauner force-pushed the issue-26960 branch 2 times, most recently from 8b94ab1 to e36f1d3 Compare June 11, 2026 15:04
@packit-as-a-service

Copy link
Copy Markdown

tmt tests failed for commit e36f1d3. @lsm5, @psss, @thrix please check.

@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

LGTM
some test unhappiness at the moment though

@Honny1 Honny1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

@simonbrauner any thoughts on the test issues?

Fixes: podman-container-tools#26960

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
@simonbrauner

Copy link
Copy Markdown
Contributor Author

The labels machine, governance and CI are there from a rebase mistake. The original failures were fixed by rebase, there is only one failure now, which does not seem quadlet-related.
@TomSweeneyRedHat @Honny1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/api-change Change to remote API; merits scrutiny

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants