Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2 from mlaventure/fix-panic
Browse files Browse the repository at this point in the history
[17.03.3] containerd cherry-picks
  • Loading branch information
mlaventure authored Jun 5, 2017
2 parents 4ab9917 + 6e5b935 commit 6c46389
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion supervisor/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ func (s *Supervisor) delete(t *DeleteTask) error {
t.Process.Wait()
}
if !t.NoEvent {
execMap := s.getDeleteExecSyncMap(t.ID)
execMap := s.getExecSyncMap(t.ID)
go func() {
// Wait for all exec processe events to be sent (we seem
// to sometimes receive them after the init event)
for _, ch := range execMap {
<-ch
}
s.deleteExecSyncMap(t.ID)
s.notifySubscribers(Event{
Type: StateExit,
Timestamp: time.Now(),
Expand Down
18 changes: 12 additions & 6 deletions supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,10 @@ func (s *Supervisor) restore() error {
continue
}
processes, err := container.Processes()
if err != nil {
return err
if err != nil || len(processes) == 0 {
logrus.WithFields(logrus.Fields{"error": err, "id": id}).Warnf("containerd: container has no process running,removing state directory.")
os.RemoveAll(filepath.Join(s.stateDir, id))
continue
}

ContainersCounter.Inc(1)
Expand Down Expand Up @@ -437,10 +439,14 @@ func (s *Supervisor) getExecSyncChannel(containerID, pid string) chan struct{} {
return ch
}

func (s *Supervisor) getDeleteExecSyncMap(containerID string) map[string]chan struct{} {
func (s *Supervisor) getExecSyncMap(containerID string) map[string]chan struct{} {
s.containerExecSyncLock.Lock()
chs := s.containerExecSync[containerID]
defer s.containerExecSyncLock.Unlock()
return s.containerExecSync[containerID]
}

func (s *Supervisor) deleteExecSyncMap(containerID string) {
s.containerExecSyncLock.Lock()
defer s.containerExecSyncLock.Unlock()
delete(s.containerExecSync, containerID)
s.containerExecSyncLock.Unlock()
return chs
}

0 comments on commit 6c46389

Please sign in to comment.