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

Add API support for PidsLimit on services

Support for PidsLimit was added to SwarmKit in docker/swarmkit/pull/2415,
but never exposed through the Docker remove API.

This patch exposes the feature in the repote API.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-09-09 14:51:07 +02:00
parent f4b0673565
commit 157c53c8e0
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
9 changed files with 134 additions and 4 deletions

View file

@ -17,7 +17,8 @@ func TestAdjustForAPIVersion(t *testing.T) {
spec := &swarm.ServiceSpec{
TaskTemplate: swarm.TaskSpec{
ContainerSpec: &swarm.ContainerSpec{
Sysctls: expectedSysctls,
Sysctls: expectedSysctls,
PidsLimit: 300,
Privileges: &swarm.Privileges{
CredentialSpec: &swarm.CredentialSpec{
Config: "someconfig",
@ -49,11 +50,18 @@ func TestAdjustForAPIVersion(t *testing.T) {
// first, does calling this with a later version correctly NOT strip
// fields? do the later version first, so we can reuse this spec in the
// next test.
adjustForAPIVersion("1.40", spec)
adjustForAPIVersion("1.41", spec)
if !reflect.DeepEqual(spec.TaskTemplate.ContainerSpec.Sysctls, expectedSysctls) {
t.Error("Sysctls was stripped from spec")
}
if spec.TaskTemplate.ContainerSpec.PidsLimit == 0 {
t.Error("PidsLimit was stripped from spec")
}
if spec.TaskTemplate.ContainerSpec.PidsLimit != 300 {
t.Error("PidsLimit did not preserve the value from spec")
}
if spec.TaskTemplate.ContainerSpec.Privileges.CredentialSpec.Config != "someconfig" {
t.Error("CredentialSpec.Config field was stripped from spec")
}
@ -72,6 +80,10 @@ func TestAdjustForAPIVersion(t *testing.T) {
t.Error("Sysctls was not stripped from spec")
}
if spec.TaskTemplate.ContainerSpec.PidsLimit != 0 {
t.Error("PidsLimit was not stripped from spec")
}
if spec.TaskTemplate.ContainerSpec.Privileges.CredentialSpec.Config != "" {
t.Error("CredentialSpec.Config field was not stripped from spec")
}