-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix: event --filter volume=vol-name should compare the event name with volume name #18619
fix: event --filter volume=vol-name should compare the event name with volume name #18619
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure but shouldn't it handle additional case for Name
, instead of replacing ID
with Name
diff --git a/libpod/events/filters.go b/libpod/events/filters.go
index 9057c9b79..5ed09b461 100644
--- a/libpod/events/filters.go
+++ b/libpod/events/filters.go
@@ -52,6 +52,9 @@ func generateEventFilter(filter, filterValue string) (func(e *Event) bool, error
if e.Type != Volume {
return false
}
+ if e.Name == filterValue {
+ return true
+ }
return strings.HasPrefix(e.ID, filterValue)
}, nil
case "TYPE":
Again I have not tried above patch, just a hunch.
I'm not sure what's the best way to fix this, and I'm really uncomfortable with the @test "events - volume events" {
local vname=v$(random_string 10)
run_podman volume create $vname
run_podman volume rm $vname
run_podman events --since=1m --stream=false --filter volume=$vname
notrunc_results="$output"
assert "${lines[0]}" =~ ".* volume create $vname"
assert "${lines[1]}" =~ ".* volume remove $vname"
# Prefix test
run_podman events --since=1m --stream=false --filter volume=${vname:0:5}
assert "$output" = "$notrunc_results"
} |
@flouthoc The ID is not being set in the code for volume events so it is always blank. In the |
@edsantiago @flouthoc The prefix check is being used in all other cases but with IDs. I don't see an ID field in the Thanks for the feedback, I'll add some tests. |
If two volumes are created with name
Wouldn't filter My idea with the patch suggested here #18619 (review) was if user specifies a But again I have not played with filter and the part of code being discussed here enough so I could be missing bits. |
Ignore my previous comment it seems diff --git a/libpod/events/filters.go b/libpod/events/filters.go
index 9057c9b79..4a836d817 100644
--- a/libpod/events/filters.go
+++ b/libpod/events/filters.go
@@ -52,7 +52,10 @@ func generateEventFilter(filter, filterValue string) (func(e *Event) bool, error
if e.Type != Volume {
return false
}
- return strings.HasPrefix(e.ID, filterValue)
+ if e.Name == filterValue {
+ return true
+ }
+ return false
}, nil
case "TYPE":
return func(e *Event) bool { |
@flouthoc I have changed it to |
LGTM other than adding tests as suggested by @edsantiago |
e2ac946
to
7c486c5
Compare
test/system/090-events.bats
Outdated
@@ -225,6 +225,17 @@ EOF | |||
is "${lines[-1]}" "{\"ID\":\"$ctrID\",\"Image\":\"$IMAGE\",\"Name\":\".*\",\"Status\":\"remove\",\"Time\":\".*\",\"Type\":\"container\",\"Attributes\":{.*}}" | |||
} | |||
|
|||
@test "events - volume events" { | |||
local vname=v$(random_string 10) | |||
run_podman volume create $vname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also record the id here id=$(output)
and filter it as well.
Ah, OK. It looks like name and ID are the same. How does Docker behave when filtering for name or ID? @vyasgun can you squash the two commits into one in the next push? |
@vrothberg docker is doing a prefix match when filtering for "volume=volume-name".
In Podman, the ID is not being set for volume events since the volume object does not have an ID. Should it be set to the volume name? Or is it better to leave it blank? |
We can leave it blank but we need to be compatible with Docker. So I think we need to keep the prefix check but compare with |
7c486c5
to
a5902ba
Compare
…ame with volume name Fixes: containers#18618 Signed-off-by: Gunjan Vyas <[email protected]>
a5902ba
to
5f29c7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vrothberg, vyasgun The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes: #18618
Does this PR introduce a user-facing change?
Yes