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 <[email protected]>
  • Loading branch information
flouthoc committed Nov 14, 2023
1 parent 8391324 commit ea1543a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/blobcache.bats
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@ 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 podman run --rm --mount type=bind,src=${TEST_SCRATCH_DIR}/test.auth,target=/test.auth,Z --net host quay.io/skopeo/stable copy --preserve-digests --authfile=/test.auth --tls-verify=false docker://registry.fedoraproject.org/fedora-minimal docker://localhost:${REGISTRY_PORT}/test

# Clear local image and c/image's blob-info-cache
run_buildah rmi --all -f
if is_rootless;
then
run rm $HOME/.local/share/containers/cache/blob-info-cache-v1.sqlite
assert "$status" -eq 0 "status of `run rm $HOME/.local/share/containers/cache/blob-info-cache-v1.sqlite` must be 0"
else
run rm /var/lib/containers/cache/blob-info-cache-v1.sqlite
assert "$status" -eq 0 "status of `run rm /var/lib/containers/cache/blob-info-cache-v1.sqlite` must be 0"
fi

# 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 images -a --format '{{.ID}}'
cid=$output
run_buildah --log-level debug push --tls-verify=false --authfile ${TEST_SCRATCH_DIR}/test.auth $cid 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 ea1543a

Please sign in to comment.