Cleanup: Merge adjustCPUShares to adoptContainerSettings

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Upstream-commit: e0af23dc18eac17633ab1f2541f26b56c303a18c
Component: engine
This commit is contained in:
Qiang Huang
2015-08-06 08:15:14 +08:00
parent b5f711f36e
commit 3ec8bc1fa3
7 changed files with 56 additions and 49 deletions

View File

@ -8,21 +8,12 @@ import (
"net/http"
"strconv"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/daemon"
"github.com/docker/docker/pkg/sockets"
"github.com/docker/docker/pkg/systemd"
"github.com/docker/docker/pkg/version"
"github.com/docker/docker/runconfig"
"github.com/docker/libnetwork/portallocator"
)
const (
// See http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/tree/kernel/sched/sched.h?id=8cd9234c64c584432f6992fe944ca9e46ca8ea76#n269
linuxMinCPUShares = 2
linuxMaxCPUShares = 262144
)
// newServer sets up the required serverClosers and does protocol specific checking.
func (s *Server) newServer(proto, addr string) ([]serverCloser, error) {
var (
@ -110,21 +101,6 @@ func allocateDaemonPort(addr string) error {
return nil
}
func adjustCPUShares(version version.Version, hostConfig *runconfig.HostConfig) {
if version.LessThan("1.19") {
if hostConfig != nil && hostConfig.CPUShares > 0 {
// Handle unsupported CpuShares
if hostConfig.CPUShares < linuxMinCPUShares {
logrus.Warnf("Changing requested CpuShares of %d to minimum allowed of %d", hostConfig.CPUShares, linuxMinCPUShares)
hostConfig.CPUShares = linuxMinCPUShares
} else if hostConfig.CPUShares > linuxMaxCPUShares {
logrus.Warnf("Changing requested CpuShares of %d to maximum allowed of %d", hostConfig.CPUShares, linuxMaxCPUShares)
hostConfig.CPUShares = linuxMaxCPUShares
}
}
}
}
// getContainersByNameDownlevel performs processing for pre 1.20 APIs. This
// is only relevant on non-Windows daemons.
func getContainersByNameDownlevel(w http.ResponseWriter, s *Server, namevar string) error {