Skip to content

Fix container update resetting pidslimit on older API clients#38791

Merged
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:update_api_changes
Feb 27, 2019
Merged

Fix container update resetting pidslimit on older API clients#38791
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:update_api_changes

Conversation

@thaJeztah
Copy link
Member

Follow-up to #32519

Older API clients did not use a pointer for PidsLimit, so API requests would always send 0, resulting in any previous value to be reset after an update:

Before this patch:

(using a 17.06 Docker CLI):

docker run -dit --name test --pids-limit=16 busybox
docker container inspect --format '{{json .HostConfig.PidsLimit}}' test
16

docker container update --memory=100M --memory-swap=200M test

docker container inspect --format '{{json .HostConfig.PidsLimit}}' test
0

docker container exec test cat /sys/fs/cgroup/pids/pids.max
max

With this patch applied:

(using a 17.06 Docker CLI):

docker run -dit --name test --pids-limit=16 busybox
docker container inspect --format '{{json .HostConfig.PidsLimit}}' test
16

docker container update --memory=100M --memory-swap=200M test

docker container inspect --format '{{json .HostConfig.PidsLimit}}' test
16

docker container exec test cat /sys/fs/cgroup/pids/pids.max
16

@thaJeztah
Copy link
Member Author

ping @cpuguy83 @kolyshkin PTAL

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering what is the "idiomatic" way to set properties of embedded structs? Is this better?

Suggested change
updateConfig.PidsLimit = nil
updateConfig.Resources.PidsLimit = nil

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, I tends to prefer the explicit way (aka updateConfig.Resources.PidsLimit) but not sure what is the "idiomatic" way 😅

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice catch!

@codecov
Copy link

codecov bot commented Feb 24, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@dd94555). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master   #38791   +/-   ##
=========================================
  Coverage          ?   36.44%           
=========================================
  Files             ?      613           
  Lines             ?    45847           
  Branches          ?        0           
=========================================
  Hits              ?    16710           
  Misses            ?    26844           
  Partials          ?     2293

Older API clients did not use a pointer for `PidsLimit`, so
API requests would always send `0`, resulting in any previous
value to be reset after an update:

Before this patch:

(using a 17.06 Docker CLI):

```bash
docker run -dit --name test --pids-limit=16 busybox
docker container inspect --format '{{json .HostConfig.PidsLimit}}' test
16

docker container update --memory=100M --memory-swap=200M test

docker container inspect --format '{{json .HostConfig.PidsLimit}}' test
0

docker container exec test cat /sys/fs/cgroup/pids/pids.max
max
```

With this patch applied:

(using a 17.06 Docker CLI):

```bash
docker run -dit --name test --pids-limit=16 busybox
docker container inspect --format '{{json .HostConfig.PidsLimit}}' test
16

docker container update --memory=100M --memory-swap=200M test

docker container inspect --format '{{json .HostConfig.PidsLimit}}' test
16

docker container exec test cat /sys/fs/cgroup/pids/pids.max
16
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :tiger:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, I tends to prefer the explicit way (aka updateConfig.Resources.PidsLimit) but not sure what is the "idiomatic" way 😅

@thaJeztah thaJeztah merged commit 91d934b into moby:master Feb 27, 2019
@thaJeztah thaJeztah deleted the update_api_changes branch February 27, 2019 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants