podman icon indicating copy to clipboard operation
podman copied to clipboard

`--sdnotify=healthy` holds pod lock while waiting for healthy; other containers in the pod can't be created and `pod inspect` hangs

Open ericzinnikas opened this issue 1 month ago • 4 comments

Issue Description

When a Quadlet pod member container starts with Notify=healthy, its podman start/run holds the pod lock until the container is healthy. This results in podman run/start --pod <same pod> and podman pod inspect blocking (stop and ps would too).

There is no timeout for the healthy wait (it ends on a healthy state or container exit). If the health check depends on another container in the same pod (i.e. a Notify=healthy health check sidecar that probes a primary app container), everything hangs until systemd TimeoutStartSec kills both.

It seems that this happens because (looking at 5.8.9):

Steps to reproduce the issue

This minimal repro creates a pod and starts a container (which will be waiting on a healthcheck). It uses --health-interval=disable so we can manually trigger the healthcheck (vs. a systemd timer).

podman pod create --name p1
podman create --pod p1 --name a1 --sdnotify=healthy --health-cmd=/bin/true --health-retries=1 --health-interval=disable docker.io/library/alpine sleep infinity
podman start a1 &  # waiting for a1 to be healthy; health check doesn't run until manually triggered below
sleep 2
time timeout 20 podman run -d --pod p1 --name b1 docker.io/library/alpine sleep infinity; echo "exit: $?"
time timeout 10 podman pod inspect p1 > /dev/null; echo "exit: $?"
podman healthcheck run a1  # a1 is now healthy
wait  # the `podman start a1` above returns
time podman run -d --pod p1 --name b2 docker.io/library/alpine sleep infinity; echo "exit: $?"
podman pod rm -f -t 0 p1

Describe the results you received

  • Our run --pod for container b1 times out after 20s with exit: 124; pod inspect also times out after 10s
  • After the health check completes (healthcheck run a1), run --pod for b2 returns immediately
  • Reproduced when running the above as root on a stock Fedora 44 (Incus system container) with podman-5.8.9

Describe the results you expected

  • Using Notify=healthy should only affect waiting for the container's health check to pass before sending its READY notification to systemd
  • It should be possible to create and start other containers in the same pod during that waiting period

podman info output

host:
  arch: amd64
  buildahVersion: 1.43.5
  cgroupControllers:
  - memory
  - hugetlb
  - pids
  - misc
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.2.1-2.fc44.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.2.1, commit: '
  cpuUtilization:
    idlePercent: 99.07
    systemPercent: 0.23
    userPercent: 0.69
  cpus: 2
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: container
    version: "44"
  eventLogger: journald
  freeLocks: 2048
  hostname: podman-scratch
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.17.0-35-generic
  linkmode: dynamic
  logDriver: journald
  memFree: 4172955648
  memTotal: 4294967296
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    defaultNetwork: podman
    dns:
      package: aardvark-dns-1.17.1-1.fc44.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.17.1
    package: netavark-1.17.2-1.fc44.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.17.2
  ociRuntime:
    name: crun
    package: crun-1.28-1.fc44.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.28
      commit: 54f16ffbefcd022bf032af768b5c5ce075c18bfc
      rundir: /run/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +JSON_C
  os: linux
  pasta:
    executable: /usr/sbin/pasta
    package: passt-0^20261002.gcba3570-1.fc44.x86_64
    version: |
      pasta 0^20261002.gcba3570-1.fc44.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: ""
    package: ""
    version: ""
  swapFree: 0
  swapTotal: 0
  uptime: 0h 1m 49.00s
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
store:
  configFile: /usr/share/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.additionalImageStores:
    - /usr/lib/containers/storage
    overlay.imagestore: /usr/lib/containers/storage
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 7406991441920
  graphRootUsed: 463077376
  graphStatus:
    Backing Filesystem: zfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 1
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 5.8.9
  BuildOrigin: Fedora Project
  Built: 1791763200
  BuiltTime: Mon Oct 12 00:00:00 2026
  GitCommit: 40030f4073bd4e1bf4f2fd9df2f6952b4d9d350a
  GoVersion: go1.26.9-X:nodwarf5
  Os: linux
  OsArch: linux/amd64
  Version: 5.8.9

---

