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

[17.03.3] containerd cherry-picks #2

Merged
merged 2 commits into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}