mirror of https://github.com/docker/docs.git
OverCommit -> Usable
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
d57eca7bc9
commit
45ea947e0e
|
|
@ -270,11 +270,11 @@ func (n *Node) ReservedCpus() int64 {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) OverCommitedMemory() int64 {
|
func (n *Node) UsableMemory() int64 {
|
||||||
return n.Memory + (n.Memory * n.overcommitRatio / 100)
|
return n.Memory + (n.Memory * n.overcommitRatio / 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) OverCommitedCpus() int64 {
|
func (n *Node) UsableCpus() int64 {
|
||||||
return n.Cpus + (n.Cpus * n.overcommitRatio / 100)
|
return n.Cpus + (n.Cpus * n.overcommitRatio / 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,22 +187,22 @@ func TestCreateContainer(t *testing.T) {
|
||||||
assert.Len(t, node.Containers(), 2)
|
assert.Len(t, node.Containers(), 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOverCommitedMemory(t *testing.T) {
|
func TestUsableMemory(t *testing.T) {
|
||||||
node := NewNode("test", 105)
|
node := NewNode("test", 105)
|
||||||
node.Memory = 1024
|
node.Memory = 1024
|
||||||
assert.Equal(t, node.OverCommitedMemory(), 1024+1024*5/100)
|
assert.Equal(t, node.UsableMemory(), 1024+1024*5/100)
|
||||||
|
|
||||||
node = NewNode("test", 90)
|
node = NewNode("test", 90)
|
||||||
node.Memory = 1024
|
node.Memory = 1024
|
||||||
assert.Equal(t, node.OverCommitedMemory(), 1024-1024*10/100)
|
assert.Equal(t, node.UsableMemory(), 1024-1024*10/100)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOverCommitedCpus(t *testing.T) {
|
func TestUsableCpus(t *testing.T) {
|
||||||
node := NewNode("test", 105)
|
node := NewNode("test", 105)
|
||||||
node.Cpus = 2
|
node.Cpus = 2
|
||||||
assert.Equal(t, node.OverCommitedCpus(), 2+2*5/100)
|
assert.Equal(t, node.UsableCpus(), 2+2*5/100)
|
||||||
|
|
||||||
node = NewNode("test", 90)
|
node = NewNode("test", 90)
|
||||||
node.Cpus = 2
|
node.Cpus = 2
|
||||||
assert.Equal(t, node.OverCommitedCpus(), 2-2*10/100)
|
assert.Equal(t, node.UsableCpus(), 2-2*10/100)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ func (p *BinPackingPlacementStrategy) PlaceContainer(config *dockerclient.Contai
|
||||||
scores := scores{}
|
scores := scores{}
|
||||||
|
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
nodeMemory := node.OverCommitedMemory()
|
nodeMemory := node.UsableMemory()
|
||||||
nodeCpus := node.OverCommitedCpus()
|
nodeCpus := node.UsableCpus()
|
||||||
|
|
||||||
// Skip nodes that are smaller than the requested resources.
|
// Skip nodes that are smaller than the requested resources.
|
||||||
if nodeMemory < int64(config.Memory) || nodeCpus < config.CpuShares {
|
if nodeMemory < int64(config.Memory) || nodeCpus < config.CpuShares {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue