Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions components/cli/vendor/github.com/docker/docker/client/hijack.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions components/engine/client/hijack.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,14 @@ func (cli *Client) setupHijackConn(req *http.Request, proto string) (net.Conn, e

// Server hijacks the connection, error 'connection closed' expected
resp, err := clientconn.Do(req)
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusSwitchingProtocols {
resp.Body.Close()
return nil, fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode)
if err != httputil.ErrPersistEOF {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should be separate from the other changes; this is a back port of moby/moby@7a53991 (moby/moby#34275) - "Fix panic in hijack"

if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusSwitchingProtocols {
resp.Body.Close()
return nil, fmt.Errorf("unable to upgrade to %s, received %d", proto, resp.StatusCode)
}
}

c, br := clientconn.Hijack()
Expand Down
6 changes: 3 additions & 3 deletions components/engine/integration-cli/docker_cli_rmi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func (s *DockerSuite) TestRmiImageIDForceWithRunningContainersAndMultipleTags(c
dockerCmd(c, "tag", imgID, newTag)
runSleepingContainerInImage(c, imgID)

out, _, err := dockerCmdWithError("rmi", "-f", imgID)
// rmi -f should not delete image with running containers
out, _, err := dockerCmdWithError("rmi", imgID)
Copy link
Member

Choose a reason for hiding this comment

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

This is actually a bug; the change was too wide; see docker/cli#394

(pull request to fix is here: docker/cli#418)

// rmi should not delete image with running containers
c.Assert(err, checker.NotNil)
c.Assert(out, checker.Contains, "(cannot be forced) - image is being used by running container")
}
Expand Down Expand Up @@ -243,7 +243,7 @@ func (s *DockerSuite) TestRmiContainerImageNotFound(c *check.C) {
dockerCmd(c, "rmi", "-f", imageIds[1])

// Try to remove the image of the running container and see if it fails as expected.
out, _, err := dockerCmdWithError("rmi", "-f", imageIds[0])
out, _, err := dockerCmdWithError("rmi", imageIds[0])
Copy link
Member

Choose a reason for hiding this comment

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

Same here

// The image of the running container should not be removed.
c.Assert(err, checker.NotNil)
c.Assert(out, checker.Contains, "image is being used by running container", check.Commentf("out: %s", out))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ func (s *DockerSuite) TestRunWithNanoCPUs(c *check.C) {
c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000")

out = inspectField(c, "test", "HostConfig.NanoCpus")
c.Assert(out, checker.Equals, "5e+08", check.Commentf("setting the Nano CPUs failed"))
c.Assert(out, checker.Equals, "500000000", check.Commentf("setting the Nano CPUs failed"))
out = inspectField(c, "test", "HostConfig.CpuQuota")
c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0"))
out = inspectField(c, "test", "HostConfig.CpuPeriod")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) {
// make sure task has been deployed.
waitAndAssert(c, defaultReconciliationTimeout,
d.CheckRunningTaskImages, checker.DeepEquals,
map[string]int{"busybox": len(services)})
map[string]int{"busybox:latest": len(services)})

for name, message := range services {
out, err := d.Cmd("service", "logs", name)
Expand Down
11 changes: 3 additions & 8 deletions components/engine/integration-cli/docker_cli_swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1730,18 +1730,13 @@ func (s *DockerSwarmSuite) TestSwarmServicePsMultipleServiceIDs(c *check.C) {

// Name Prefix
out, err = d.Cmd("service", "ps", "to")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, name1+".1")
c.Assert(out, checker.Contains, name1+".2")
c.Assert(out, checker.Contains, name1+".3")
c.Assert(out, checker.Contains, name2+".1")
c.Assert(out, checker.Contains, name2+".2")
c.Assert(out, checker.Contains, name2+".3")
c.Assert(err, checker.NotNil)
c.Assert(out, checker.Contains, "no such service: to")
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, use the test I wrote at the time of the PR, but which could not be merged upstream due to not being able to update the CLI; moby/moby@4242aec

That test also verifies the new behaviour


// Name Prefix (no hit)
out, err = d.Cmd("service", "ps", "noname")
c.Assert(err, checker.NotNil)
c.Assert(out, checker.Contains, "no such services: noname")
c.Assert(out, checker.Contains, "no such service: noname")

out, err = d.Cmd("service", "ps", id1)
c.Assert(err, checker.IsNil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *check.C) {

time.Sleep(20 * time.Second)

image := "busybox"
image := "busybox:latest"
// create a new global service again.
_, err = d1.Cmd("service", "create", "--no-resolve-image", "--name", serviceName, "--mode=global", "--network", networkName, image, "top")
c.Assert(err, checker.IsNil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (s *DockerSuite) TestUpdateWithNanoCPUs(c *check.C) {
c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000")

out = inspectField(c, "top", "HostConfig.NanoCpus")
c.Assert(out, checker.Equals, "5e+08", check.Commentf("setting the Nano CPUs failed"))
c.Assert(out, checker.Equals, "500000000", check.Commentf("setting the Nano CPUs failed"))
out = inspectField(c, "top", "HostConfig.CpuQuota")
c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0"))
out = inspectField(c, "top", "HostConfig.CpuPeriod")
Expand All @@ -308,7 +308,7 @@ func (s *DockerSuite) TestUpdateWithNanoCPUs(c *check.C) {

out, _ = dockerCmd(c, "update", "--cpus", "0.8", "top")
out = inspectField(c, "top", "HostConfig.NanoCpus")
c.Assert(out, checker.Equals, "8e+08", check.Commentf("updating the Nano CPUs failed"))
c.Assert(out, checker.Equals, "800000000", check.Commentf("updating the Nano CPUs failed"))
out = inspectField(c, "top", "HostConfig.CpuQuota")
c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0"))
out = inspectField(c, "top", "HostConfig.CpuPeriod")
Expand Down