Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat API image remove events now have 'delete' status #15487

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y'know, as long as we're re-pushing, why not add a comment here for future maintainers, explaining exactly what the problem is?

e.Status = "delete"
e.Action = "delete"
}
if !utils.IsLibpodRequest(r) && e.Status == "died" {
e.Status = "die"
e.Action = "die"
Expand Down
19 changes: 19 additions & 0 deletions test/apiv2/10-images.at
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,23 @@ 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 There is a race around events being added to the journal
# This sleep seems to avoid the race.
# If it fails and begins to flake, investigate a retry loop.
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 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and fails when run against main.

'select(.status | contains("delete")).Action=delete'

# vim: filetype=sh