Commit Graph

23 Commits

Author SHA1 Message Date
Miloslav Trmač bc6b35d0c9 Replace Set.Values with a non-allocating Set.All
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2025-03-12 20:16:03 +01:00
Miloslav Trmač f9d27e8c6d Add digest -> specific variant, annotation data to BIC
The cache implementations are recording both the base and specific compression variant;
CandidateLocations2 all call CandidateTemplateWithCompression to choose the
appropriate variants to return based on CandidateLocations2Options.

This way, neither the BIC implementations nor the transports are not responsible for
converting zstd:chunked entries to zstd entries if the user wants the latter.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-08-06 22:13:08 +02:00
Miloslav Trmač d09a403fd6 Introduce blobinfocache.DigestCompressorData
We will want to record more than a single alghoritm name. For now,
just introduce the structure and modify users, we'll add the new fields
later.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-08-05 20:47:31 +02:00
Miloslav Trmač efdc63990c Turn CandidateCompression into CandidateTemplateWithCompression
... and add CandidateWithLocation and CandidateWithUnknownLocation ,
so that the BIC implementations only need to deal with one value
instead of carrying around three; we will want to add one more,
and encapsulating them all into a single template will make it
transparent to the cache implementations.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-08-05 20:46:58 +02:00
Miloslav Trmač 757d726e12 Add TOC digest <-> uncompressed digest mapping to BIC
The new code is not called, so it should not change behavior
(apart from extending the BoltDB/SQLite schema).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-30 18:56:23 +02:00
Miloslav Trmač f1074950a1 Fix a comment
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-23 21:00:37 +02:00
Miloslav Trmač 7482d25260 Remove the no longer necessary BICReplacementCandidate2.CompressorName field
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-25 18:24:29 +01:00
Miloslav Trmač 537ec27530 Return algorithm and operation directly from BlobInfoCache implementations
The implementations (sharing the code in pkg/blobinfocache/internal/prioritize)
already need to look up the algorithm, so just return the value as a part of
a BICReplacementCandidate2, instead of looking it up again in the transport.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-25 18:24:25 +01:00
Miloslav Trmač 0b8ee226ac Move compression matching from the transport to the BIC lookup
The primary benefit is that we now filter the algorithms _before_ collecting
and trimming the list of candidates, i.e. if the most recent candidates
are not matching the requirements, CandidateLocations2 will return older
candidates instead of returning just some unwanted candidates which will be rejected.

This requires us to look up the actual compression in the BIC code, so this also
changes pkg/blobinfocache/internal/test to use real algorithm names.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-25 16:06:24 +01:00
Miloslav Trmač f97ab28e26 Pass blobinfocache.CandidateLocations2Options down in BIC implementations
... into candidateLocations and appendReplacementCandidates.

We will add more conditions there soon.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-25 16:06:10 +01:00
Miloslav Trmač 8bed236511 Introduce blobinfocache.CandidateLocations2Options
... and move the canSubstitute parameter to it.

We will add more options, and we well want to carry them around
as a unit.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-03-25 16:05:59 +01:00
Yaroslav Halchenko 498178b59a [DATALAD RUNCMD] run codespell throughout but ignore fail
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w || :",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2023-12-08 16:20:31 -05:00
Aditya R 539f9ee2f9
docker, BlobInfoCache: try to reuse compressed blobs when pushing across registries
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.

How to verify this ?

* Remove all images `buildah rmi --all` // needed so all new blobs can
  be tagged again in common bucket
* Remove any previous `blob-info-cache` by

```console
rm /home/<user>/.local/share/containers/cache/blob-info-cache-v1.boltdb
```

```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
```

Signed-off-by: Aditya R <arajan@redhat.com>
2023-11-01 11:18:41 +05:30
Miloslav Trmač 5c00606081 Add Open / Close methods to BlobInfoCache2
Cache implementations still must work without Open/Close being called
because the v1 interface is public, but we can call Open/Close in copy.Image
to amortize the overhead cost a bit.

Currently all Open/Close methods are empty, so this should not change
behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-09-05 22:48:33 +02:00
Miloslav Trmač 962d2e3bc7 Add a warning in the memory backend about compressor inconsistency
The BoltDB backend already warns, so be consistent.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-09-05 22:48:24 +02:00
Miloslav Trmač e59ae40173 Clarify documentation of how we record compression
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-09-05 22:48:21 +02:00
Miloslav Trmač a20400994c Add comment punctuation
golangci-lint linter: godot

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-06 21:23:52 +01:00
Miloslav Trmač 7797bbcafb Add internal/set, use it
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-02-03 18:33:53 +01:00
Josh Soref 111bf164be Spelling
* about
* appropriate
* busybox
* candidate
* candidates
* certificate
* config
* configuration
* containers
* decompression
* directory
* does-not/match
* does/not/exist
* doesnot
* doesnotexist
* exemplary
* garbage
* gzipped
* identify
* initially
* kubernetes
* length
* marshaling
* maximum
* mybetaproduct
* overridden
* parameter
* permissive
* policyconfiguration
* protocols
* reference
* referenceable
* requirement
* response
* simultaneously
* slashes
* subobject
* successfully
* this
* uncompressed
* unmarshaled
* unmarshaler
* unmarshaling it
* unmarshaller
* valid

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2021-03-23 14:37:37 -04:00
Nalin Dahyabhai 5364600209 blobinfocache: track compression types for locations
Extend the blob info cache to also cache the name of the type of
compression used on a blob that we've seen, or specific values that
indicate that we know the blob was not compressed, or that we don't
know whether or not it was compressed.

New methods for adding known blob-compression pairs and reading
candidate locations including compression information are part of a new
internal BlobInfoCache2 interface which the library's BlobInfoCache
implementors also implement.

When we copy a blob, try to record the state of compression for the
source blob, and if we applied any changes, the blob we produced.

Make sure that when TryReusingBlob successfully uses a blob from the
blob info cache, that it provides compression information in the
BlobInfo that it returns, so that manifests can be updated to describe
layers using the correct MIME types.

When attempting to write a manifest, if a manifest can't be written
because layers were compressed using an algorithm which can't be
expressed using that manifest type, continue on to trying other manifest
formats.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-01-16 13:58:15 -05:00
Miloslav Trmač 7d9cde7252 Update to major version v5
> gomove github.com/containers/image/v4 github.com/containers/image/v5
+ a manual edit of go.mod

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2019-10-25 22:27:45 +02:00
Miloslav Trmač e568c94ef3 Correctly use a c/image/v4 module namespace
... so that major-version-aware Go module import
(as opposed to vX.Y.Z+incompatible, which does not allow different
packages to use different versions) works right.

Also requires adding some more GO111MODULE=on options to Makefile.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2019-10-03 22:54:27 +02:00
W. Trevor King d545a196c9 pkg/blobinfocache: Split implementations into subpackages
This allows consumers who don't need the defaulting logic to pick
their desired implementation without pulling in unrelated
dependencies.  For example, it allows you to consume the memory or
NoCache implementations without pulling in github.com/boltdb.

I'd initially included blobinfocache wrappers to preserve backwards
compatibility with the old API while consumers updated to the new
APIs, but Miloslav said we don't have any backwards-compatibility
commitments at the moment [1].

Having single-implementation subpackages also allows for more generic
names (e.g. NewMemoryCache is now just New), because memory.New is
clear enough while memory.NewMemoryCache stutters.

[1]: https://github.com/containers/image/pull/602#issuecomment-471570789

Signed-off-by: W. Trevor King <wking@tremily.us>
2019-03-12 13:24:14 -07:00