Have blob mounting use the blob cache

This commit is contained in:
Joseph Schorr 2019-02-14 13:06:18 -05:00
parent f75f315037
commit 69c306e740
2 changed files with 24 additions and 2 deletions

View file

@ -132,7 +132,8 @@ def _try_to_mount_blob(repository_ref, mount_blob_digest):
return None
# Lookup if the mount blob's digest exists in the repository.
mount_blob = registry_model.get_repo_blob_by_digest(from_repository_ref, mount_blob_digest)
mount_blob = registry_model.get_cached_repo_blob(model_cache, from_namespace, from_repo_name,
mount_blob_digest)
if mount_blob is None:
logger.debug('Blob `%s` under repository `%s` not found', mount_blob_digest, from_repo)
return None

View file

@ -1204,7 +1204,8 @@ def test_blob_mounting(push_user, push_namespace, push_repo, mount_repo_name, ex
options.mount_blobs = {'sha256:' + hashlib.sha256(image.bytes).hexdigest(): mount_repo_name
for image in basic_images}
manifest_protocol.push(liveserver_session, 'devtable', 'newrepo', 'latest', basic_images,
manifest_protocol.push(liveserver_session, 'devtable', 'newrepo', 'latest',
basic_images,
credentials=('devtable', 'password'),
options=options,
expected_failure=expected_failure)
@ -1215,6 +1216,26 @@ def test_blob_mounting(push_user, push_namespace, push_repo, mount_repo_name, ex
credentials=('devtable', 'password'))
def test_blob_mounting_with_empty_layers(manifest_protocol, pusher, puller, images_with_empty_layer,
liveserver_session, app_reloader):
# Push an image so we can attempt to mount it.
pusher.push(liveserver_session, 'devtable', 'simple', 'latest', images_with_empty_layer,
credentials=('devtable', 'password'))
# Push again, trying to mount the image layer(s) from the mount repo.
options = ProtocolOptions()
options.scopes = ['repository:devtable/newrepo:push,pull',
'repository:%s:pull' % ('devtable/simple')]
options.mount_blobs = {'sha256:' + hashlib.sha256(image.bytes).hexdigest(): 'devtable/simple'
for image in images_with_empty_layer}
options.skip_head_checks = True
manifest_protocol.push(liveserver_session, 'devtable', 'newrepo', 'latest',
images_with_empty_layer,
credentials=('devtable', 'password'),
options=options)
def get_robot_password(api_caller):
api_caller.conduct_auth('devtable', 'password')
resp = api_caller.get('/api/v1/organization/buynlarge/robots/ownerbot')