diff --git a/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy b/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy index c5adfa59e..78c07475e 100644 --- a/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy @@ -150,14 +150,26 @@ class RegistryProxyController { } protected DigestStore manifestForPath(RoutePath route, HttpRequest httpRequest) { - def manifest = storage.getManifest(route.targetPath) + // when the request contains a wave token and the manifest is specified + // using a container 'tag' instead of a 'digest' the request path is used as storage key + // because the target container path could be not unique (multiple wave containers request + // could shared the same target container with a different configuration request) + final unsolvedContainer = route.token && route.isTag() + final key = unsolvedContainer ? httpRequest.path : route.targetPath + // check if there's cached manifest + final manifest = storage.getManifest(key) if (manifest.present) { - log.debug "Manifest cache hit ==> $route.path" + log.debug "Manifest cache hit ==> $key" return manifest.get() } - + // resolve the manifest using the proxy service Map> headers = httpRequest.headers.asMap() as Map> - return proxyService.handleManifest(route, headers) + final result = proxyService.handleManifest(route, headers) + // cache the digest with the original route path to avoid to resolve one more time + if( result && unsolvedContainer ) { + storage.saveManifest(key, result) + } + return result } static protected MutableHttpResponse badRequest(String message) { diff --git a/src/main/groovy/io/seqera/wave/core/RegistryProxyService.groovy b/src/main/groovy/io/seqera/wave/core/RegistryProxyService.groovy index ccb33d607..4c1dcb7c7 100644 --- a/src/main/groovy/io/seqera/wave/core/RegistryProxyService.groovy +++ b/src/main/groovy/io/seqera/wave/core/RegistryProxyService.groovy @@ -98,13 +98,7 @@ class RegistryProxyService { // find out the target digest for the request final target = "$route.registry/v2/${route.image}/manifests/${digest.target}" - final entry = storage.getManifest(target).orElse(null) - - // cache the digest with the original route path to avoid to resolve one more time - if( entry && route.isManifest() && route.isTag() && route.token ) { - storage.saveManifest(route.targetPath, entry) - } - return entry + return storage.getManifest(target).orElse(null) } protected void updateContainerRequest(RoutePath route, ContainerDigestPair digest) {