mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Cleanup: remove some useless code and change verifyHostConfig to verifyContainerSetting
Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
parent
5d22afc54e
commit
67552fb22d
6 changed files with 11 additions and 23 deletions
|
@ -252,7 +252,6 @@ func (container *Container) Start() (err error) {
|
||||||
if err := container.initializeNetworking(); err != nil {
|
if err := container.initializeNetworking(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
container.verifyDaemonSettings()
|
|
||||||
linkedEnv, err := container.setupLinkedContainers()
|
linkedEnv, err := container.setupLinkedContainers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -832,21 +832,6 @@ func (container *Container) initializeNetworking() error {
|
||||||
return container.buildHostnameFile()
|
return container.buildHostnameFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the config is compatible with the current kernel
|
|
||||||
func (container *Container) verifyDaemonSettings() {
|
|
||||||
if container.hostConfig.Memory > 0 && !container.daemon.sysInfo.MemoryLimit {
|
|
||||||
logrus.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.")
|
|
||||||
container.hostConfig.Memory = 0
|
|
||||||
}
|
|
||||||
if container.hostConfig.Memory > 0 && container.hostConfig.MemorySwap != -1 && !container.daemon.sysInfo.SwapLimit {
|
|
||||||
logrus.Warnf("Your kernel does not support swap limit capabilities. Limitation discarded.")
|
|
||||||
container.hostConfig.MemorySwap = -1
|
|
||||||
}
|
|
||||||
if container.daemon.sysInfo.IPv4ForwardingDisabled {
|
|
||||||
logrus.Warnf("IPv4 forwarding is disabled. Networking will not work")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (container *Container) ExportRw() (archive.Archive, error) {
|
func (container *Container) ExportRw() (archive.Archive, error) {
|
||||||
if container.daemon == nil {
|
if container.daemon == nil {
|
||||||
return nil, fmt.Errorf("Can't load storage driver for unregistered container %s", container.ID)
|
return nil, fmt.Errorf("Can't load storage driver for unregistered container %s", container.ID)
|
||||||
|
|
|
@ -59,9 +59,6 @@ func (container *Container) setupWorkingDirectory() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) verifyDaemonSettings() {
|
|
||||||
}
|
|
||||||
|
|
||||||
func populateCommand(c *Container, env []string) error {
|
func populateCommand(c *Container, env []string) error {
|
||||||
en := &execdriver.Network{
|
en := &execdriver.Network{
|
||||||
Mtu: c.daemon.config.Mtu,
|
Mtu: c.daemon.config.Mtu,
|
||||||
|
|
|
@ -19,7 +19,7 @@ func (daemon *Daemon) ContainerCreate(name string, config *runconfig.Config, hos
|
||||||
return "", nil, fmt.Errorf("Config cannot be empty in order to create a container")
|
return "", nil, fmt.Errorf("Config cannot be empty in order to create a container")
|
||||||
}
|
}
|
||||||
|
|
||||||
warnings, err := daemon.verifyHostConfig(hostConfig)
|
warnings, err := daemon.verifyContainerSettings(hostConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", warnings, err
|
return "", warnings, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1166,7 +1166,7 @@ func checkKernel() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (daemon *Daemon) verifyHostConfig(hostConfig *runconfig.HostConfig) ([]string, error) {
|
func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig) ([]string, error) {
|
||||||
var warnings []string
|
var warnings []string
|
||||||
|
|
||||||
if hostConfig == nil {
|
if hostConfig == nil {
|
||||||
|
@ -1181,10 +1181,12 @@ func (daemon *Daemon) verifyHostConfig(hostConfig *runconfig.HostConfig) ([]stri
|
||||||
}
|
}
|
||||||
if hostConfig.Memory > 0 && !daemon.SystemConfig().MemoryLimit {
|
if hostConfig.Memory > 0 && !daemon.SystemConfig().MemoryLimit {
|
||||||
warnings = append(warnings, "Your kernel does not support memory limit capabilities. Limitation discarded.")
|
warnings = append(warnings, "Your kernel does not support memory limit capabilities. Limitation discarded.")
|
||||||
|
logrus.Warnf("Your kernel does not support memory limit capabilities. Limitation discarded.")
|
||||||
hostConfig.Memory = 0
|
hostConfig.Memory = 0
|
||||||
}
|
}
|
||||||
if hostConfig.Memory > 0 && hostConfig.MemorySwap != -1 && !daemon.SystemConfig().SwapLimit {
|
if hostConfig.Memory > 0 && hostConfig.MemorySwap != -1 && !daemon.SystemConfig().SwapLimit {
|
||||||
warnings = append(warnings, "Your kernel does not support swap limit capabilities, memory limited without swap.")
|
warnings = append(warnings, "Your kernel does not support swap limit capabilities, memory limited without swap.")
|
||||||
|
logrus.Warnf("Your kernel does not support swap limit capabilities, memory limited without swap.")
|
||||||
hostConfig.MemorySwap = -1
|
hostConfig.MemorySwap = -1
|
||||||
}
|
}
|
||||||
if hostConfig.Memory > 0 && hostConfig.MemorySwap > 0 && hostConfig.MemorySwap < hostConfig.Memory {
|
if hostConfig.Memory > 0 && hostConfig.MemorySwap > 0 && hostConfig.MemorySwap < hostConfig.Memory {
|
||||||
|
@ -1195,10 +1197,12 @@ func (daemon *Daemon) verifyHostConfig(hostConfig *runconfig.HostConfig) ([]stri
|
||||||
}
|
}
|
||||||
if hostConfig.CpuPeriod > 0 && !daemon.SystemConfig().CpuCfsPeriod {
|
if hostConfig.CpuPeriod > 0 && !daemon.SystemConfig().CpuCfsPeriod {
|
||||||
warnings = append(warnings, "Your kernel does not support CPU cfs period. Period discarded.")
|
warnings = append(warnings, "Your kernel does not support CPU cfs period. Period discarded.")
|
||||||
|
logrus.Warnf("Your kernel does not support CPU cfs period. Period discarded.")
|
||||||
hostConfig.CpuPeriod = 0
|
hostConfig.CpuPeriod = 0
|
||||||
}
|
}
|
||||||
if hostConfig.CpuQuota > 0 && !daemon.SystemConfig().CpuCfsQuota {
|
if hostConfig.CpuQuota > 0 && !daemon.SystemConfig().CpuCfsQuota {
|
||||||
warnings = append(warnings, "Your kernel does not support CPU cfs quota. Quota discarded.")
|
warnings = append(warnings, "Your kernel does not support CPU cfs quota. Quota discarded.")
|
||||||
|
logrus.Warnf("Your kernel does not support CPU cfs quota. Quota discarded.")
|
||||||
hostConfig.CpuQuota = 0
|
hostConfig.CpuQuota = 0
|
||||||
}
|
}
|
||||||
if hostConfig.BlkioWeight > 0 && (hostConfig.BlkioWeight < 10 || hostConfig.BlkioWeight > 1000) {
|
if hostConfig.BlkioWeight > 0 && (hostConfig.BlkioWeight < 10 || hostConfig.BlkioWeight > 1000) {
|
||||||
|
@ -1208,7 +1212,10 @@ func (daemon *Daemon) verifyHostConfig(hostConfig *runconfig.HostConfig) ([]stri
|
||||||
hostConfig.OomKillDisable = false
|
hostConfig.OomKillDisable = false
|
||||||
return warnings, fmt.Errorf("Your kernel does not support oom kill disable.")
|
return warnings, fmt.Errorf("Your kernel does not support oom kill disable.")
|
||||||
}
|
}
|
||||||
|
if daemon.SystemConfig().IPv4ForwardingDisabled {
|
||||||
|
warnings = append(warnings, "IPv4 forwarding is disabled. Networking will not work.")
|
||||||
|
logrus.Warnf("IPv4 forwarding is disabled. Networking will not work")
|
||||||
|
}
|
||||||
return warnings, nil
|
return warnings, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *runconfig.HostConf
|
||||||
return fmt.Errorf("Container already started")
|
return fmt.Errorf("Container already started")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = daemon.verifyHostConfig(hostConfig); err != nil {
|
if _, err = daemon.verifyContainerSettings(hostConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue