Remove containers from state on pod remove
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
8fe5343e8b
commit
50bea08c50
1 changed files with 8 additions and 2 deletions
|
@ -290,7 +290,8 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
||||||
return nil, fmt.Errorf("specified sandbox not found: %s", sandboxID)
|
return nil, fmt.Errorf("specified sandbox not found: %s", sandboxID)
|
||||||
}
|
}
|
||||||
|
|
||||||
podInfraContainer := sb.name + "-infra"
|
podInfraContainerName := sb.name + "-infra"
|
||||||
|
var podInfraContainer *oci.Container
|
||||||
|
|
||||||
// Delete all the containers in the sandbox
|
// Delete all the containers in the sandbox
|
||||||
for _, c := range sb.containers.List() {
|
for _, c := range sb.containers.List() {
|
||||||
|
@ -309,13 +310,17 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
||||||
return nil, fmt.Errorf("failed to delete container %s in sandbox %s: %v", c.Name(), sandboxID, err)
|
return nil, fmt.Errorf("failed to delete container %s in sandbox %s: %v", c.Name(), sandboxID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if podInfraContainer == c.Name() {
|
if podInfraContainerName == c.Name() {
|
||||||
|
podInfraContainer = c
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
containerDir := filepath.Join(s.runtime.ContainerDir(), c.Name())
|
containerDir := filepath.Join(s.runtime.ContainerDir(), c.Name())
|
||||||
if err := os.RemoveAll(containerDir); err != nil {
|
if err := os.RemoveAll(containerDir); err != nil {
|
||||||
return nil, fmt.Errorf("failed to remove container %s directory: %v", c.Name(), err)
|
return nil, fmt.Errorf("failed to remove container %s directory: %v", c.Name(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.removeContainer(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the files related to the sandbox
|
// Remove the files related to the sandbox
|
||||||
|
@ -323,6 +328,7 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
||||||
if err := os.RemoveAll(podSandboxDir); err != nil {
|
if err := os.RemoveAll(podSandboxDir); err != nil {
|
||||||
return nil, fmt.Errorf("failed to remove sandbox %s directory: %v", sandboxID, err)
|
return nil, fmt.Errorf("failed to remove sandbox %s directory: %v", sandboxID, err)
|
||||||
}
|
}
|
||||||
|
s.removeContainer(podInfraContainer)
|
||||||
|
|
||||||
s.releasePodName(sb.name)
|
s.releasePodName(sb.name)
|
||||||
s.removeSandbox(sandboxID)
|
s.removeSandbox(sandboxID)
|
||||||
|
|
Loading…
Reference in a new issue