Skip to content
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: replicate manifest list instances with zstd compression on ReplicateZstd:true #1875

Closed
wants to merge 1 commit into from

Conversation

flouthoc
Copy link
Contributor

@flouthoc flouthoc commented Mar 7, 2023

Extends copy to support a new operation when copying a manifest list from src to dest i.e ReplicateZstd. When ReplicateZstd is set to true and copy operation is performed for a manifest list then a copy for all the image will be created and added to the manifest list with compression as zstd and appropriate annotation i.e "io.github.containers.compression.zstd": "true" will be set on each image.

The CLI tools must use ReplicateZstd flag in order to use this new feature.

Example with skopeo

  • Here src docker://localhost:5000/list only contains two gzip compressed image but while copying skopeo will replicated zstd instances as well
$ ./skopeo copy --all --src-tls-verify=false --dest-tls-verify=false docker://localhost:5000/list docker://localhost/list
Getting image list signatures
Copying 4 of 4 images in list
Copying image sha256:915468dd2aae5e243dbb8d38afc445e8971f7076deade33b81128fdfa42a17a4 (1/4)
Getting image source signatures
Copying blob f5763aacc581 done
Copying blob 0aa932d79126 done
Copying config ba4505248d done
Writing manifest to image destination
Storing signatures
Copying image sha256:f08c3c433a2c73ba643800326a825493a862a438857a227f01ae63e0aa6f3896 (2/4)
Getting image source signatures
Copying blob 1d86523f4719 done
Copying blob 0aa932d79126 done
Copying config 1ea47b71b3 done
Writing manifest to image destination
Storing signatures
Copying image sha256:915468dd2aae5e243dbb8d38afc445e8971f7076deade33b81128fdfa42a17a4 (3/4)
Getting image source signatures
Copying blob f5763aacc581 done
Copying blob 0aa932d79126 done
Copying config ba4505248d done
Writing manifest to image destination
Storing signatures
Copying image sha256:f08c3c433a2c73ba643800326a825493a862a438857a227f01ae63e0aa6f3896 (5/4)
Getting image source signatures
Copying blob 1d86523f4719 done
Copying blob 0aa932d79126 done
Copying config 1ea47b71b3 done
Writing manifest to image destination
Storing signatures
Writing manifest list to image destination
Storing list signatures
  • output
$ skopeo inspect --tls-verify=false --raw docker://localhost/list | jq
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "manifests": [
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "digest": "sha256:915468dd2aae5e243dbb8d38afc445e8971f7076deade33b81128fdfa42a17a4",
      "size": 759,
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    },
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "digest": "sha256:f08c3c433a2c73ba643800326a825493a862a438857a227f01ae63e0aa6f3896",
      "size": 759,
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    },
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "digest": "sha256:2a8521136269bf9113cdf9088288a07cce52850d15b958b43aad6da5dc0115fb",
      "size": 759,
      "annotations": {
        "io.github.containers.compression.zstd": "true"
      },
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    },
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "digest": "sha256:4feb1d9bf33b2f771dbee9b5ece774f1b6b4dc49b82bce686e47afd13686dcb5",
      "size": 759,
      "annotations": {
        "io.github.containers.compression.zstd": "true"
      },
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    }
  ]
}

@flouthoc flouthoc changed the title copy: replicate manifest list instances with zstd compression on ReplicateZstd: true copy: replicate manifest list instances with zstd compression on ReplicateZstd:true Mar 7, 2023
@flouthoc flouthoc marked this pull request as draft March 7, 2023 10:01
@flouthoc flouthoc marked this pull request as ready for review March 7, 2023 10:56
Extends copy to support a new operation when copying a manifest list
from `src` to `dest` i.e `ReplicateZstd`. When `ReplicateZstd` is set to
`true` and copy operation is performed for a manifest list then a copy
for all the image will be created and added to the manifest list with
compression as `zstd` and appropriate annotation i.e
`"io.github.containers.compression.zstd": "true"` will be set on each
image.

The CLI tools must use `ReplicateZstd` flag in order to use this new
feature.

Example with skopeo

* Here src `docker://localhost:5000/list` only contains two gzip
  compressed image but while copying skopeo will replicated zstd
instances as well

```console
$ ./skopeo copy --all --src-tls-verify=false --dest-tls-verify=false docker://localhost:5000/list docker://localhost/list
Getting image list signatures
Copying 4 of 4 images in list
Copying image sha256:915468dd2aae5e243dbb8d38afc445e8971f7076deade33b81128fdfa42a17a4 (1/4)
Getting image source signatures
Copying blob f5763aacc581 done
Copying blob 0aa932d79126 done
Copying config ba4505248d done
Writing manifest to image destination
Storing signatures
Copying image sha256:f08c3c433a2c73ba643800326a825493a862a438857a227f01ae63e0aa6f3896 (2/4)
Getting image source signatures
Copying blob 1d86523f4719 done
Copying blob 0aa932d79126 done
Copying config 1ea47b71b3 done
Writing manifest to image destination
Storing signatures
Copying image sha256:915468dd2aae5e243dbb8d38afc445e8971f7076deade33b81128fdfa42a17a4 (3/4)
Getting image source signatures
Copying blob f5763aacc581 done
Copying blob 0aa932d79126 done
Copying config ba4505248d done
Writing manifest to image destination
Storing signatures
Copying image sha256:f08c3c433a2c73ba643800326a825493a862a438857a227f01ae63e0aa6f3896 (5/4)
Getting image source signatures
Copying blob 1d86523f4719 done
Copying blob 0aa932d79126 done
Copying config 1ea47b71b3 done
Writing manifest to image destination
Storing signatures
Writing manifest list to image destination
Storing list signatures
```

