-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Check for nil before using HostConfig to adjustCpuShares #14917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@srust thanks! Can you add a failing test case for this change also? And put the HostConfig nil check inside AdjustCpuShares pls |
this is a bug where when the client calls an older api (specifically < 1.19) version w/o hostconfig it results in this nil pointer dereference, failing test case:
ping @calavera I've added this to 1.8 (remove it if I've mistaken) |
Ah thanks @runcom for the test case! Was just working through the test suite to add this. I'll move the nil check. |
a3e9b0e
to
5e875be
Compare
5e875be
to
5ebd73a
Compare
e4dae9d
to
0933fa4
Compare
@srust could you also squash your commits down to just one pls? |
@runcom I've commited your patch for the unit test (hope that's okay). thanks again. I've pushed both the fix and test case and rebased with master. Let me know anything else you need for this. Thanks! |
0933fa4
to
3c73b1a
Compare
Squashed to one commit. |
LGTM |
@@ -1687,3 +1687,13 @@ func (s *DockerSuite) TestPostContainersStartWithLinksInHostConfigIdLinked(c *ch | |||
c.Assert(res.StatusCode, check.Equals, http.StatusNoContent) | |||
b.Close() | |||
} | |||
|
|||
// #14915 | |||
func (s *DockerSuite) TestPostContainersCreateWithoutHostConfigOnOldAPI(c *check.C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TestContainersApiCreateNoHostConfig118
Fix moby#14915. Add unit test for moby#14915. Thanks @runcom for the test case: when the client calls 1.18 api version w/o hostconfig it results in a nil pointer dereference. Signed-off-by: Stephen Rust <srust@blockbridge.com>
3c73b1a
to
c358a4c
Compare
Renamed unit test from code review. |
LGTM |
1 similar comment
LGTM |
Check for nil before using HostConfig to adjustCpuShares
cherry picked into #15091 |
Hi,
This fixes #14915 for me.
The remote API in master does not work for a /container/create request that comes in with a missing HostConfig sub-object. Docker will dereference a nil pointer.
The 'adjustCpuShares' function expects a valid HostConfig object.
It appears that the commit for #13218 changed the behavior of the decoder, to no longer create a new HostConfig object if none was specified over the API. That change appears to have broken the create call. With this fix applied, the issue no longer occurs.
Thanks!
Signed-off-by: Stephen Rust srust@blockbridge.com