Allow multiple clients to pull the same tag simultaneously
If two clients simultaneously try to pull the same tag, there was a race whereby one would succeed and the second would generate an error. Now, the second simply waits for the first to complete.
This commit is contained in:
parent
6344e6f258
commit
ae474e05f5
11
server.go
11
server.go
|
@ -985,8 +985,14 @@ func (srv *Server) ImagePull(localName string, tag string, out io.Writer, sf *ut
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := srv.poolAdd("pull", localName+":"+tag); err != nil {
|
||||
return err
|
||||
|
||||
out = utils.NewWriteFlusher(out)
|
||||
|
||||
if c, err := srv.poolAdd("pull", localName+":"+tag); err != 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
|
||||
}
|
||||
defer srv.poolRemove("pull", localName+":"+tag)
|
||||
|
||||
|
@ -1001,7 +1007,6 @@ func (srv *Server) ImagePull(localName string, tag string, out io.Writer, sf *ut
|
|||
localName = remoteName
|
||||
}
|
||||
|
||||
out = utils.NewWriteFlusher(out)
|
||||
err = srv.pullRepository(r, out, localName, remoteName, tag, endpoint, sf, parallel)
|
||||
if err == registry.ErrLoginRequired {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue