Merge pull request #433 from sameo/topic/sandboxrun-fixes

server: Fix RunPodSandbox error path
This commit is contained in:
Antonio Murdaca 2017-04-06 18:46:24 +02:00 committed by GitHub
commit 0854c081ec

View file

@ -282,19 +282,20 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
hostname: hostname,
}
s.addSandbox(sb)
if err = s.podIDIndex.Add(id); err != nil {
return nil, err
}
defer func() {
if err != nil {
s.removeSandbox(id)
if err2 := s.podIDIndex.Delete(id); err2 != nil {
logrus.Warnf("couldn't delete pod id %s from idIndex", id)
}
}
}()
s.addSandbox(sb)
if err = s.podIDIndex.Add(id); err != nil {
return nil, err
}
for k, v := range annotations {
g.AddAnnotation(k, v)
}