containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.27k stars 2.37k forks source link

Quadlets and .pod templates #24028

Open thmo opened 1 week ago

thmo commented 1 week ago

Issue Description

Referenzing a templated .pod quadlet from a templated .container quadlet doesn't seem to be possible.

Steps to reproduce the issue

Create these quadlet files:

# foo@.pod
[Pod]

[Install]
WantedBy=multi-user.target
# foo_app@.container
[Container]
Pod=foo@%i.pod
Image=alpine
Exec=sleep %i

[Service]
Restart=always

[Install]
WantedBy=multi-user.target

And run /usr/lib/systemd/system-generators/podman-system-generator --dryrun.

Describe the results you received

...
quadlet-generator[1668438]: converting "foo_app@.container": quadlet pod unit foo@%i.pod does not exist
...

Describe the results you expected

A service file for the container, referenzing the pod, using %i, as the instance name might be unknown.

podman info output

host:
  arch: amd64
  buildahVersion: 1.37.2
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - hugetlb
  - pids
  - rdma
  - misc
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.12-1.el9.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.12, commit: 7ba5bd6c81ff2c10e07aee8c4281d12a2878fa12'
  cpuUtilization:
    idlePercent: 98.35
    systemPercent: 0.64
    userPercent: 1.02
  cpus: 6
  databaseBackend: boltdb
  distribution:
    distribution: rocky
    version: "9.4"
  eventLogger: journald
  freeLocks: 1948
  hostname: REDACTED
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 5.14.0-427.35.1.el9_4.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 914542592
  memTotal: 16498958336
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.12.1-1.el9.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.12.1
    package: netavark-1.12.2-1.el9.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.12.2
  ociRuntime:
    name: crun
    package: crun-1.16.1-1.el9.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.16.1
      commit: afa829ca0122bd5e1d67f1f38e6cc348027e3c32
      rundir: /run/user/0/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20231204.gb86afe3-1.el9.x86_64
    version: |
      pasta 0^20231204.gb86afe3-1.el9.x86_64
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/podman/podman.sock
  rootlessNetworkCmd: pasta
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.3.1-1.el9.x86_64
    version: |-
      slirp4netns version 1.3.1
      commit: e5e368c4f5db6ae75c2fce786e31eef9da6bf236
      libslirp: 4.4.0
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.2
  swapFree: 0
  swapTotal: 0
  uptime: 172h 46m 45.00s (Approximately 7.17 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.access.redhat.com
  - registry.redhat.io
  - docker.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 39
    paused: 0
    running: 38
    stopped: 1
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 419537911808
  graphRootUsed: 36848578560
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "true"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 41
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 5.2.2
  Built: 1724331499
  BuiltTime: Thu Aug 22 14:58:19 2024
  GitCommit: ""
  GoVersion: go1.22.5 (Red Hat 1.22.5-2.el9)
  Os: linux
  OsArch: linux/amd64
  Version: 5.2.2


### Podman in a container

No

### Privileged Or Rootless

None

### Upstream Latest Release

Yes

### Additional environment details

_No response_

### Additional information

_No response_
thmo commented 6 days ago

Actually it's even worse. If one tries to work around the limitation of this bug, creation of the instantiated pod fails:

foo@bar-pod[1703114]: Error: running pod create option: names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*: invalid argument
systemd[1]: foo@bar-pod.service: Control process exited, code=exited, status=125/n/a
thmo commented 6 days ago

Maybe related to #22874

ygalblum commented 6 days ago

Hi Thomas,

Yes Quadlet has an issue when referencing templated Quadlet files.

You can see my comment here: https://github.com/containers/podman/discussions/17744#discussioncomment-9856920, though it refers to linked .build files, the same applies for .pod files.