diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2020-05-08 21:11:51 +0200 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2020-06-05 12:50:38 +0200 |
commit | 687bdc7c71a4722caa598f809b05deb2572191d5 (patch) | |
tree | 0e363f79ec91ebd610bae36a9e57b1cc195c1761 /integration/internal | |
parent | fa38a6cd21fec539066a2e3429b98b33f6427dfe (diff) | |
download | docker-687bdc7c71a4722caa598f809b05deb2572191d5.tar.gz |
API: swarm: move PidsLimit to TaskTemplate.Resources
The initial implementation followed the Swarm API, where
PidsLimit is located in ContainerSpec. This is not the
desired place for this property, so moving the field to
TaskTemplate.Resources in our API.
A similar change should be made in the SwarmKit API (likely
keeping the old field for backward compatibility, because
it was merged some releases back)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'integration/internal')
-rw-r--r-- | integration/internal/swarm/service.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/integration/internal/swarm/service.go b/integration/internal/swarm/service.go index 1ee5004860..5e9bb416ef 100644 --- a/integration/internal/swarm/service.go +++ b/integration/internal/swarm/service.go @@ -196,11 +196,11 @@ func ServiceWithCapabilities(Capabilities []string) ServiceSpecOpt { } } -// ServiceWithPidsLimit sets the PidsLimit option of the service's ContainerSpec. +// ServiceWithPidsLimit sets the PidsLimit option of the service's Resources.Limits. func ServiceWithPidsLimit(limit int64) ServiceSpecOpt { return func(spec *swarmtypes.ServiceSpec) { - ensureContainerSpec(spec) - spec.TaskTemplate.ContainerSpec.PidsLimit = limit + ensureResources(spec) + spec.TaskTemplate.Resources.Limits.Pids = limit } } @@ -235,6 +235,18 @@ func ExecTask(t *testing.T, d *daemon.Daemon, task swarmtypes.Task, config types return attach } +func ensureResources(spec *swarmtypes.ServiceSpec) { + if spec.TaskTemplate.Resources == nil { + spec.TaskTemplate.Resources = &swarmtypes.ResourceRequirements{} + } + if spec.TaskTemplate.Resources.Limits == nil { + spec.TaskTemplate.Resources.Limits = &swarmtypes.Limit{} + } + if spec.TaskTemplate.Resources.Reservations == nil { + spec.TaskTemplate.Resources.Reservations = &swarmtypes.Resources{} + } +} + func ensureContainerSpec(spec *swarmtypes.ServiceSpec) { if spec.TaskTemplate.ContainerSpec == nil { spec.TaskTemplate.ContainerSpec = &swarmtypes.ContainerSpec{} |