mirror of
https://github.com/moby/moby.git
synced 2026-08-10 17:15:06 +00:00
daemon: Check system requirements before initialization
Move checkSystem() call from inside NewDaemon() to cli.start() to validate system requirements earlier in the startup process. Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
This commit is contained in:
@@ -114,6 +114,11 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) {
|
||||
debug.Enable()
|
||||
}
|
||||
|
||||
// Verify platform-specific requirements before proceeding with daemon initialization
|
||||
if err := daemon.CheckSystem(); err != nil {
|
||||
return fmt.Errorf("system requirements not met: %w", err)
|
||||
}
|
||||
|
||||
if rootless.RunningWithRootlessKit() && !cli.Config.IsRootless() {
|
||||
return errors.New("rootless mode needs to be enabled for running with RootlessKit")
|
||||
}
|
||||
|
||||
@@ -807,15 +807,15 @@ func (daemon *Daemon) IsSwarmCompatible() error {
|
||||
return daemon.config().IsSwarmCompatible()
|
||||
}
|
||||
|
||||
// CheckSystem verifies that the system meets the platform-specific requirements
|
||||
// for running the Docker daemon.
|
||||
func CheckSystem() error {
|
||||
return checkSystem()
|
||||
}
|
||||
|
||||
// NewDaemon sets up everything for the daemon to be able to service
|
||||
// requests from the webserver.
|
||||
func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.Store, authzMiddleware *authorization.Middleware) (_ *Daemon, retErr error) {
|
||||
// Verify platform-specific requirements.
|
||||
// TODO(thaJeztah): this should be called before we try to create the daemon; perhaps together with the config validation.
|
||||
if err := checkSystem(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
registryService, err := registry.NewService(config.ServiceOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user