* output

```json
$ skopeo inspect --tls-verify=false --raw docker://localhost/list | jq
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "manifests": [
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "digest": "sha256:915468dd2aae5e243dbb8d38afc445e8971f7076deade33b81128fdfa42a17a4",
      "size": 759,
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    },
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "digest": "sha256:f08c3c433a2c73ba643800326a825493a862a438857a227f01ae63e0aa6f3896",
      "size": 759,
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    },
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "digest": "sha256:2a8521136269bf9113cdf9088288a07cce52850d15b958b43aad6da5dc0115fb",
      "size": 759,
      "annotations": {
        "io.github.containers.compression.zstd": "true"
      },
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    },
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "digest": "sha256:4feb1d9bf33b2f771dbee9b5ece774f1b6b4dc49b82bce686e47afd13686dcb5",
      "size": 759,
      "annotations": {
        "io.github.containers.compression.zstd": "true"
      },
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    }
  ]
}
```

Signed-off-by: Aditya R <[email protected]>
@flouthoc
Copy link
Contributor Author

flouthoc commented Mar 7, 2023

@mtrmac @giuseppe PTAL my first iteration approach on this one. ( also just wondering if skopeo failure are because of the PR or unrelated )

@@ -155,6 +155,9 @@ type Options struct {
// if this is set to OptionalBoolUndefined (which is the default behavior, and recommended for most callers).
// This only affects CopySystemImage.
PreferGzipInstances types.OptionalBool
// While Copying entire manifest list from src to dest, allow each image to be replicated with compression as zstd
// and appropriate annotations configured for each newly compressed image the manifest list.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit of a nit

Suggested change
// and appropriate annotations configured for each newly compressed image the manifest list.
// and appropriate annotations configured for each newly compressed image in the manifest list.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I think this is a good top-level view of what will be necessary, but let’s build the infrastructure in smaller steps.

copy/copy.go Show resolved Hide resolved
copy/copy.go Show resolved Hide resolved
copy/copy.go Show resolved Hide resolved
copy/copy.go Show resolved Hide resolved
copy/copy.go Show resolved Hide resolved
copy/copy.go Show resolved Hide resolved
internal/manifest/list.go Show resolved Hide resolved
internal/manifest/oci_index.go Show resolved Hide resolved
internal/manifest/oci_index.go Show resolved Hide resolved
internal/manifest/oci_index.go Show resolved Hide resolved
@mtrmac
Copy link
Collaborator

mtrmac commented Mar 7, 2023

( also just wondering if skopeo failure are because of the PR or unrelated )

It’s almost certainly this PR. (I’m afraid the output is very noisy, but search for FAIL:):

    --- FAIL: TestCopy/TestCopyNoneWithManifestList (0.30s)
        utils.go:68: Running skopeo copy --multi-arch=index-only docker://registry.fedoraproject.org/fedora-minimal dir:/tmp/TestCopyTestCopyNoneWithManifestList3756920598/001
        utils.go:70: 
            	Error Trace:	/var/tmp/go/src/github.com/containers/skopeo/integration/utils.go:70
            	            				/var/tmp/go/src/github.com/containers/skopeo/integration/copy_test.go:148
            	Error:      	Received unexpected error:
            	            	exit status 2
            	Test:       	TestCopy/TestCopyNoneWithManifestList
            	Messages:   	Getting image list signatures
            	            	Copying 0 of 0 images in list
            	            	panic: runtime error: index out of range [0] with length 0
            	            	
            	            	goroutine 1 [running]:
            	            	github.com/containers/image/v5/copy.(*copier).copyMultipleImages(0xc0001e6480, {0x55649775b8b8, 0xc000126000}, 0xc0006665a0?, 0xc0007116c8, 0x1924924?)
            	            		/var/tmp/go/src/github.com/containers/skopeo/vendor/github.com/containers/image/v5/copy/copy.go:528 +0x231f
            	            	github.com/containers/image/v5/copy.Image({0x55649775b8b8, 0xc000126000}, 0x0?, {0x5564977611d8, 0xc0002e4c20}, {0x556497761238?, 0xc0003b8060?}, 0xc000149078?)

copy/copy.go Show resolved Hide resolved
flouthoc added a commit to flouthoc/image that referenced this pull request Mar 8, 2023
As discussed containers#1875 it is
suggested to keep the two implementation in different files since there
independent complexity is increasing.

Signed-off-by: Aditya R <[email protected]>
@mtrmac mtrmac added the kind/feature A request for, or a PR adding, new functionality label Apr 5, 2023
@mtrmac
Copy link
Collaborator

mtrmac commented Jul 25, 2023

This will be fully implemented when #1987 is merged, closing this prototype.

Thanks for doing all that work!

@mtrmac mtrmac closed this Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for, or a PR adding, new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants