Commit 683c63fe authored by Mrunal Patel's avatar Mrunal Patel

restore: Cleanup orphaned exit files leaked before

This should clean up the exit files that we leaked
before.
Signed-off-by: Mrunal Patel's avatarMrunal Patel <[email protected]>
parent 4477b9db
......@@ -221,6 +221,37 @@ func (s *Server) restore() {
}
sb.AddIP(ip)
}
// Clean up orphaned exit files
var exitIDs []string
exitDir := s.Config().RuntimeConfig.ContainerExitsDir
err = filepath.Walk(exitDir, func(path string, info os.FileInfo, err error) error {
exitFileName := filepath.Base(path)
if path != exitDir {
exitIDs = append(exitIDs, exitFileName)
}
return nil
})
if err != nil {
logrus.Warnf("Failed to walk exit dir %v: %v", exitDir, err)
}
for _, exitID := range exitIDs {
logrus.Warnf("Checking exit file: %v", exitID)
ctr := s.GetContainer(exitID)
if ctr != nil {
continue
} else {
sb := s.GetSandbox(exitID)
if sb != nil {
continue
}
}
logrus.Warnf("Removing exit file: %v", exitID)
if err := os.Remove(filepath.Join(exitDir, exitID)); err != nil && !os.IsNotExist(err) {
logrus.Warnf("Failed to remove container exit file during restore cleanup %s: %v", exitID, err)
}
}
}
// cleanupSandboxesOnShutdown Remove all running Sandboxes on system shutdown
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment