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

Multi arch indices broken in v2alpha5 #639

Closed
juanzolotoochin opened this issue Jun 25, 2024 · 2 comments
Closed

Multi arch indices broken in v2alpha5 #639

juanzolotoochin opened this issue Jun 25, 2024 · 2 comments

Comments

@juanzolotoochin
Copy link

For the following target:

$ bazel query --output=build //bazel/examples/oci/publish_vservice_go_image:_publish.index

# /home/juan-munoz/gg/repo/bazel/examples/oci/publish_vservice_go_image/BUILD.bazel:17:26
oci_image_index(
  name = "_publish.index",
  tags = ["manual"],
  generator_name = "publish",
  generator_function = "publish_vservice_go_image",
  generator_location = "bazel/examples/oci/publish_vservice_go_image/BUILD.bazel:17:26",
  images = ["//bazel/examples/oci/publish_vservice_go_image:_publish.amd64", "//bazel/examples/oci/publish_vservice_go_image:_publish.arm64"],
)
# Rule _publish.index instantiated at (most recent call last):
#   /home/juan-munoz/gg/repo/bazel/examples/oci/publish_vservice_go_image/BUILD.bazel:17:26 in <toplevel>
#   /home/juan-munoz/gg/repo/bazel/oci/service.bzl:89:27                                    in publish_vservice_go_image
#   /home/juan-munoz/gg/repo/bazel/oci/service.bzl:47:18                                    in publish_vservice_image
#   /home/juan-munoz/gg/repo/bazel/oci/oci.bzl:235:24                                       in publish_image
# Rule oci_image_index defined at (most recent call last):
#   /home/juan-munoz/.cache/bazel/_bazel_juan-munoz/5e2ab9bef16b62dfdad15ea9f3634c69/external/rules_oci/oci/private/image_index.bzl:75:23 in <toplevel

Which is just an oci_index with two images: arm64 and amd64. When building the index:

bazel build //bazel/examples/oci/publish_vservice_go_image:_publish.index

Target //bazel/examples/oci/publish_vservice_go_image:_publish.index up-to-date:
  bazel-bin/bazel/examples/oci/publish_vservice_go_image/_publish.index

The output produced only has one of the two images:

# Find the manifest in the output
cat bazel-bin/bazel/examples/oci/publish_vservice_go_image/_publish.index/index.json
{
  "manifests": [
    {
      "mediaType": "application/vnd.oci.image.index.v1+json",
      "size": 375,
      "digest": "sha256:547ab32ced98b7107f22c7a2d79d1f25ecb1cc46bdf308287d1561896d63cdee"
    }
  ]
}

# That blob is the one we want. We can see it only contains the `arm64` image:
cat bazel-bin/bazel/examples/oci/publish_vservice_go_image/_publish.index/blobs/sha256/547ab32ced98b7107f22c7a2d79d1f25ecb1cc46bdf308287d1561896d63cdee
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "manifests": [
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "digest": "sha256:49bfe0fa65600ddbc8ed3d28cbb97c9474ec6d9f395583ae10b6206f92d4f0d2",
      "size": 853,
      "platform": {
        "os": "linux",
        "architecture": "arm64"
      }
    }
  ]

Compare with doing the same but in rules_oci@v1:

$  cat bazel-bin/bazel/examples/oci/publish_vservice_go_image/_publish.index/index.json
{
  "schemaVersion": 2,
  "manifests": [
    {
      "mediaType": "application/vnd.oci.image.index.v1+json",
      "size": 646,
      "digest": "sha256:5ef7438421b55cf126d3c7500f50a8e29199e10c2fb9341382316681e029a9ce"
    }
  ]
}

$ cat bazel-bin/bazel/examples/oci/publish_vservice_go_image/_publish.index/blobs/sha256/5ef7438421b55cf126d3c7500f50a8e29199e10c2fb9341382316681e029a9ce
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "manifests": [
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "size": 717,
      "digest": "sha256:c0c5dd9d8253f5fdaaf1ac454e4d8a712a3d8fecc9b62cb7cceacf9439d172fd",
      "platform": {
        "os": "linux",
        "architecture": "amd64"
      }
    },
    {
      "mediaType": "application/vnd.oci.image.manifest.v1+json",
      "size": 717,
      "digest": "sha256:15523c5a7adf9f7646eacc51111caaeafb38dcbf29a894e26eb6c326363efe75",
      "platform": {
        "os": "linux",
        "architecture": "arm64"
      }
    }
  ]
}

Subsequently, when pushing to a remote registry, the index only contains a single image in v2, not both as it does in v1.

@juanzolotoochin
Copy link
Author

This may be a duplicate of #638

@thesayyn
Copy link
Collaborator

Closing as duplicate of #638

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

No branches or pull requests

2 participants