Skip to content

Commit

Permalink
Compat API image remove events now have 'delete' status
Browse files Browse the repository at this point in the history
Change only the compat API, so we don't force a breaking change
on Libpod API users.

Partial fix for #15485

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
  • Loading branch information
mheon committed Aug 25, 2022
1 parent f98215c commit ba4042a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/api/handlers/compat/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ func GetEvents(w http.ResponseWriter, r *http.Request) {
}

e := entities.ConvertToEntitiesEvent(*evt)
// Some events differ between Libpod and Docker endpoints.
// Handle these differences for Docker-compat.
if !utils.IsLibpodRequest(r) && e.Type == "image" && e.Status == "remove" {
e.Status = "delete"
e.Action = "delete"
}
if !utils.IsLibpodRequest(r) && e.Status == "died" {
e.Status = "die"
e.Action = "die"
Expand Down
17 changes: 17 additions & 0 deletions test/apiv2/10-images.at
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,21 @@ fi

cleanBuildTest

# compat API vs libpod API event differences:
# on image removal, libpod produces 'remove' events.
# compat produces 'delete' events.
podman image build -t test:test -<<EOF
from $IMAGE
EOF

START=$(date +%s)

t DELETE libpod/images/test:test 200
# HACK HACK HACK detect race
sleep 1
t GET "libpod/events?stream=false&since=$START" 200 \
'select(.status | contains("remove")).Action=remove'
t GET "events?stream=false&since=$START" 200 \
'select(.status | contains("delete")).Action=delete'

# vim: filetype=sh

0 comments on commit ba4042a

Please sign in to comment.