Skip to content

Commit

Permalink
Merge pull request #12643 from leahneukirchen/events-compat
Browse files Browse the repository at this point in the history
legacy events: also set Action="die"
  • Loading branch information
openshift-merge-robot authored Jan 4, 2022
2 parents 47cf00e + 116a276 commit 9a35494
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/api/handlers/compat/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
e := entities.ConvertToEntitiesEvent(*evt)
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 {
Expand Down
27 changes: 27 additions & 0 deletions test/apiv2/27-containersEvents.at
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9a35494

Please sign in to comment.