mirror of https://github.com/docker/docs.git
Merge pull request #2910 from codeaholics/wait-for-simultaneous-pull
Allow multiple clients to pull the same tag simultaneously
This commit is contained in:
commit
5fe5055bd9
13
server.go
13
server.go
|
@ -985,7 +985,17 @@ func (srv *Server) ImagePull(localName string, tag string, out io.Writer, sf *ut
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err := srv.poolAdd("pull", localName+":"+tag); err != nil {
|
|
||||||
|
out = utils.NewWriteFlusher(out)
|
||||||
|
|
||||||
|
c, err := srv.poolAdd("pull", localName+":"+tag)
|
||||||
|
if err != nil {
|
||||||
|
if c != nil {
|
||||||
|
// Another pull of the same repository is already taking place; just wait for it to finish
|
||||||
|
out.Write(sf.FormatStatus("", "Repository %s already being pulled by another client. Waiting.", localName))
|
||||||
|
<-c
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer srv.poolRemove("pull", localName+":"+tag)
|
defer srv.poolRemove("pull", localName+":"+tag)
|
||||||
|
@ -1001,7 +1011,6 @@ func (srv *Server) ImagePull(localName string, tag string, out io.Writer, sf *ut
|
||||||
localName = remoteName
|
localName = remoteName
|
||||||
}
|
}
|
||||||
|
|
||||||
out = utils.NewWriteFlusher(out)
|
|
||||||
err = srv.pullRepository(r, out, localName, remoteName, tag, endpoint, sf, parallel)
|
err = srv.pullRepository(r, out, localName, remoteName, tag, endpoint, sf, parallel)
|
||||||
if err == registry.ErrLoginRequired {
|
if err == registry.ErrLoginRequired {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue