cnabio / cnab-to-oci

Tool to convert CNAB bundle.json to OCI index
Apache License 2.0
54 stars 43 forks source link

Push a CNAB Bundle to GCR fails #69

Open silvin-lubecki opened 4 years ago

silvin-lubecki commented 4 years ago

Pushing a CNAB bundle to gcr.io returns an error:

Error: error while pushing bundle config manifest: unexpected status: 400 Bad Request

After some investigation, we found multiple caveats:

silvin-lubecki commented 4 years ago

From https://github.com/docker/app/issues/562

glyn commented 4 years ago

I'm not sure https://github.com/docker/cnab-to-oci/pull/64 is a complete fix as I hit the problem when building at master (27701312d17158eea04c079e7ffcc75259741264). Here are steps to reproduce:

  1. Grab this sample bundle.json
  2. Issue: cnab-to-oci --log-level debug push bundle.json -t gcr.io/<your project>/cnab-to-oci-sample
  3. Fails, where <your project> is cf-sandbox-gnormington with:
    DEBU[0000] Fixing up bundle gcr.io/cf-sandbox-gnormington/cnab-to-oci-sample
    DEBU[0000] Fixing image glyn/cnab-to-oci-sample-cnab:e923b473656ef515302cd8daf8d734e07ea0a1ac
    Starting to copy image glyn/cnab-to-oci-sample-cnab:e923b473656ef515302cd8daf8d734e07ea0a1ac...
    Completed image glyn/cnab-to-oci-sample-cnab:e923b473656ef515302cd8daf8d734e07ea0a1ac copy
    DEBU[0003] Fixing image hello-world@sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a
    Starting to copy image hello-world@sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a...
    Completed image hello-world@sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a copy
    DEBU[0004] Bundle fixed
    DEBU[0004] Pushing CNAB Bundle gcr.io/cf-sandbox-gnormington/cnab-to-oci-sample
    DEBU[0004] Pushing CNAB Bundle Config
    DEBU[0004] Trying to push CNAB Bundle Config
    DEBU[0004] CNAB Bundle Config Descriptor
    DEBU[0004] {
    "mediaType": "application/vnd.cnab.config.v1+json",
    "digest": "sha256:99bb324f7d14e36aa9871920df164d04956e51e5d5b5e44c4d1dc36324200e11",
    "size": 100
    }
    DEBU[0004] Trying to push CNAB Bundle Config Manifest
    DEBU[0004] CNAB Bundle Config Manifest Descriptor
    DEBU[0004] {
    "mediaType": "application/vnd.oci.image.manifest.v1+json",
    "digest": "sha256:88c71a3786a9fd8801f09985e4e5142a316f32864a70513f1cf88c186b424026",
    "size": 188
    }
    DEBU[0005] Failed to push CNAB Bundle Config Manifest, trying with a fallback method
    DEBU[0005] Trying to push CNAB Bundle Config
    DEBU[0005] CNAB Bundle Config Descriptor
    DEBU[0005] {
    "mediaType": "application/vnd.oci.image.config.v1+json",
    "digest": "sha256:99bb324f7d14e36aa9871920df164d04956e51e5d5b5e44c4d1dc36324200e11",
    "size": 100
    }
    DEBU[0005] Trying to push CNAB Bundle Config Manifest
    DEBU[0005] CNAB Bundle Config Manifest Descriptor
    DEBU[0005] {
    "mediaType": "application/vnd.oci.image.manifest.v1+json",
    "digest": "sha256:fd7309a61ab1cb5ff783f78801b5edc667b836f95b56a5a4755051b1550fbbab",
    "size": 193
    }
    DEBU[0006] Failed to push CNAB Bundle Config Manifest, trying with a fallback method
    DEBU[0006] Trying to push CNAB Bundle Config
    DEBU[0006] CNAB Bundle Config Descriptor
    DEBU[0006] {
    "mediaType": "application/vnd.docker.container.image.v1+json",
    "digest": "sha256:99bb324f7d14e36aa9871920df164d04956e51e5d5b5e44c4d1dc36324200e11",
    "size": 100
    }
    DEBU[0006] Trying to push CNAB Bundle Config Manifest
    DEBU[0006] CNAB Bundle Config Manifest Descriptor
    DEBU[0006] {
    "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
    "digest": "sha256:c12e12dd0993fcd5826668f14b4fec9215c8f12a20c956ea40f8e0c39d8b836c",
    "size": 520
    }
    DEBU[0006] CNAB Bundle Config pushed
    DEBU[0006] Pushing CNAB Index
    DEBU[0006] Trying to push OCI Index
    DEBU[0006] {"schemaVersion":2,"manifests":[{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","digest":"sha256:c12e12dd0993fcd5826668f14b4fec9215c8f12a20c956ea40f8e0c39d8b836c","size":520,"annotations":{"io.cnab.manifest.type":"config"}},{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","digest":"sha256:65747a4dd330a0062b4288f8d500cd96dbcb140f7086548557504ad63c9fa6e2","size":1364,"annotations":{"io.cnab.manifest.type":"invocation"}},{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","digest":"sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a","size":524,"annotations":{"io.cnab.component.name":"simple-image","io.cnab.manifest.type":"component"}}],"annotations":{"io.cnab.runtime_version":"v1.0.0-WD","org.opencontainers.artifactType":"application/vnd.cnab.manifest.v1","org.opencontainers.image.authors":"[{\"name\":\"Glyn Normington\"}]","org.opencontainers.image.description":"","org.opencontainers.image.title":"cnab-to-oci-sample","org.opencontainers.image.version":"0.1.0"}}
    DEBU[0006] OCI Index Descriptor
    DEBU[0006] {
    "mediaType": "application/vnd.oci.image.index.v1+json",
    "digest": "sha256:0cbc68985d57a86c4a36a00fa2b766b3f47b0f93ba98924a14b1a467a001201d",
    "size": 1049
    }
    DEBU[0006] Unable to push OCI Index: unexpected status: 400 Bad Request
    DEBU[0006] Trying to push Index with Manifest list as fallback
    DEBU[0006] {"schemaVersion":2,"manifests":[{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","digest":"sha256:c12e12dd0993fcd5826668f14b4fec9215c8f12a20c956ea40f8e0c39d8b836c","size":520,"annotations":{"io.cnab.manifest.type":"config"}},{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","digest":"sha256:65747a4dd330a0062b4288f8d500cd96dbcb140f7086548557504ad63c9fa6e2","size":1364,"annotations":{"io.cnab.manifest.type":"invocation"}},{"mediaType":"application/vnd.docker.distribution.manifest.v2+json","digest":"sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a","size":524,"annotations":{"io.cnab.component.name":"simple-image","io.cnab.manifest.type":"component"}}],"annotations":{"io.cnab.runtime_version":"v1.0.0-WD","org.opencontainers.artifactType":"application/vnd.cnab.manifest.v1","org.opencontainers.image.authors":"[{\"name\":\"Glyn Normington\"}]","org.opencontainers.image.description":"","org.opencontainers.image.title":"cnab-to-oci-sample","org.opencontainers.image.version":"0.1.0"},"mediaType":"application/vnd.docker.distribution.manifest.list.v2+json"}
    DEBU[0006] Manifest list Descriptor
    DEBU[0006] {
    "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
    "digest": "sha256:d84e8186a3cac7f71d0fc7c84e4a28dbf2a7bb4bc802fe881f6666bdb274c644",
    "size": 1121
    }
    DEBU[0007] Unable to push Index with Manifest list: unexpected status: 400 Bad Request
    Error: unexpected status: 400 Bad Request

However, it works when pushing to docker hub. But, when I tried to copy the bundle from docker hub to GCR, I got the following error which may give a clue to the problem:

copy failed: failed to write image gcr.io/cf-sandbox-gnormington/cnab-to-oci-master-copied: failed to write image index gcr.io/cf-sandbox-gnormington/cnab-to-oci-master-copied: MANIFEST_INVALID: Failed to parse manifest for request "/v2/cf-sandbox-gnormington/cnab-to-oci-master-copied/manifests/sha256:fd7309a61ab1cb5ff783f78801b5edc667b836f95b56a5a4755051b1550fbbab": Manifest is missing required field "layers".