Skip to content

Commit

Permalink
blobcacheinfo,test: blobs must be resued when pushing across registry
Browse files Browse the repository at this point in the history
It seems we try to reuse blobs only for the specified registry, however
we can have valid known compressed digests across registry as well
following pr attempts to use that by doing following steps.

* `CandidateLocations2` now processes all known blobs and appends them
  to returned candidates at the lowest priority. As a result when
`TryReusingBlob` tries to process these candidates and if the blobs
filtered by the `Opaque` set by the `transport` fail to match then
attempt is made against all known blobs (ones which do not belong to the
current registry).

* Increase the sample set of potential blob reuse to all known
  compressed digests , also involving the one which do not belong to
current registry.

* If a blob is found match it against the registry where we are
  attempting to push. If blob is already there consider it a `CACHE
HIT!` and reply skipping blob, since its already there.

----

```console
$ skopeo copy docker://registry.fedoraproject.org/fedora-minimal docker://quay.io/fl/test:some-tag
$ buildah pull registry.fedoraproject.org/fedora-minimal
$ buildah tag registry.fedoraproject.org/fedora-minimal quay.io/fl/test
$ buildah push quay.io/fl/test
```

```console
Getting image source signatures
Copying blob a3497ca15bbf skipped: already exists
Copying config f7e02de757 done
Writing manifest to image destination
Storing signatures
```

Testing: containers/image#1645

Signed-off-by: Aditya R <arajan@redhat.com>
  • Loading branch information
flouthoc committed Nov 10, 2023
1 parent bf3b55b commit a42777c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/blobcache.bats
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,29 @@ function _check_matches() {
expect_output --from="$unmatched" "$5" "$6 should not match"
}

# Integration test for https://github.com/containers/image/pull/1645
@test "blobcache: blobs must be reused when pushing across registry" {
start_registry
run_buildah login --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth --username testuser --password testpassword localhost:${REGISTRY_PORT}
run_buildah pull registry.fedoraproject.org/fedora-minimal
run_buildah tag registry.fedoraproject.org/fedora-minimal localhost:${REGISTRY_PORT}/test
run_buildah --log-level debug push --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth localhost:${REGISTRY_PORT}/test docker://localhost:${REGISTRY_PORT}/test
# must not contain "Skipping blob" since push must happen
assert "$output" !~ "Skipping blob"
run_buildah --log-level debug push --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth localhost:${REGISTRY_PORT}/test docker://localhost:${REGISTRY_PORT}/test
expect_output --substring "Skipping blob"

# Clear local image and c/image's blob-info-cache
run_buildah rmi --all -f
run rm /var/lib/containers/cache/blob-info-cache-v1.sqlite

# In first push blob must be skipped after vendoring https://github.com/containers/image/pull/1645
run_buildah pull registry.fedoraproject.org/fedora-minimal
run_buildah tag registry.fedoraproject.org/fedora-minimal localhost:${REGISTRY_PORT}/test
run_buildah --log-level debug push --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth localhost:${REGISTRY_PORT}/test docker://localhost:${REGISTRY_PORT}/test
expect_output --substring "Skipping blob"
}

@test "blobcache-commit" {
blobcachedir=${TEST_SCRATCH_DIR}/cache
mkdir -p ${blobcachedir}
Expand Down

0 comments on commit a42777c

Please sign in to comment.