Clear index entries when removing pods or ctrs
When removing a pod sandbox or container, remove the ID of the item from the corresponding ID index, so that we can correctly determine if it was us or another actor that cleaned them up. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
parent
50a3958e5a
commit
d6225894af
1 changed files with 9 additions and 0 deletions
|
@ -60,6 +60,9 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
||||||
|
|
||||||
s.releaseContainerName(c.Name())
|
s.releaseContainerName(c.Name())
|
||||||
s.removeContainer(c)
|
s.removeContainer(c)
|
||||||
|
if err := s.ctrIDIndex.Delete(c.ID()); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to delete container %s in pod sandbox %s from index: %v", c.Name(), sb.id, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := label.UnreserveLabel(sb.processLabel); err != nil {
|
if err := label.UnreserveLabel(sb.processLabel); err != nil {
|
||||||
|
@ -85,9 +88,15 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
||||||
s.releaseContainerName(podInfraContainer.Name())
|
s.releaseContainerName(podInfraContainer.Name())
|
||||||
s.removeContainer(podInfraContainer)
|
s.removeContainer(podInfraContainer)
|
||||||
sb.infraContainer = nil
|
sb.infraContainer = nil
|
||||||
|
if err := s.ctrIDIndex.Delete(podInfraContainer.ID()); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to delete infra container %s in pod sandbox %s from index: %v", podInfraContainer.ID(), sb.id, err)
|
||||||
|
}
|
||||||
|
|
||||||
s.releasePodName(sb.name)
|
s.releasePodName(sb.name)
|
||||||
s.removeSandbox(sb.id)
|
s.removeSandbox(sb.id)
|
||||||
|
if err := s.podIDIndex.Delete(sb.id); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to pod sandbox %s from index: %v", sb.id, err)
|
||||||
|
}
|
||||||
|
|
||||||
resp := &pb.RemovePodSandboxResponse{}
|
resp := &pb.RemovePodSandboxResponse{}
|
||||||
logrus.Debugf("RemovePodSandboxResponse %+v", resp)
|
logrus.Debugf("RemovePodSandboxResponse %+v", resp)
|
||||||
|
|
Loading…
Reference in a new issue