From e7492ca12fbe874759ab910b0e67dd53471de58a Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Tue, 6 Dec 2016 12:12:52 +0100 Subject: [PATCH] server: fix pod filter by truncated id Signed-off-by: Antonio Murdaca --- server/sandbox_list.go | 6 +++++- test/pod.bats | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/server/sandbox_list.go b/server/sandbox_list.go index a21d40be..3d8ae6a6 100644 --- a/server/sandbox_list.go +++ b/server/sandbox_list.go @@ -39,7 +39,11 @@ func (s *Server) ListPodSandbox(ctx context.Context, req *pb.ListPodSandboxReque // Filter by pod id first. if filter != nil { if filter.Id != nil { - sb := s.getSandbox(*filter.Id) + id, err := s.podIDIndex.Get(*filter.Id) + if err != nil { + return nil, err + } + sb := s.getSandbox(id) if sb == nil { podList = []*sandbox{} } else { diff --git a/test/pod.bats b/test/pod.bats index e33db963..56cfcc22 100644 --- a/test/pod.bats +++ b/test/pod.bats @@ -112,6 +112,12 @@ function teardown() { [ "$status" -eq 0 ] [[ "$output" != "" ]] [[ "$output" =~ "$pod1_id" ]] + # filter by truncated id should work as well + run ocic pod list --id "${pod1_id:0:4}" + echo "$output" + [ "$status" -eq 0 ] + [[ "$output" != "" ]] + [[ "$output" =~ "$pod1_id" ]] run ocic pod list --id "$pod2_id" echo "$output" [ "$status" -eq 0 ]