فهرست منبع

Merge pull request #44309 from thaJeztah/daemon_check_requirements

daemon: NewDaemon(): check system requirements early
Sebastiaan van Stijn 2 سال پیش
والد
کامیت
e7904c5faa
4فایلهای تغییر یافته به همراه11 افزوده شده و 15 حذف شده
  1. 4 8
      daemon/daemon.go
  2. 0 1
      daemon/daemon_unix.go
  3. 7 5
      daemon/daemon_unsupported.go
  4. 0 1
      daemon/daemon_windows.go

+ 4 - 8
daemon/daemon.go

@@ -710,9 +710,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)
@@ -736,11 +737,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

+ 0 - 1
daemon/daemon_unix.go

@@ -61,7 +61,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

+ 7 - 5
daemon/daemon_unsupported.go

@@ -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()
 }

+ 0 - 1
daemon/daemon_windows.go

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