mirror of
https://github.com/containers/podman.git
synced 2025-05-30 07:04:03 +08:00
legacy events: also set exitCode
For Status = "die", Docker sets the exit code of the container to a field "exitCode". Podman uses "containerExitCode". Copy the value into "exitCode" as well, for compatibility. Signed-off-by: Leah Neukirchen <leah@vuxu.org>
This commit is contained in:
@ -92,6 +92,7 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
|
||||
if !utils.IsLibpodRequest(r) && e.Status == "died" {
|
||||
e.Status = "die"
|
||||
e.Action = "die"
|
||||
e.Actor.Attributes["exitCode"] = e.Actor.Attributes["containerExitCode"]
|
||||
}
|
||||
|
||||
if err := coder.Encode(e); err != nil {
|
||||
|
27
test/apiv2/27-containersEvents.at
Normal file
27
test/apiv2/27-containersEvents.at
Normal file
@ -0,0 +1,27 @@
|
||||
# -*- sh -*-
|
||||
#
|
||||
# test container-related events
|
||||
#
|
||||
|
||||
podman pull $IMAGE &>/dev/null
|
||||
|
||||
# Ensure clean slate
|
||||
podman rm -a -f &>/dev/null
|
||||
|
||||
START=$(date +%s)
|
||||
|
||||
podman run $IMAGE false || true
|
||||
|
||||
# libpod api
|
||||
t GET "libpod/events?stream=false&since=$START" 200 \
|
||||
'select(.status | contains("start")).Action=start' \
|
||||
'select(.status | contains("died")).Action=died' \
|
||||
'select(.status | contains("died")).Actor.Attributes.containerExitCode=1'
|
||||
|
||||
# compat api, uses status=die (#12643)
|
||||
t GET "events?stream=false&since=$START" 200 \
|
||||
'select(.status | contains("start")).Action=start' \
|
||||
'select(.status | contains("die")).Action=die' \
|
||||
'select(.status | contains("die")).Actor.Attributes.exitCode=1'
|
||||
|
||||
# vim: filetype=sh
|
Reference in New Issue
Block a user