File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,37 @@ func (s *Server) restore() {
221221 }
222222 sb .AddIP (ip )
223223 }
224+
225+ // Clean up orphaned exit files
226+ var exitIDs []string
227+
228+ exitDir := s .Config ().RuntimeConfig .ContainerExitsDir
229+ err = filepath .Walk (exitDir , func (path string , info os.FileInfo , err error ) error {
230+ exitFileName := filepath .Base (path )
231+ if path != exitDir {
232+ exitIDs = append (exitIDs , exitFileName )
233+ }
234+ return nil
235+ })
236+ if err != nil {
237+ logrus .Warnf ("Failed to walk exit dir %v: %v" , exitDir , err )
238+ }
239+ for _ , exitID := range exitIDs {
240+ logrus .Warnf ("Checking exit file: %v" , exitID )
241+ ctr := s .GetContainer (exitID )
242+ if ctr != nil {
243+ continue
244+ } else {
245+ sb := s .GetSandbox (exitID )
246+ if sb != nil {
247+ continue
248+ }
249+ }
250+ logrus .Warnf ("Removing exit file: %v" , exitID )
251+ if err := os .Remove (filepath .Join (exitDir , exitID )); err != nil && ! os .IsNotExist (err ) {
252+ logrus .Warnf ("Failed to remove container exit file during restore cleanup %s: %v" , exitID , err )
253+ }
254+ }
224255}
225256
226257// cleanupSandboxesOnShutdown Remove all running Sandboxes on system shutdown
You can’t perform that action at this time.
0 commit comments