Skip to content

Commit

Permalink
Prevent OOM exception caching layer blob
Browse files Browse the repository at this point in the history
  • Loading branch information
pditommaso committed Apr 3, 2022
1 parent c377edf commit 1309fd7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/groovy/io/seqera/docker/ContainerScanner.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,16 @@ class ContainerScanner {
return result
}

@Memoized // <-- prevent to load in memory the same blob more than once, otherwise it will throw a OOM exception
private byte[] readLayerBlob(Path location) {
return Files.readAllBytes(location)
}

synchronized protected Map layerBlob(String image) {
// store the layer blob in the cache
final type = "application/vnd.docker.image.rootfs.diff.tar.gzip"
final location = layerConfig.append.locationPath
final buffer = Files.readAllBytes(location)
final buffer = readLayerBlob(location)
final computed = RegHelper.digest(buffer)
final digest = layerConfig.append.gzipDigest
final size = layerConfig.append.gzipSize
Expand Down

0 comments on commit 1309fd7

Please sign in to comment.