Remove container directories on pod sandbox removal
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
2eafad8a36
commit
219fb703dc
1 changed files with 9 additions and 0 deletions
|
@ -194,11 +194,20 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
|||
return nil, fmt.Errorf("specified sandbox not found: %s", *sbName)
|
||||
}
|
||||
|
||||
podInfraContainer := *sbName + "-infra"
|
||||
|
||||
// Delete all the containers in the sandbox
|
||||
for _, c := range sb.containers {
|
||||
if err := s.runtime.DeleteContainer(c); err != nil {
|
||||
return nil, fmt.Errorf("failed to delete container %s in sandbox %s: %v", c.Name(), *sbName, err)
|
||||
}
|
||||
if podInfraContainer == c.Name() {
|
||||
continue
|
||||
}
|
||||
containerDir := filepath.Join(s.runtime.ContainerDir(), c.Name())
|
||||
if err := os.RemoveAll(containerDir); err != nil {
|
||||
return nil, fmt.Errorf("failed to remove container %s directory: %v", c.Name(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the files related to the sandbox
|
||||
|
|
Loading…
Reference in a new issue