host:
  arch: amd64
  buildahVersion: 1.46.0
  cdiSpecDirs:
  - /etc/cdi
  - /var/run/cdi
  cgroupControllers:
  - memory
  - hugetlb
  - pids
  - misc
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.2.1-2.fc44.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.2.1, commit: '
  cpuUtilization:
    idlePercent: 99.07
    systemPercent: 0.23
    userPercent: 0.69
  cpus: 2
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: container
    version: "44"
  eventLogger: journald
  freeLocks: 2048
  hostname: podman-scratch
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.17.0-35-generic
  linkmode: dynamic
  logDriver: journald
  memAvailable: 4251981824
  memFree: 4167274496
  memTotal: 4294967296
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    defaultNetwork: podman
    dns:
      package: aardvark-dns-2.1.0-1.20261022135346563456.main.32.g730249b.fc44.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 2.1.0
    package: netavark-2.1.0-1.20261029194916628016.main.104.g00e0b33a.fc44.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 2.1.0
  ociRuntime:
    features: '{"ociVersionMin":"1.0.0","ociVersionMax":"1.1.0+dev","hooks":["prestart","createRuntime","createContainer","startContainer","poststart","poststop"],"mountOptions":["rw","rrw","ro","rro","rdirsync","rdiratime","rnodev","rnorelatime","nodiratime","rnodiratime","dirsync","rnosuid","ratime","diratime","rnoatime","strictatime","rstrictatime","noatime","rnostrictatime","rnomand","rprivate","nostrictatime","rnoexec","nodev","rmand","norelatime","mand","idmap","atime","nomand","rsuid","rbind","suid","bind","rslave","nosuid","defaults","rrelatime","rsync","remount","dest-nofollow","dev","rdev","private","noexec","src-nofollow","sync","relatime","async","rasync","tmpcopyup","shared","rshared","slave","rexec","unbindable","runbindable","exec","copy-symlink"],"linux":{"namespaces":["cgroup","ipc","mount","network","pid","user","uts"],"capabilities":["CAP_CHOWN","CAP_DAC_OVERRIDE","CAP_DAC_READ_SEARCH","CAP_FOWNER","CAP_FSETID","CAP_KILL","CAP_SETGID","CAP_SETUID","CAP_SETPCAP","CAP_LINUX_IMMUTABLE","CAP_NET_BIND_SERVICE","CAP_NET_BROADCAST","CAP_NET_ADMIN","CAP_NET_RAW","CAP_IPC_LOCK","CAP_IPC_OWNER","CAP_SYS_MODULE","CAP_SYS_RAWIO","CAP_SYS_CHROOT","CAP_SYS_PTRACE","CAP_SYS_PACCT","CAP_SYS_ADMIN","CAP_SYS_BOOT","CAP_SYS_NICE","CAP_SYS_RESOURCE","CAP_SYS_TIME","CAP_SYS_TTY_CONFIG","CAP_MKNOD","CAP_LEASE","CAP_AUDIT_WRITE","CAP_AUDIT_CONTROL","CAP_SETFCAP","CAP_MAC_OVERRIDE","CAP_MAC_ADMIN","CAP_SYSLOG","CAP_WAKE_ALARM","CAP_BLOCK_SUSPEND","CAP_AUDIT_READ","CAP_PERFMON","CAP_BPF","CAP_CHECKPOINT_RESTORE"],"cgroup":{"v1":true,"v2":true,"systemd":true,"systemdUser":true},"seccomp":{"enabled":true,"actions":["SCMP_ACT_ALLOW","SCMP_ACT_ERRNO","SCMP_ACT_KILL","SCMP_ACT_KILL_PROCESS","SCMP_ACT_KILL_THREAD","SCMP_ACT_LOG","SCMP_ACT_NOTIFY","SCMP_ACT_TRACE","SCMP_ACT_TRAP"],"operators":["SCMP_CMP_NE","SCMP_CMP_LT","SCMP_CMP_LE","SCMP_CMP_EQ","SCMP_CMP_GE","SCMP_CMP_GT","SCMP_CMP_MASKED_EQ"]},"apparmor":{"enabled":true},"selinux":{"enabled":true},"mountExtensions":{"idmap":{"enabled":true}},"intelRdt":{"enabled":true},"netDevices":{"enabled":true},"memoryPolicy":{"modes":["MPOL_DEFAULT","MPOL_PREFERRED","MPOL_BIND","MPOL_INTERLEAVE","MPOL_LOCAL","MPOL_PREFERRED_MANY","MPOL_WEIGHTED_INTERLEAVE"],"flags":["MPOL_F_NUMA_BALANCING","MPOL_F_RELATIVE_NODES","MPOL_F_STATIC_NODES"]}},"annotations":{"io.github.seccomp.libseccomp.version":"2.6.1","org.opencontainers.runc.checkpoint.enabled":"true","run.oci.crun.checkpoint.enabled":"true","run.oci.crun.commit":"54f16ffbefcd022bf032af768b5c5ce075c18bfc","run.oci.crun.version":"1.28","run.oci.crun.wasm":"true"},"potentiallyUnsafeConfigAnnotations":["module.wasm.image\/variant","io.kubernetes.cri.container-type","run.oci.","org.criu.","krun."]}'
    name: crun
    package: crun-1.28-1.fc44.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.28
      commit: 54f16ffbefcd022bf032af768b5c5ce075c18bfc
      rundir: /run/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +JSON_C
  os: linux
  pasta:
    executable: /usr/sbin/pasta
    package: passt-0^20261002.gcba3570-1.fc44.x86_64
    version: |
      pasta 0^20261002.gcba3570-1.fc44.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
  rootlessPortForwarder: rootlessport
  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
  swapFree: 0
  swapTotal: 0
  uptime: 0h 3m 14.00s
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
store:
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    additionalImageStores:
    - /usr/lib/containers/storage
    imagestore: /usr/lib/containers/storage
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 7406990393344
  graphRootUsed: 516816896
  graphStatus:
    Backing Filesystem: zfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 1
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 6.3.0-dev
  BuildOrigin: 'Copr: rhcontainerbot/podman-next'
  Built: 1793318400
  BuiltTime: Fri Oct 30 00:00:00 2026
  GitCommit: d727bf2fc6a9c4e4993c6b7562f9553309395bb7
  GoVersion: go1.26.10-X:nodwarf5
  Os: linux
  OsArch: linux/amd64
  Version: 6.3.0-dev

