mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 13:41:36 +00:00
Merge pull request #15646 from tonistiigi/15589-pull-cancellation
Fix pull on client disconnect
This commit is contained in:
@@ -369,3 +369,40 @@ func (s *DockerTrustSuite) TestTrustedPullWithExpiredSnapshot(c *check.C) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Test that pull continues after client has disconnected. #15589
|
||||
func (s *DockerTrustSuite) TestPullClientDisconnect(c *check.C) {
|
||||
testRequires(c, Network)
|
||||
|
||||
repoName := "hello-world:latest"
|
||||
|
||||
dockerCmdWithError("rmi", repoName) // clean just in case
|
||||
|
||||
pullCmd := exec.Command(dockerBinary, "pull", repoName)
|
||||
|
||||
stdout, err := pullCmd.StdoutPipe()
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
err = pullCmd.Start()
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
// cancel as soon as we get some output
|
||||
buf := make([]byte, 10)
|
||||
_, err = stdout.Read(buf)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
err = pullCmd.Process.Kill()
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
maxAttempts := 20
|
||||
for i := 0; ; i++ {
|
||||
if _, _, err := dockerCmdWithError("inspect", repoName); err == nil {
|
||||
break
|
||||
}
|
||||
if i >= maxAttempts {
|
||||
c.Fatal("Timeout reached. Image was not pulled after client disconnected.")
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user