1
0
mirror of https://github.com/quay/quay.git synced 2025-04-18 10:44:06 +03:00

georeplication: Enqueue blobs for replication on manifest list pushes (PROJQUAY-5256) (#2212)

* georeplication: Enqueue blobs for replication on manifest list pushes (PROJQUAY-5256)
Previously, blob replication was only queued when normal manifests were pushed to the registry. This created problems with manifest lists who contain child manifests whose blobs were never queued. The end result was a huge discrepancy of storage usage between different defined storage engines.
With this fix, blobs will always be enqueued for replication regardless of the image type.

* Update `black` in `requirements-dev.txt` to match the version we use on Github
This commit is contained in:
Ivan Bazulic 2023-09-12 13:58:08 -04:00 committed by GitHub
parent f013a27b6f
commit abfde5b9d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View File

@ -261,6 +261,16 @@ def write_manifest_by_tagname(namespace_name, repo_name, manifest_ref):
return _write_manifest_and_log(namespace_name, repo_name, manifest_ref, parsed)
def _enqueue_blobs_for_replication(manifest, storage, namespace_name):
blobs = registry_model.get_manifest_local_blobs(manifest, storage)
if blobs is None:
logger.error("Could not lookup blobs for manifest `%s`", manifest.digest)
else:
with queue_replication_batch(namespace_name) as queue_storage_replication:
for blob_digest in blobs:
queue_storage_replication(blob_digest)
@v2_bp.route(MANIFEST_DIGEST_ROUTE, methods=["PUT"])
@disallow_for_account_recovery_mode
@parse_repository_name()
@ -301,6 +311,10 @@ def write_manifest_by_digest(namespace_name, repo_name, manifest_ref):
image_pushes.labels("v2", 201, manifest.media_type).inc()
# Queue all blob manifests for replication.
if features.STORAGE_REPLICATION:
_enqueue_blobs_for_replication(manifest, storage, namespace_name)
return Response(
"OK",
status=201,
@ -372,15 +386,9 @@ def _write_manifest_and_log(namespace_name, repo_name, tag_name, manifest_impl):
namespace_name, repo_name, tag_name, manifest_impl
)
# Queue all blob manifests for replication.
# Queue all blob manifests for replication
if features.STORAGE_REPLICATION:
blobs = registry_model.get_manifest_local_blobs(manifest, storage)
if blobs is None:
logger.error("Could not lookup blobs for manifest `%s`", manifest.digest)
else:
with queue_replication_batch(namespace_name) as queue_storage_replication:
for blob_digest in blobs:
queue_storage_replication(blob_digest)
_enqueue_blobs_for_replication(manifest, storage, namespace_name)
track_and_log("push_repo", repository_ref, tag=tag_name)
spawn_notification(repository_ref, "repo_push", {"updated_tags": [tag_name]})

View File

@ -2,7 +2,7 @@
git+https://github.com/quay/mockldap.git@136253ca136fc7898944a4b37893a99440f7335e#egg=mockldap
git+https://github.com/jarus/flask-testing.git@17f19d7fee0e1e176703fc7cb04917a77913ba1a#egg=Flask_Testing
bencode.py==2.1.0
black==21.12b0
black==22.3.0
flake8==4.0.1
boto3-stubs==1.14.9.0
fakeredis==1.6.1