+
Skip to content

Quadlets: Wrong .conf drop-in overwrites, if located in different subdirectories #26555

Open
@eulores

Description

@eulores

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

  1. create ~/.config/containers/systemd/container.d/10-override.conf with this content:
[Service]
Environment=test=wrong
  1. create ~/.config/containers/systemd/tools/foo-bar-.container.d/10-override.conf with this content:
[Service]
Environment=test=right
  1. create a minimal unit in ~/.config/containers/systemd/tools/foo-bar-baz.container
[Container]
Image=docker.io/traefik/whoami:latest
  1. run quadlet -user -dryrun
  2. check stderr for the name of the loaded drop-in file
  3. 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))
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.quadlettriagedIssue has been triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载