server: fix ctr filter by truncated id

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

View file

@ -36,7 +36,11 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque
// Filter using container id and pod id first.
if filter != nil {
if filter.Id != nil {
c := s.state.containers.Get(*filter.Id)
id, err := s.ctrIDIndex.Get(*filter.Id)
if err != nil {
return nil, err
}
c := s.state.containers.Get(id)
if c != nil {
if filter.PodSandboxId != nil {
if c.Sandbox() == *filter.PodSandboxId {

View file

@ -187,6 +187,11 @@ function teardown() {
[ "$status" -eq 0 ]
[[ "$output" != "" ]]
[[ "$output" =~ "$ctr1_id" ]]
run ocic ctr list --id "${ctr1_id:0:4}" --quiet
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" != "" ]]
[[ "$output" =~ "$ctr1_id" ]]
run ocic ctr list --id "$ctr2_id" --pod "$pod2_id" --quiet
echo "$output"
[ "$status" -eq 0 ]