From edba913f678efab2d65a9bf64ad6abb499b50d4d Mon Sep 17 00:00:00 2001
From: Mrunal Patel <mrunalp@gmail.com>
Date: Wed, 5 Oct 2016 11:31:41 -0700
Subject: [PATCH] Track container IDs in index

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
---
 server/container.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/server/container.go b/server/container.go
index 48ad9363..5833d4cc 100644
--- a/server/container.go
+++ b/server/container.go
@@ -99,6 +99,10 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
 
 	s.addContainer(container)
 
+	if err := s.ctrIDIndex.Add(containerID); err != nil {
+		return nil, err
+	}
+
 	return &pb.CreateContainerResponse{
 		ContainerId: &containerID,
 	}, nil
@@ -397,6 +401,10 @@ func (s *Server) RemoveContainer(ctx context.Context, req *pb.RemoveContainerReq
 	s.releaseContainerName(c.Name())
 	s.removeContainer(c)
 
+	if err := s.ctrIDIndex.Delete(c.ID()); err != nil {
+		return nil, err
+	}
+
 	return &pb.RemoveContainerResponse{}, nil
 }