-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
copy/multiple: instanceCopyCopy honor UpdateCompressionAlgorithms
#2047
copy/multiple: instanceCopyCopy honor UpdateCompressionAlgorithms
#2047
Conversation
@mtrmac PTAL once merged I will vendor this into containers/skopeo#2047 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider a simple skopeo copy --format oci
of an existing image: In that case we should preserve the original blobs (or reuse blobs at destination, if possible), and add the OCI annotations.
So while copy --dest-compress-format zstd
is the most salient use case, I think this should work by collecting compression algorithms from all copies.
- IIRC the
BlobInfo
returned fromcopyLayer
always contains an algorithm, orUnknown
/Uncompressed
. - Then,
copyLayers
can deduplicate the values into a set; and return that value. copySingleImage
can return the relevant algorithms (optionally add acopySingleImageResult struct
so that we don’t have that many unnamed return values)- and that can then be used for
ListEdit
(If the source is not already OCI, it is probably v2s1 or v2s2, which only support gzip, so that seems like a non-issue. But the copy can reuse zstd blobs at the destination, creating an OCI image that is mixed gzip + Zstd, or possibly Zstd-only.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think the shortcut in OptimizeDestinationImageAlreadyExists
must not be taken if require…Match
.
Ugh, the
I think 3. is the cleanest way to do this right now; and if we ever replace the “conceptually-misplaced heuristic” (which serves as a nice example that technical debt never goes away on its own) with a proper |
6988b8e
to
6571477
Compare
@mtrmac I have not updated tests yet but this is what I am thinking. WDYT ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick pass, not a careful review — so far all the primary design points look correct.
copy/single.go
Outdated
} | ||
|
||
func removeDuplicateCompression(algos []compressiontypes.Algorithm) []compressiontypes.Algorithm { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be built on internal/set.Set
instead of manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… and probably inlined in the two loops that collect the data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set.Add(
ensures that no duplicates are there ( I have added a test to verify that ) however compression.Algorithm
is not a comparable
which is required by Set
hence I have created a Set
using string
i.e compression.Algorithm.Name()
and its working fine.
Later I'm using AlgorithmsByNames
to retrieve a slice of Algorithms
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A full review now — ~nothing new.
f9f8cc5
to
0b7e0b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Last comments on a debug log and a misplaced comment.
If `UpdateCompressionAlgorithms` is set then `Annotations` map must be initialized if its not set. Signed-off-by: Aditya R <[email protected]>
Modifies `copy/single` to correctly use the feature from containers#2023, that is if compression is changed blob must be resued only if it matches required compression. Signed-off-by: Aditya R <[email protected]>
imagecopier implementes feature for requireCompressionFormatMatch refactor `copySingleImage` to accept that as an argument. Signed-off-by: Aditya R <[email protected]>
0b7e0b5
to
a40cb55
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise, feel free to merge without another round.
Users can set compression formats while performing `copy` in such cases `instanceCopyCopy` must honor UpdateCompressionAlgorithms. Signed-off-by: Aditya R <[email protected]>
Verifies if no duplicates are kept when `.Values()` is used to return slice. Signed-off-by: Aditya R <[email protected]>
a40cb55
to
bb006b3
Compare
I don't have merge access, @containers/image-maintainers PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Needed By: containers/skopeo#2047
Users can set compression formats while performing
copy
in such casesinstanceCopyCopy
must honor UpdateCompressionAlgorithms.copy/single: set requiredCompression if compressionFormat is changed
copy/single
to correctly use the feature fromblob:
TryReusingBlobWithOptions
considerRequiredCompression
if set #2023, that is if compression ischanged blob must be resued only if it matches required compression.
UpdateCompressionAlgorithms
is set thenAnnotations
map must beinitialized if its not set.
Integration tests for
e2e
feature added here: containers/skopeo#2047 (comment)