Podman in a container

Yes

Privileged Or Rootless

Privileged

Upstream Latest Release

Yes

Additional environment details

  • Repro'd on Fedora 44 Incus system container (unprivileged, security.nesting=true) on an Ubuntu parent
  • First encountered with 5.8.9 on Ubuntu 26.04

Additional information

Originally encountered this because I have a quadlet pod with a distroless app container and a health check sidecar container (with Notify=healthy) whose health check probes the main app container. No ordering was defined between the two container units.

Running podman auto-update on the sidecar restarted the pod and the two containers were stuck crash-looping for >30mins as they hit systemd's timeout (the sidecar happened to continually win the start-first race). I added After=app.service to the sidecar unit as a workaround to mitigate the issue.

ericzinnikas avatar Oct 31 '26 04:10 ericzinnikas

Hi... Thanks for the detailed write-up and the repro. I'd like to work on this if no one else is already on it. From reading the code path you linked, it looks like Container.Start holds pod.lock all the way through waitForHealthy, while only the container lock is released during the wait. Before I start, I wanted to check the direction with the maintainers: would you prefer releasing the pod lock before the health wait, or restructuring so the wait happens outside Container.Start entirely? I want to avoid introducing races with pod stop or concurrent starts. I'll try the repro locally in the meantime. Happy to wait for guidance before sending a PR.

souvik-biswas-dev avatar Oct 31 '26 10:10 souvik-biswas-dev

Releasing pod lock before the wait sounds reasonable and low impact

mheon avatar Nov 02 '26 14:11 mheon

@souvik-biswas-dev, I think you can start working. Before that, please read and follow our contribution guidelines and LLM policy.

Honny1 avatar Nov 02 '26 15:11 Honny1

Thanks @Honny1 and @mheon . I've read the contribution guidelines and LLM policy. I'll go with releasing the pod lock before the health wait as suggested and I'll be careful about races with pod stop and concurrent starts. I'll send a PR once I have it working and tested.

souvik-biswas-dev avatar Nov 02 '26 16:11 souvik-biswas-dev