Description
Issue Description
I have two .conf drop-in files and expecting one to overwrite the other, following the behavior described in podman-systemd.unit.5
(Drop-in files with the same name further down the hierarchy override those further up).
foo-bar-.container.d/10-override.conf
should overwrite container.d/10-override.conf
. But if both of these directories do not share the same parent directory then the behavior breaks.
I am aware that there is a precedence of directories for quadlet files, but this shouldn't impact .conf files that might have to be loaded from different places in the file system hierarchy.
Steps to reproduce the issue
- create
~/.config/containers/systemd/container.d/10-override.conf
with this content:
[Service]
Environment=test=wrong
- create
~/.config/containers/systemd/tools/foo-bar-.container.d/10-override.conf
with this content:
[Service]
Environment=test=right
- create a minimal unit in
~/.config/containers/systemd/tools/foo-bar-baz.container
[Container]
Image=docker.io/traefik/whoami:latest
- run
quadlet -user -dryrun
- check stderr for the name of the loaded drop-in file
- check stdout for the environment key finally taken into account
Describe the results you received
quadlet-generator[3975]: Loading source unit file ~/.config/containers/systemd/tools/foo-bar-baz.container
quadlet-generator[3975]: Loading source drop-in file ~/.config/containers/systemd/container.d/10-override.conf
---foo-bar-baz.service---
[X-Container]
Image=docker.io/traefik/whoami:latest
[Service]
Environment=test=wrong
Describe the results you expected
quadlet-generator[4101]: Loading source unit file ~/.config/containers/systemd/tools/foo-bar-baz.container
quadlet-generator[4101]: Loading source drop-in file ~/.config/containers/systemd/tools/foo-bar-.container.d/10-override.conf
---foo-bar-baz.service---
[X-Container]
Image=docker.io/traefik/whoami:latest
[Service]
Environment=test=right
podman info output
Client: Podman Engine
Version: 5.5.2
API Version: 5.5.2
Go Version: go1.24.4
Built: Thu Jan 1 01:00:00 1970
OS/Arch: linux/amd64
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
No response
Additional information
Quick fix:
In file podman/cmd/quadlet/main.go
, in function loadUnitDropins()
, change the outer and inner loop, so as to first cycle through all unitDropinPaths
before cycling through sourecePaths
.
for _, dropinPath := range unitDropinPaths {
for _, sourcePath := range sourcePaths {
dropinDirs = append(dropinDirs, path.Join(sourcePath, dropinPath))
}
}