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

crane: fails on Windows with "Error: cannot parse hash: "sha256\\0401ae60059d7270e280bdd6db0d3b91afcf5b34be7271d39c2af0253479257b"" #1942

Open
bartoszpop opened this issue May 8, 2024 · 4 comments · May be fixed by #1944
Labels
bug Something isn't working lifecycle/frozen

Comments

@bartoszpop
Copy link

bartoszpop commented May 8, 2024

Describe the bug

We use rules_oci Bazel rules to build an OCI image. oci_image delegates to crane by invoking the following commands:

++ external/oci_crane_windows_amd64/crane.exe registry serve --disk=bazel-out/x64_windows-fastbuild/bin/my-project/app-oci-image/blobs --address=localhost:0

++ external/oci_crane_windows_amd64/crane.exe push bazel-out/x64_windows-fastbuild/bin/external/zulu_openjdk_17_single/layout 127.0.0.1:5126/layout:latest
2024/05/08 22:10:47 pushed blob: sha256:4493837effea9d438f4e65387c2590376c9b8f9e67a5a4fc3a09b71c13a27454
2024/05/08 22:10:47 pushed blob: sha256:299e78871a1cc210673f2e2dded580ca4ef6c03d3c2fd21ea876ac425ac89d24
2024/05/08 22:10:47 pushed blob: sha256:96526aa774ef0126ad0fe9e9a95764c5fc37f409ab9e97021e7b47a5d82bf6fa
2024/05/08 22:10:47 pushed blob: sha256:808b0c9c38bef5adc6d2a46ff90e81fdb2e8f5b10a5c30edf5e7b3ddcc40ae8c
2024/05/08 22:10:47 127.0.0.1:5126/layout:latest: digest: sha256:4be37c87d550ce8a5aa3f3088843686e9f138112d397a434d7be081a1221b776 size: 949
++ external/oci_crane_windows_amd64/crane.exe --verbose mutate 127.0.0.1:5126/layout@sha256:4be37c87d550ce8a5aa3f3088843686e9f138112d397a434d7be081a1221b776 --append=bazel-out/x64_windows-fastbuild/bin/my-project/app-tar.tar --entrypoint=java,-jar,Application.jar

(...)

2024/05/08 22:10:51 --> PUT http://127.0.0.1:5126/v2/layout/blobs/uploads/3249378995400909334?digest=sha256%3A0401ae60059d7270e280bdd6da0d3b91afcf5b34be7871d39c2af02534b9257b [body redacted: omitting binary blobs from logs]
2024/05/08 22:10:51 PUT /v2/layout/blobs/uploads/3249378995400909334?digest=sha256%3A0401ae60059d7270e280bdd6da0d3b91afcf5b34be7871d39c2af02534b9257b HTTP/1.1
Host: 127.0.0.1:5126
User-Agent: crane.exe/0.18.0 go-containerregistry/0.18.0
Content-Length: 0
Content-Type: application/octet-stream
Accept-Encoding: gzip

2024/05/08 22:10:52 <-- 201 http://127.0.0.1:5126/v2/layout/blobs/uploads/3249378995400909334?digest=sha256%3A0401ae60059d7270e280bdd6da0d3b91afcf5b34be7871d39c2af02534b9257b (1.0634894s) [body redacted: omitting binary blobs from logs]
2024/05/08 22:10:52 HTTP/1.1 201 Created
Content-Length: 0
Date: Wed, 08 May 2024 20:10:52 GMT
Docker-Content-Digest: sha256:0401ae60059d7270e280bdd6da0d3b91afcf5b34be7871d39c2af02534b9257b

2024/05/08 22:10:52 pushed blob: sha256:0401ae60059d7270e280bdd6da0d3b91afcf5b34be7871d39c2af02534b9257b
2024/05/08 22:10:52 --> PUT http://127.0.0.1:5126/v2/layout/manifests/sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211
2024/05/08 22:10:52 PUT /v2/layout/manifests/sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211 HTTP/1.1
Host: 127.0.0.1:5126
User-Agent: crane.exe/0.18.0 go-containerregistry/0.18.0
Content-Length: 921
Content-Type: application/vnd.docker.distribution.manifest.v2+json
Accept-Encoding: gzip

