server: fix pod filter by truncated id

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-12-06 12:12:52 +01:00
parent 15f23bc6ac
commit e7492ca12f
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
2 changed files with 11 additions and 1 deletions

View file

@ -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 {

View file

@ -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 ]