8000 add pid limits · moby/swarmkit@8f9f7dc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 8f9f7dc

Browse files
committed
add pid limits
Signed-off-by: cheyang <cheyang@163.com>
1 parent da5ee2a commit 8f9f7dc

File tree

5 files changed

+205
-149
lines changed

5 files changed

+205
-149
lines changed

agent/exec/dockerapi/container.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,12 @@ func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *volume.VolumesC
423423
func (c *containerConfig) resources() enginecontainer.Resources {
424424
resources := enginecontainer.Resources{}
425425

426+
// set pids limit
427+
pidsLimit := c.spec().PidsLimit
428+
if pidsLimit > 0 {
429+
resources.PidsLimit = pidsLimit
430+
}
431+
426432
// If no limits are specified let the engine use its defaults.
427433
//
428434
// TODO(aluzzardi): We might want to set some limits anyway otherwise

agent/exec/dockerapi/container_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,26 @@ func TestExtraHosts(t *testing.T) {
135135
}
136136
}
137137

138+
func TestPidLimit(t *testing.T) {
139+
c := containerConfig{
140+
task: &api.Task{
141+
Spec: api.TaskSpec{Runtime: &api.TaskSpec_Container{
142+
Container: &api.ContainerSpec{
143+
PidsLimit: 10,
144+
},
145+
}},
146+
},
147+
}
148+
149+
hostConfig := c.hostConfig()
150+
expected := int64(10)
151+
actual := hostConfig.PidsLimit
152+
153+
if expected != actual {
154+
t.Fatalf("expected %d, got %d", expected, actual)
155+
}
156+
}
157+
138158
func TestStopSignal(t *testing.T) {
139159
c := containerConfig{
140160
task: &api.Task{

api/api.pb.txt

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -710,13 +710,6 @@ file {
710710
type: TYPE_STRING
711711
json_name: "swiftPrefix"
712712
}
713-
field {
714-
name: "php_class_prefix"
715-
number: 40
716-
label: LABEL_OPTIONAL
717-
type: TYPE_STRING
718-
json_name: "phpClassPrefix"
719-
}
720713
field {
721714
name: "uninterpreted_option"
722715
number: 999
@@ -798,10 +791,6 @@ file {
798791
start: 8
799792
end: 9
800793
}
801-
reserved_range {
802-
start: 9
803-
end: 10
804-
}
805794
}
806795
message_type {
807796
name: "FieldOptions"
@@ -945,10 +934,6 @@ file {
945934
start: 1000
946935
end: 536870912
947936
}
948-
reserved_range {
949-
start: 5
950-
end: 6
951-
}
952937
}
953938
message_type {
954939
name: "EnumValueOptions"
@@ -4751,6 +4736,13 @@ file {
47514736
type_name: ".docker.swarmkit.v1.ContainerSpec.Isolation"
47524737
json_name: "isolation"
47534738
}
4739+
field {
4740+
name: "pidsLimit"
4741+
number: 25
4742+
label: LABEL_OPTIONAL
4743+
type: TYPE_INT64
4744+
json_name: "pidsLimit"
4745+
}
47544746
nested_type {
47554747
name: "LabelsEntry"
47564748
field {

0 commit comments

Comments
 (0)
0