mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add fail fast path when containerd fails on startup
Prevents looping of startup errors such as containerd not being found on the path. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
6ba1e91877
commit
ce0b0b72bc
1 changed files with 11 additions and 4 deletions
|
@ -43,7 +43,7 @@ type remote struct {
|
||||||
logger *logrus.Entry
|
logger *logrus.Entry
|
||||||
|
|
||||||
daemonWaitCh chan struct{}
|
daemonWaitCh chan struct{}
|
||||||
daemonStartCh chan struct{}
|
daemonStartCh chan error
|
||||||
daemonStopCh chan struct{}
|
daemonStopCh chan struct{}
|
||||||
|
|
||||||
rootDir string
|
rootDir string
|
||||||
|
@ -72,7 +72,7 @@ func Start(ctx context.Context, rootDir, stateDir string, opts ...DaemonOpt) (Da
|
||||||
pluginConfs: pluginConfigs{make(map[string]interface{})},
|
pluginConfs: pluginConfigs{make(map[string]interface{})},
|
||||||
daemonPid: -1,
|
daemonPid: -1,
|
||||||
logger: logrus.WithField("module", "libcontainerd"),
|
logger: logrus.WithField("module", "libcontainerd"),
|
||||||
daemonStartCh: make(chan struct{}),
|
daemonStartCh: make(chan error, 1),
|
||||||
daemonStopCh: make(chan struct{}),
|
daemonStopCh: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,10 @@ func Start(ctx context.Context, rootDir, stateDir string, opts ...DaemonOpt) (Da
|
||||||
select {
|
select {
|
||||||
case <-time.After(startupTimeout):
|
case <-time.After(startupTimeout):
|
||||||
return nil, errors.New("timeout waiting for containerd to start")
|
return nil, errors.New("timeout waiting for containerd to start")
|
||||||
case <-r.daemonStartCh:
|
case err := <-r.daemonStartCh:
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return r, nil
|
return r, nil
|
||||||
|
@ -263,7 +266,11 @@ func (r *remote) monitorDaemon(ctx context.Context) {
|
||||||
|
|
||||||
os.RemoveAll(r.GRPC.Address)
|
os.RemoveAll(r.GRPC.Address)
|
||||||
if err := r.startContainerd(); err != nil {
|
if err := r.startContainerd(); err != nil {
|
||||||
r.logger.WithError(err).Error("failed starting containerd")
|
if !started {
|
||||||
|
r.daemonStartCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
r.logger.WithError(err).Error("failed restarting containerd")
|
||||||
delay = time.After(50 * time.Millisecond)
|
delay = time.After(50 * time.Millisecond)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue