Skip to content

Commit fc89dca

Browse files
renedeitch
authored andcommitted
zedUpload: Fallback to maxsize on HEAD request error
Some registries, like AWS ECR do not respect the OCI spec regarding HEAD requests to get the size of a layer (blob), leading to errors like the following: error could not get layer size XXXXX: HEAD XXXXX: unexpected status code 403 Forbidden (HEAD responses have no body, use GET for details) This commit provides a workaround, falling back size to maxsize if the layer's size cannot be retrieved. This fix was tested with the faulty registry and it works. Signed-off-by: Renê de Souza Pinto <[email protected]>
1 parent 850283d commit fc89dca

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

zedUpload/ociutil/oci.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ func PullBlob(registry, repo, hash, localFile, username, apiKey string, maxsize
137137
}
138138
size, err = layer.Size()
139139
if err != nil {
140-
return 0, "", fmt.Errorf("could not get layer size %s: %v", ref.String(), err)
140+
// Registry didn't reply correctly the HEAD request for size, fallback to the maxsize
141+
size = maxsize
142+
logrus.Errorf("could not get layer size %s: %v, trying maxsize %d ...", ref.String(), err, size)
141143
}
142144
}
143145

0 commit comments

Comments
 (0)