@@ -43,7 +43,7 @@ type remote struct {
4343 logger * logrus.Entry
4444
4545 daemonWaitCh chan struct {}
46- daemonStartCh chan struct {}
46+ daemonStartCh chan error
4747 daemonStopCh chan struct {}
4848
4949 rootDir string
@@ -72,7 +72,7 @@ func Start(ctx context.Context, rootDir, stateDir string, opts ...DaemonOpt) (Da
7272 pluginConfs : pluginConfigs {make (map [string ]interface {})},
7373 daemonPid : - 1 ,
7474 logger : logrus .WithField ("module" , "libcontainerd" ),
75- daemonStartCh : make (chan struct {} ),
75+ daemonStartCh : make (chan error , 1 ),
7676 daemonStopCh : make (chan struct {}),
7777 }
7878
@@ -92,7 +92,10 @@ func Start(ctx context.Context, rootDir, stateDir string, opts ...DaemonOpt) (Da
9292 select {
9393 case <- time .After (startupTimeout ):
9494 return nil , errors .New ("timeout waiting for containerd to start" )
95- case <- r .daemonStartCh :
95+ case err := <- r .daemonStartCh :
96+ if err != nil {
97+ return nil , err
98+ }
9699 }
97100
98101 return r , nil
@@ -263,7 +266,11 @@ func (r *remote) monitorDaemon(ctx context.Context) {
263266
264267 os .RemoveAll (r .GRPC .Address )
265268 if err := r .startContainerd (); err != nil {
266- r .logger .WithError (err ).Error ("failed starting containerd" )
269+ if ! started {
270+ r .daemonStartCh <- err
271+ return
272+ }
273+ r .logger .WithError (err ).Error ("failed restarting containerd" )
267274 delay = time .After (50 * time .Millisecond )
268275 continue
269276 }
0 commit comments