Skip to content

add soci to nerdctl image convert [DO NOT MERGE] #4300

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coderbirju
Copy link
Contributor

@coderbirju coderbirju commented May 28, 2025

This PR adds functionality to support nerdctl image convert using soci.
This follows the new soci convert feature.

Note: the tests currently skip if the soci version is <0.10.0 (which is the expected version that will contain the convert feature) and this PR will be marked DO NOT MERGE till then.

cc: @Shubhranshu153 @swagatbora90 @AkihiroSuda

@coderbirju coderbirju changed the title add soci convert feature [DO NOT MERGE] add soci to nerdctl image convert [DO NOT MERGE] May 28, 2025
Signed-off-by: Arjun Raja Yogidas <[email protected]>
@coderbirju coderbirju marked this pull request as ready for review June 3, 2025 20:11
@@ -45,3 +45,18 @@ For images that already have SOCI indices, see https://gallery.ecr.aws/soci-work
nerdctl push --snapshotter=soci --soci-span-size=2097152 --soci-min-layer-size=20971520 public.ecr.aws/my-registry/my-repo:latest
```
--soci-span-size and --soci-min-layer-size are two properties to customize the SOCI index. See [Command Reference](https://github.com/containerd/nerdctl/blob/377b2077bb616194a8ef1e19ccde32aa1ffd6c84/docs/command-reference.md?plain=1#L773) for further details.


## Enable SOCI for `nerdctl image convert`
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs documentation to distinguish soci option with push vs convert and some details about v1, v2 indexes

@@ -960,6 +960,11 @@ Flags:
- `--oci` : convert Docker media types to OCI media types
- `--platform=<PLATFORM>` : convert content for a specific platform
- `--all-platforms` : convert content for all platforms (default: false)
- `--soci`: generate SOCI v2 Indices to oci images.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: format

@@ -960,6 +960,11 @@ Flags:
- `--oci` : convert Docker media types to OCI media types
- `--platform=<PLATFORM>` : convert content for a specific platform
- `--all-platforms` : convert content for all platforms (default: false)
- `--soci`: generate SOCI v2 Indices to oci images.
*[**Note**: content is converted for all platforms by default when using this flag, use the `--platorm` flag to limit this behavior]*
- `--soci-min-layer-size` : Span size in bytes that soci index uses to segment layer data. Default is 4 MiB.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: soci-span-size?

@@ -89,6 +89,12 @@ func convertCommand() *cobra.Command {
cmd.Flags().String("overlaybd-dbstr", "", "Database config string for overlaybd")
// #endregion

// #region soci flags
cmd.Flags().Bool("soci", false, "Convert image to SOCI Index V2 format.")
cmd.Flags().Int64("soci-min-layer-size", -1, "The minimum size of layers that will be converted to SOCI Index V2 format")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we set the default explicitly instead of passing -1? If we simply want to use SOCI defined defaults, can we simply not pass these options if not set?


// ConvertSociIndexV2 converts an image to SOCI format and returns the converted image reference with digest
func ConvertSociIndexV2(ctx context.Context, client *client.Client, srcRef string, destRef string, gOpts types.GlobalCommandOptions, platforms []string, sOpts types.SociOptions) (string, error) {
sociCmd, err := setupSociCommand(gOpts)
Copy link
Contributor

Choose a reason for hiding this comment

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

This will rely on the platform SOCI version to support the convert option as well. For compatibility, should we check the SOCI cli version first, before making the soci call. We should throw an appropriate error/warn message if the platform soci version does not support convert option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants