mirror of https://github.com/docker/docs.git
use 1024 as total cpushare for a machine
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
parent
e1e7259b8a
commit
b304a453f4
|
@ -265,7 +265,7 @@ func (n *node) updateContainer(c dockerclient.Container, containers map[string]*
|
|||
}
|
||||
container.Info = *info
|
||||
// real CpuShares -> nb of CPUs
|
||||
container.Info.Config.CpuShares = container.Info.Config.CpuShares / 100.0 * n.Cpus
|
||||
container.Info.Config.CpuShares = container.Info.Config.CpuShares * 1024.0 / n.Cpus
|
||||
}
|
||||
|
||||
return containers, nil
|
||||
|
@ -366,7 +366,7 @@ func (n *node) create(config *dockerclient.ContainerConfig, name string, pullIma
|
|||
newConfig := *config
|
||||
|
||||
// nb of CPUs -> real CpuShares
|
||||
newConfig.CpuShares = config.CpuShares * 100 / n.Cpus
|
||||
newConfig.CpuShares = config.CpuShares * 1024 / n.Cpus
|
||||
|
||||
if id, err = client.CreateContainer(&newConfig, name); err != nil {
|
||||
// If the error is other than not found, abort immediately.
|
||||
|
|
|
@ -171,7 +171,7 @@ func TestCreateContainer(t *testing.T) {
|
|||
var (
|
||||
config = &dockerclient.ContainerConfig{
|
||||
Image: "busybox",
|
||||
CpuShares: 512,
|
||||
CpuShares: 1,
|
||||
Cmd: []string{"date"},
|
||||
Tty: false,
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ func TestCreateContainer(t *testing.T) {
|
|||
assert.True(t, node.isConnected())
|
||||
|
||||
mockConfig := *config
|
||||
mockConfig.CpuShares = config.CpuShares * mockInfo.NCPU
|
||||
mockConfig.CpuShares = config.CpuShares * 1024 / mockInfo.NCPU
|
||||
|
||||
// Everything is ok
|
||||
name := "test1"
|
||||
|
@ -203,7 +203,7 @@ func TestCreateContainer(t *testing.T) {
|
|||
|
||||
// Image not found, pullImage == false
|
||||
name = "test2"
|
||||
mockConfig.CpuShares = config.CpuShares * mockInfo.NCPU
|
||||
mockConfig.CpuShares = config.CpuShares * 1024 / mockInfo.NCPU
|
||||
client.On("CreateContainer", &mockConfig, name).Return("", dockerclient.ErrNotFound).Once()
|
||||
container, err = node.create(config, name, false)
|
||||
assert.Equal(t, err, dockerclient.ErrNotFound)
|
||||
|
@ -212,7 +212,7 @@ func TestCreateContainer(t *testing.T) {
|
|||
// Image not found, pullImage == true, and the image can be pulled successfully
|
||||
name = "test3"
|
||||
id = "id3"
|
||||
mockConfig.CpuShares = config.CpuShares * mockInfo.NCPU
|
||||
mockConfig.CpuShares = config.CpuShares * 1024 / mockInfo.NCPU
|
||||
client.On("PullImage", config.Image+":latest", mock.Anything).Return(nil).Once()
|
||||
client.On("CreateContainer", &mockConfig, name).Return("", dockerclient.ErrNotFound).Once()
|
||||
client.On("CreateContainer", &mockConfig, name).Return(id, nil).Once()
|
||||
|
|
Loading…
Reference in New Issue