File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -406,13 +406,14 @@ func (s *Server) waitForSync(ct *api.Container) error {
406406
407407 code , err := s .c .WaitContainer (ctx , ct .ID )
408408 if err != nil {
409- if errors .Is (ctx .Err (), context .DeadlineExceeded ) {
410- // timeout, we should stop the container
411- ctx , cancel := context .WithTimeout (s .context (), time .Second * 30 )
412- _ = s .c .StopContainer (ctx , ct .ID )
413- cancel ()
409+ if ! errors .Is (ctx .Err (), context .DeadlineExceeded ) {
410+ return err
411+ } else {
412+ // When the error is timeout, we expect that
413+ // container will be stopped and removed in onPostSync() goroutine
414+ // Here we set a special exit code to indicate that the container is timeout in meta.
415+ code = - 2
414416 }
415- return err
416417 }
417418
418419 name , ok := ct .Labels ["org.ustcmirror.name" ]
@@ -430,5 +431,7 @@ func (s *Server) waitForSync(ct *api.Container) error {
430431 Dir : dir ,
431432 ExitCode : code ,
432433 }
433- return nil
434+ // returns context.DeadlineExceeded when timeout
435+ // or nil when it succeeded
436+ return err
434437}
You can’t perform that action at this time.
0 commit comments