Ensure clean engine shutdown on startup errors
Previously on error either from the daemon or from the api it is just exiting with exit status 1 but not performing a shutdown. This can produce insconsistent state depending on where the error came from. This makes sure that before we exit on error that the engine gets fully shutdown. Signed-off-by: Brian Goff <cpuguy83@gmail.com> Upstream-commit: 0e3f2f2ac07c69922bd837f864219a088d243248 Component: engine
This commit is contained in:
@@ -1002,14 +1002,6 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
|
||||
trustStore: t,
|
||||
statsCollector: newStatsCollector(1 * time.Second),
|
||||
}
|
||||
if err := daemon.restore(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// set up filesystem watch on resolv.conf for network changes
|
||||
if err := daemon.setupResolvconfWatcher(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Setup shutdown handlers
|
||||
// FIXME: can these shutdown handlers be registered closer to their source?
|
||||
@@ -1030,6 +1022,15 @@ func NewDaemonFromDirectory(config *Config, eng *engine.Engine) (*Daemon, error)
|
||||
}
|
||||
})
|
||||
|
||||
if err := daemon.restore(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// set up filesystem watch on resolv.conf for network changes
|
||||
if err := daemon.setupResolvconfWatcher(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return daemon, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user