{"schemaVersion":2,"mediaType":"application/vnd.docker.distribution.manifest.v2+json","config":{"mediaType":"application/vnd.docker.container.image.v1+json","size":3108,"digest":"sha256:8f29baa7207585c1c03df3f6245511450518407dab1f51e06716e63e66a29388"},"layers":[{"mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip","size":3401967,"digest":"sha256:96526aa774ef0126ad0fe9e9a95764c5fc37f409ab9e97021e7b47a5d82bf6fa"},{"mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip","size":148202573,"digest":"sha256:808b0c9c38bef5adc6d2a46ff90e81fdb2e8f5b10a5c30edf5e7b3ddcc40ae8c"},{"mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip","size":1402,"digest":"sha256:4493837effea9d438f4e65387c2590376c9b8f9e67a5a4fc3a09b71c13a27454"},{"mediaType":"application/vnd.docker.image.rootfs.diff.tar.gzip","size":204855955,"digest":"sha256:0401ae60059d7270e280bdd6da0d3b91afcf5b34be7871d39c2af02534b9257b"}]}
2024/05/08 22:10:52 <-- 201 http://127.0.0.1:5126/v2/layout/manifests/sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211 (436.6┬Ás)
2024/05/08 22:10:52 HTTP/1.1 201 Created
Content-Length: 0
Date: Wed, 08 May 2024 20:10:52 GMT
Docker-Content-Digest: sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211


2024/05/08 22:10:52 127.0.0.1:5126/layout@sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211: digest: sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211 size: 921
+ REF=127.0.0.1:5126/layout@sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211
+ '[' 0 -ne 0 ']'
+ external/oci_crane_windows_amd64/crane.exe pull 127.0.0.1:5126/layout@sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211 ./bazel-out/x64_windows-fastbuild/bin/myproject/app-oci-image --format=oci --annotate-ref
+ mv bazel-out/x64_windows-fastbuild/bin/myproject/app-oci-image/index.json bazel-out/x64_windows-fastbuild/bin/myproject/app-oci-image/temp.json
+ external/jq_windows_amd64/jq.exe --arg ref 127.0.0.1:5126/layout@sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211 '.manifests |= map(select(.annotations["org.opencontainers.image.ref.name"] == $ref)) | del(.manifests[0].annotations)' bazel-out/x64_windows-fastbuild/bin/myproject/app-oci-image/temp.json
+ rm bazel-out/x64_windows-fastbuild/bin/myproject/app-oci-image/temp.json
+ external/oci_crane_windows_amd64/crane.exe layout gc ./bazel-out/x64_windows-fastbuild/bin/myproject/app-oci-image
Error: cannot parse hash: "sha256\\0401ae60059d7270e280bdd6da0d3b91afcf5b34be7871d39c2af02534b9257b"
--./bazel-out/x64_windows-fastbuild/bin/myproject/app-oci-image
|-- oci-layout
|-- index.json
|--blobs
  |--sha256
    |--4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211
    |--8f29baa7207585c1c03df3f6245511450518407dab1f51e06716e63e66a29388
    |--299e78871a1cc210673f2e2dded580ca4ef6c03d3c2fd21ea876ac425ac89d24
    |--0401ae60059d7270e280bdd6da0d3b91afcf5b34be7871d39c2af02534b9257b
    |--808b0c9c38bef5adc6d2a46ff90e81fdb2e8f5b10a5c30edf5e7b3ddcc40ae8c
    |--96526aa774ef0126ad0fe9e9a95764c5fc37f409ab9e97021e7b47a5d82bf6fa
    |--4493837effea9d438f4e65387c2590376c9b8f9e67a5a4fc3a09b71c13a27454

oci-layout

{
    "imageLayoutVersion": "1.0.0"
}

index.json

{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "manifests": [
    {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "size": 921,
      "digest": "sha256:4d47a76f3f8000bb48a75f6b3d9109c05ddf1b2ee5b2f43a399f8cead7cef211"
    }
  ]
}

Looks like at some point crane uses Windows path separator "\" instead of ":".

Additional context

0.18.0

@bartoszpop bartoszpop added the bug Something isn't working label May 8, 2024
bartoszpop pushed a commit to bartoszpop/go-containerregistry that referenced this issue May 8, 2024
bartoszpop added a commit to bartoszpop/go-containerregistry that referenced this issue May 8, 2024
Copy link

github-actions bot commented Aug 7, 2024

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

@bartoszpop
Copy link
Author

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Keep fresh with the 'lifecycle/frozen' label.

@thesayyn @jonjohnsonjr any chance to have it merged?

@bartoszpop
Copy link
Author

@imjasonh can you pls approve the pr?

Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Keep fresh with the 'lifecycle/frozen' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lifecycle/frozen
Projects
None yet
2 participants