Skip to content

Commit

Permalink
Fix unresolved container cache
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Feb 11, 2023
1 parent b3e464c commit f26dbba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, List<String>> headers = httpRequest.headers.asMap() as Map<String, List<String>>
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f26dbba

Please sign in to comment.