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

events: support "die" filter #16912

Merged
merged 1 commit into from
Dec 22, 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
3 changes: 2 additions & 1 deletion docs/source/markdown/podman-events.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The *container* event type will report the follow statuses:
* commit
* connect
* create
* died
* disconnect
* exec
* exec_died
Expand Down Expand Up @@ -91,7 +92,7 @@ filters are supported:
* volume=name_or_id
* type=event_type (described above)

In the case where an ID is used, the ID may be in its full or shortened form.
In the case where an ID is used, the ID may be in its full or shortened form. The "die" event is mapped to "died" for Docker compatibility.

#### **--format**

Expand Down
3 changes: 3 additions & 0 deletions libpod/events/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ func generateEventFilter(filter, filterValue string) (func(e *Event) bool, error
return strings.HasPrefix(e.ID, filterValue)
}, nil
case "EVENT", "STATUS":
if filterValue == "die" { // Docker compat
filterValue = "died"
}
return func(e *Event) bool {
return string(e.Status) == filterValue
}, nil
Expand Down
12 changes: 12 additions & 0 deletions test/system/090-events.bats
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,15 @@ EOF
_events_container_create_inspect_data journald
_events_container_create_inspect_data file
}

@test "events - docker compat" {
local cname=c$(random_string 15)
t0=$(date --iso-8601=seconds)
run_podman run --name=$cname --rm $IMAGE true
run_podman events \
--since="$t0" \
--filter=status=$cname \
--filter=status=die \
--stream=false
is "${lines[0]}" ".* container died .* (image=$IMAGE, name=$cname, .*)"
}