... | ... |
@@ -51,13 +51,13 @@ type Container struct { |
51 | 51 |
} |
52 | 52 |
|
53 | 53 |
type Config struct { |
54 |
- Hostname string |
|
55 |
- User string |
|
56 |
- Ram int64 // Memory limit (in bytes) |
|
57 |
- RamSwap int64 // Total memory usage (ram + swap); set `-1' to disable swap |
|
58 |
- Ports []int |
|
59 |
- Tty bool // Attach standard streams to a tty, including stdin if it is not closed. |
|
60 |
- OpenStdin bool // Open stdin |
|
54 |
+ Hostname string |
|
55 |
+ User string |
|
56 |
+ Memory int64 // Memory limit (in bytes) |
|
57 |
+ MemorySwap int64 // Total memory usage (memory + swap); set `-1' to disable swap |
|
58 |
+ Ports []int |
|
59 |
+ Tty bool // Attach standard streams to a tty, including stdin if it is not closed. |
|
60 |
+ OpenStdin bool // Open stdin |
|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
type NetworkSettings struct { |
... | ... |
@@ -24,7 +24,7 @@ func TestStart(t *testing.T) { |
24 | 24 |
[]string{"-al"}, |
25 | 25 |
[]string{testLayerPath}, |
26 | 26 |
&Config{ |
27 |
- Ram: 33554432, |
|
27 |
+ Memory: 33554432, |
|
28 | 28 |
}, |
29 | 29 |
) |
30 | 30 |
if err != nil { |
... | ... |
@@ -60,7 +60,7 @@ func TestRun(t *testing.T) { |
60 | 60 |
[]string{"-al"}, |
61 | 61 |
[]string{testLayerPath}, |
62 | 62 |
&Config{ |
63 |
- Ram: 33554432, |
|
63 |
+ Memory: 33554432, |
|
64 | 64 |
}, |
65 | 65 |
) |
66 | 66 |
if err != nil { |
... | ... |
@@ -589,11 +589,11 @@ func TestLXCConfig(t *testing.T) { |
589 | 589 |
if err != nil { |
590 | 590 |
t.Fatal(err) |
591 | 591 |
} |
592 |
- // Ram is allocated randomly for testing |
|
592 |
+ // Memory is allocated randomly for testing |
|
593 | 593 |
rand.Seed(time.Now().UTC().UnixNano()) |
594 |
- ramMin := 33554432 |
|
595 |
- ramMax := 536870912 |
|
596 |
- ram := ramMin + rand.Intn(ramMax-ramMin) |
|
594 |
+ memMin := 33554432 |
|
595 |
+ memMax := 536870912 |
|
596 |
+ mem := memMin + rand.Intn(memMax-memMin) |
|
597 | 597 |
container, err := docker.Create( |
598 | 598 |
"config_test", |
599 | 599 |
"/bin/true", |
... | ... |
@@ -601,7 +601,7 @@ func TestLXCConfig(t *testing.T) { |
601 | 601 |
[]string{testLayerPath}, |
602 | 602 |
&Config{ |
603 | 603 |
Hostname: "foobar", |
604 |
- Ram: int64(ram), |
|
604 |
+ Memory: int64(mem), |
|
605 | 605 |
}, |
606 | 606 |
) |
607 | 607 |
if err != nil { |
... | ... |
@@ -611,9 +611,9 @@ func TestLXCConfig(t *testing.T) { |
611 | 611 |
container.generateLXCConfig() |
612 | 612 |
grepFile(t, container.lxcConfigPath, "lxc.utsname = foobar") |
613 | 613 |
grepFile(t, container.lxcConfigPath, |
614 |
- fmt.Sprintf("lxc.cgroup.memory.limit_in_bytes = %d", ram)) |
|
614 |
+ fmt.Sprintf("lxc.cgroup.memory.limit_in_bytes = %d", mem)) |
|
615 | 615 |
grepFile(t, container.lxcConfigPath, |
616 |
- fmt.Sprintf("lxc.cgroup.memory.memsw.limit_in_bytes = %d", ram*2)) |
|
616 |
+ fmt.Sprintf("lxc.cgroup.memory.memsw.limit_in_bytes = %d", mem*2)) |
|
617 | 617 |
} |
618 | 618 |
|
619 | 619 |
func BenchmarkRunSequencial(b *testing.B) { |
... | ... |
@@ -85,10 +85,10 @@ lxc.mount.entry = /etc/resolv.conf {{$ROOTFS}}/etc/resolv.conf none bind,ro 0 0 |
85 | 85 |
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 |
86 | 86 |
|
87 | 87 |
# limits |
88 |
-{{if .Config.Ram}} |
|
89 |
-lxc.cgroup.memory.limit_in_bytes = {{.Config.Ram}} |
|
90 |
-lxc.cgroup.memory.soft_limit_in_bytes = {{.Config.Ram}} |
|
91 |
-{{with $ramSwap := getRamSwap .Config}} |
|
88 |
+{{if .Config.Memory}} |
|
89 |
+lxc.cgroup.memory.limit_in_bytes = {{.Config.Memory}} |
|
90 |
+lxc.cgroup.memory.soft_limit_in_bytes = {{.Config.Memory}} |
|
91 |
+{{with $ramSwap := getMemorySwap .Config}} |
|
92 | 92 |
lxc.cgroup.memory.memsw.limit_in_bytes = {{$ramSwap}} |
93 | 93 |
{{end}} |
94 | 94 |
{{end}} |
... | ... |
@@ -96,19 +96,19 @@ lxc.cgroup.memory.memsw.limit_in_bytes = {{$ramSwap}} |
96 | 96 |
|
97 | 97 |
var LxcTemplateCompiled *template.Template |
98 | 98 |
|
99 |
-func getRamSwap(config *Config) int64 { |
|
100 |
- // By default, RamSwap is set to twice the size of RAM. |
|
101 |
- // If you want to omit RamSwap, set it to `-1'. |
|
102 |
- if config.RamSwap < 0 { |
|
99 |
+func getMemorySwap(config *Config) int64 { |
|
100 |
+ // By default, MemorySwap is set to twice the size of RAM. |
|
101 |
+ // If you want to omit MemorySwap, set it to `-1'. |
|
102 |
+ if config.MemorySwap < 0 { |
|
103 | 103 |
return 0 |
104 | 104 |
} |
105 |
- return config.Ram * 2 |
|
105 |
+ return config.Memory * 2 |
|
106 | 106 |
} |
107 | 107 |
|
108 | 108 |
func init() { |
109 | 109 |
var err error |
110 | 110 |
funcMap := template.FuncMap{ |
111 |
- "getRamSwap": getRamSwap, |
|
111 |
+ "getMemorySwap": getMemorySwap, |
|
112 | 112 |
} |
113 | 113 |
LxcTemplateCompiled, err = template.New("lxc").Funcs(funcMap).Parse(LxcTemplate) |
114 | 114 |
if err != nil { |