containers / common

Location for shared common files in github.com/containers repos.
Apache License 2.0
184 stars 193 forks source link

podman command never returns when hook configured with either prestart with this corresponding hook handler #2106

Closed itsCheithanya closed 2 months ago

itsCheithanya commented 2 months ago

image

podman command never returns when hook configured with either prestart/poststart for this corresponding hook handler /usr/local/bin/podman-hook-prestart

#!/bin/bash

input="-"
CONTAINER_CONFIG=$(cat "$input")
CONTAINER_ID=$(echo "$CONTAINER_CONFIG" | jq -r ".id")

# Get the name of the container using podman inspect
CONTAINER_NAME=$(sudo podman inspect "$CONTAINER_ID" | jq -r '.[0].Name')

# Update the container state with the container name annotation
UPDATED_CONFIG=$(echo "$CONTAINER_CONFIG" | jq ".annotations += {\"container_name\": \"${CONTAINER_NAME}\"}")

echo "$UPDATED_CONFIG"

image

Luap99 commented 2 months ago

Podman holds a lock for the critical container sections such as executing hooks so if you call another podman command from within that tries to take the same lock it will deadlock.