You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, stargzifying an image fails with DIGEST_INVALID.
$ ./stargzify -upgrade 127.0.0.1:5000/ubuntu:18.04
2019/10/13 14:37:24 No matching credentials were found, falling back on anonymous
2019/10/13 14:37:49 DIGEST_INVALID: provided digest did not match uploaded content; map[Digest:sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Reason:map[]]
Especially when Writeing to the digester is slow, we can see this failure more frequently.
func (t*teeReader) Read(p []byte) (nint, errerror) {
n, err=t.r.Read(p)
// ***** Region A *****ifn>0 {
ifn, err:=t.w.Write(p[:n]); err!=nil {
returnn, err
}
}
return
}
Here, this TeeReader has the PipeReader as a reader and the digester as a writer.
In the Region A of the above, the write half(PipeWriter) is unblocked because reading from this PipeReader completes.
So the goroutine in the layer.Compressed() can immediately calculate the digest during the region A(before following t.w.Write() completes).
This race results in calculating an invalid(uncompleted) degest.
The text was updated successfully, but these errors were encountered:
Sometimes, stargzifying an image fails with DIGEST_INVALID.
Especially when
Write
ing to the digester is slow, we can see this failure more frequently.There is a race condition on the
digester
The method
layer.Compressed()
calculates the digest(withSum()
method) immediately after thePipeWriter
is unblocked.But even if the
PipeWriter
is unblocked, it isn't guaranteed that theTeeReader
completes to write the data to thedigester
.Accroding to the implementation of the TeeReader:
Here, this TeeReader has the
PipeReader
as a reader and thedigester
as a writer.In the Region A of the above, the write half(
PipeWriter
) is unblocked because reading from thisPipeReader
completes.So the goroutine in the
layer.Compressed()
can immediately calculate the digest during the region A(before followingt.w.Write()
completes).This race results in calculating an invalid(uncompleted) degest.
The text was updated successfully, but these errors were encountered: