daemon: NewDaemon(): check system requirements early

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-10-17 12:47:25 +02:00
parent d006242d73
commit 17fb29c9e8
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
4 changed files with 11 additions and 15 deletions

View File

@ -706,9 +706,10 @@ func (daemon *Daemon) IsSwarmCompatible() error {
// 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) (daemon *Daemon, err error) {
// Verify the platform is supported as a daemon
if !platformSupported {
return nil, errors.New("the Docker daemon is not supported on this platform")
// 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)
@ -732,11 +733,6 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
// Setup the resolv.conf
setupResolvConf(config)
// Validate platform-specific requirements
if err := checkSystem(); err != nil {
return nil, err
}
idMapping, err := setupRemappedRoot(config)
if err != nil {
return nil, err

View File

@ -60,7 +60,6 @@ const (
// See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/tree/kernel/sched/sched.h?id=8cd9234c64c584432f6992fe944ca9e46ca8ea76#n269
linuxMinCPUShares = 2
linuxMaxCPUShares = 262144
platformSupported = true
// It's not kernel limit, we want this 6M limit to account for overhead during startup, and to supply a reasonable functional container
linuxMinMemory = 6291456
// constants for remapped root settings

View File

@ -4,15 +4,17 @@
package daemon // import "github.com/docker/docker/daemon"
import (
"github.com/docker/docker/daemon/config"
"errors"
"github.com/docker/docker/pkg/sysinfo"
)
const platformSupported = false
func setupResolvConf(config *config.Config) {
func checkSystem() error {
return errors.New("the Docker daemon is not supported on this platform")
}
func getSysInfo(daemon *Daemon) *sysinfo.SysInfo {
func setupResolvConf(_ *interface{}) {}
func getSysInfo(_ *Daemon) *sysinfo.SysInfo {
return sysinfo.New()
}

View File

@ -38,7 +38,6 @@ import (
const (
isWindows = true
platformSupported = true
windowsMinCPUShares = 1
windowsMaxCPUShares = 10000
windowsMinCPUPercent = 1