1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Renamed Container property Ram to Memory before it is too late

This commit is contained in:
Sam Alba 2013-03-11 19:25:02 -07:00
parent 4e5ae88372
commit 948961831a
3 changed files with 26 additions and 26 deletions

View file

@ -53,8 +53,8 @@ type Container struct {
type Config struct { type Config struct {
Hostname string Hostname string
User string User string
Ram int64 // Memory limit (in bytes) Memory int64 // Memory limit (in bytes)
RamSwap int64 // Total memory usage (ram + swap); set `-1' to disable swap MemorySwap int64 // Total memory usage (memory + swap); set `-1' to disable swap
Ports []int Ports []int
Tty bool // Attach standard streams to a tty, including stdin if it is not closed. Tty bool // Attach standard streams to a tty, including stdin if it is not closed.
OpenStdin bool // Open stdin OpenStdin bool // Open stdin

View file

@ -24,7 +24,7 @@ func TestStart(t *testing.T) {
[]string{"-al"}, []string{"-al"},
[]string{testLayerPath}, []string{testLayerPath},
&Config{ &Config{
Ram: 33554432, Memory: 33554432,
}, },
) )
if err != nil { if err != nil {
@ -60,7 +60,7 @@ func TestRun(t *testing.T) {
[]string{"-al"}, []string{"-al"},
[]string{testLayerPath}, []string{testLayerPath},
&Config{ &Config{
Ram: 33554432, Memory: 33554432,
}, },
) )
if err != nil { if err != nil {
@ -589,11 +589,11 @@ func TestLXCConfig(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Ram is allocated randomly for testing // Memory is allocated randomly for testing
rand.Seed(time.Now().UTC().UnixNano()) rand.Seed(time.Now().UTC().UnixNano())
ramMin := 33554432 memMin := 33554432
ramMax := 536870912 memMax := 536870912
ram := ramMin + rand.Intn(ramMax-ramMin) mem := memMin + rand.Intn(memMax-memMin)
container, err := docker.Create( container, err := docker.Create(
"config_test", "config_test",
"/bin/true", "/bin/true",
@ -601,7 +601,7 @@ func TestLXCConfig(t *testing.T) {
[]string{testLayerPath}, []string{testLayerPath},
&Config{ &Config{
Hostname: "foobar", Hostname: "foobar",
Ram: int64(ram), Memory: int64(mem),
}, },
) )
if err != nil { if err != nil {
@ -611,9 +611,9 @@ func TestLXCConfig(t *testing.T) {
container.generateLXCConfig() container.generateLXCConfig()
grepFile(t, container.lxcConfigPath, "lxc.utsname = foobar") grepFile(t, container.lxcConfigPath, "lxc.utsname = foobar")
grepFile(t, container.lxcConfigPath, grepFile(t, container.lxcConfigPath,
fmt.Sprintf("lxc.cgroup.memory.limit_in_bytes = %d", ram)) fmt.Sprintf("lxc.cgroup.memory.limit_in_bytes = %d", mem))
grepFile(t, container.lxcConfigPath, grepFile(t, container.lxcConfigPath,
fmt.Sprintf("lxc.cgroup.memory.memsw.limit_in_bytes = %d", ram*2)) fmt.Sprintf("lxc.cgroup.memory.memsw.limit_in_bytes = %d", mem*2))
} }
func BenchmarkRunSequencial(b *testing.B) { func BenchmarkRunSequencial(b *testing.B) {

View file

@ -85,10 +85,10 @@ lxc.mount.entry = /etc/resolv.conf {{$ROOTFS}}/etc/resolv.conf none bind,ro 0 0
lxc.cap.drop = audit_control audit_write mac_admin mac_override mknod net_raw setfcap setpcap sys_admin sys_boot sys_module sys_nice sys_pacct sys_rawio sys_resource sys_time sys_tty_config lxc.cap.drop = audit_control audit_write mac_admin mac_override mknod net_raw setfcap setpcap sys_admin sys_boot sys_module sys_nice sys_pacct sys_rawio sys_resource sys_time sys_tty_config
# limits # limits
{{if .Config.Ram}} {{if .Config.Memory}}
lxc.cgroup.memory.limit_in_bytes = {{.Config.Ram}} lxc.cgroup.memory.limit_in_bytes = {{.Config.Memory}}
lxc.cgroup.memory.soft_limit_in_bytes = {{.Config.Ram}} lxc.cgroup.memory.soft_limit_in_bytes = {{.Config.Memory}}
{{with $ramSwap := getRamSwap .Config}} {{with $ramSwap := getMemorySwap .Config}}
lxc.cgroup.memory.memsw.limit_in_bytes = {{$ramSwap}} lxc.cgroup.memory.memsw.limit_in_bytes = {{$ramSwap}}
{{end}} {{end}}
{{end}} {{end}}
@ -96,19 +96,19 @@ lxc.cgroup.memory.memsw.limit_in_bytes = {{$ramSwap}}
var LxcTemplateCompiled *template.Template var LxcTemplateCompiled *template.Template
func getRamSwap(config *Config) int64 { func getMemorySwap(config *Config) int64 {
// By default, RamSwap is set to twice the size of RAM. // By default, MemorySwap is set to twice the size of RAM.
// If you want to omit RamSwap, set it to `-1'. // If you want to omit MemorySwap, set it to `-1'.
if config.RamSwap < 0 { if config.MemorySwap < 0 {
return 0 return 0
} }
return config.Ram * 2 return config.Memory * 2
} }
func init() { func init() {
var err error var err error
funcMap := template.FuncMap{ funcMap := template.FuncMap{
"getRamSwap": getRamSwap, "getMemorySwap": getMemorySwap,
} }
LxcTemplateCompiled, err = template.New("lxc").Funcs(funcMap).Parse(LxcTemplate) LxcTemplateCompiled, err = template.New("lxc").Funcs(funcMap).Parse(LxcTemplate)
if err != nil { if err != nil {