Open supermeng opened 6 years ago
func (s *Supervisor) Start() error { logrus.WithFields(logrus.Fields{ "stateDir": s.stateDir, "runtime": s.runtime, "runtimeArgs": s.runtimeArgs, "memory": s.machine.Memory, "cpus": s.machine.Cpus, }).Debug("containerd: supervisor running") go func() { for i := range s.tasks { s.handleTask(i) } }() return nil }
func (s Supervisor) handleTask(i Task) { var err error switch t := i.(type) { case AddProcessTask: err = s.addProcess(t) case CreateCheckpointTask: err = s.createCheckpoint(t) case DeleteCheckpointTask: err = s.deleteCheckpoint(t) case StartTask: err = s.start(t) case DeleteTask: err = s.delete(t) case ExitTask: err = s.exit(t) case GetContainersTask: err = s.getContainers(t) case SignalTask: err = s.signal(t) case StatsTask: err = s.stats(t) case UpdateTask: err = s.updateContainer(t) case UpdateProcessTask: err = s.updateProcess(t) case *OOMTask: err = s.oom(t) default: err = ErrUnknownTask } if err != errDeferredResponse { i.ErrorCh() <- err close(i.ErrorCh()) } }
in containerd 0.2.x, docker exec new process need 70ms as issue https://github.com/moby/moby/issues/33933 said, and containerd supervisord exec task with single goroutine, so many context cancelled when too many containers in a node need healthcheck. cost 70*n ms.