Skip to content

Commit 17fb29c

Browse files
committed
daemon: NewDaemon(): check system requirements early
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent d006242 commit 17fb29c

4 files changed

Lines changed: 11 additions & 15 deletions

File tree

daemon/daemon.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,10 @@ func (daemon *Daemon) IsSwarmCompatible() error {
706706
// NewDaemon sets up everything for the daemon to be able to service
707707
// requests from the webserver.
708708
func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.Store) (daemon *Daemon, err error) {
709-
// Verify the platform is supported as a daemon
710-
if !platformSupported {
711-
return nil, errors.New("the Docker daemon is not supported on this platform")
709+
// Verify platform-specific requirements.
710+
// TODO(thaJeztah): this should be called before we try to create the daemon; perhaps together with the config validation.
711+
if err := checkSystem(); err != nil {
712+
return nil, err
712713
}
713714

714715
registryService, err := registry.NewService(config.ServiceOptions)
@@ -732,11 +733,6 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
732733
// Setup the resolv.conf
733734
setupResolvConf(config)
734735

735-
// Validate platform-specific requirements
736-
if err := checkSystem(); err != nil {
737-
return nil, err
738-
}
739-
740736
idMapping, err := setupRemappedRoot(config)
741737
if err != nil {
742738
return nil, err

daemon/daemon_unix.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ const (
6060
// See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/tree/kernel/sched/sched.h?id=8cd9234c64c584432f6992fe944ca9e46ca8ea76#n269
6161
linuxMinCPUShares = 2
6262
linuxMaxCPUShares = 262144
63-
platformSupported = true
6463
// It's not kernel limit, we want this 6M limit to account for overhead during startup, and to supply a reasonable functional container
6564
linuxMinMemory = 6291456
6665
// constants for remapped root settings

daemon/daemon_unsupported.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
package daemon // import "github.com/docker/docker/daemon"
55

66
import (
7-
"github.com/docker/docker/daemon/config"
7+
"errors"
8+
89
"github.com/docker/docker/pkg/sysinfo"
910
)
1011

11-
const platformSupported = false
12-
13-
func setupResolvConf(config *config.Config) {
12+
func checkSystem() error {
13+
return errors.New("the Docker daemon is not supported on this platform")
1414
}
1515

16-
func getSysInfo(daemon *Daemon) *sysinfo.SysInfo {
16+
func setupResolvConf(_ *interface{}) {}
17+
18+
func getSysInfo(_ *Daemon) *sysinfo.SysInfo {
1719
return sysinfo.New()
1820
}

daemon/daemon_windows.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838

3939
const (
4040
isWindows = true
41-
platformSupported = true
4241
windowsMinCPUShares = 1
4342
windowsMaxCPUShares = 10000
4443
windowsMinCPUPercent = 1

0 commit comments

Comments
 (0)