oras-project / oras

OCI registry client - managing content like artifacts, images, packages
https://oras.land
Apache License 2.0
1.5k stars 180 forks source link

ORAS log is not matched with the result when pushing a file with multiple tags #1207

Open FeynmanZhou opened 11 months ago

FeynmanZhou commented 11 months ago

What happened in your environment?

I pushed a file hello.txt with 3 tags v11, v12, v13 as follows:

$ oras push localhost:5000/oras:v11,v12,v13 hello.txt
Exists    e3b0c44298fc hello.txt
Pushed [registry] localhost:5000/oras:v11
Tagged v12
Tagged v13
Digest: sha256:466a0ca65eff1b3602f5ef44cf6e32bac75976ccbdacf3d7c09218a5cd2db373

From the logs, it tells me the file has been pushed to only, but v12 and v13 are tagged.

Next, when I view the manifest of localhost:5000/oras:v12, the file hello.txt has also been pushed to this repo.

oras manifest fetch localhost:5000/oras:v12 --output - | jq
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.manifest.v1+json",
  "artifactType": "application/vnd.unknown.artifact.v1",
  "config": {
    "mediaType": "application/vnd.oci.empty.v1+json",
    "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
    "size": 2,
    "data": "e30="
  },
  "layers": [
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar",
      "digest": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
      "size": 0,
      "annotations": {
        "org.opencontainers.image.title": "hello.txt"
      }
    }
  ],
  "annotations": {
    "org.opencontainers.image.created": "2023-12-21T09:41:16Z"
  }
}

It looks a bit confusing because the file has also been pushed to v12 and v13, but the logs don't tell me this result explicitly.

What did you expect to happen?

$ oras push localhost:5000/oras:v11,v12,v13 hello.txt
Exists    e3b0c44298fc hello.txt
Tagged v11 and pushed the file to [registry] localhost:5000/oras:v11
Tagged v12 and pushed the file to [registry] localhost:5000/oras:v12
Tagged v13 and pushed the file to [registry] localhost:5000/oras:v13
Digest: sha256:466a0ca65eff1b3602f5ef44cf6e32bac75976ccbdacf3d7c09218a5cd2db373

or

$ oras push localhost:5000/oras:v11,v12,v13 hello.txt
Exists    e3b0c44298fc hello.txt
pushed the file to [registry] localhost:5000/oras:v11
pushed the file to [registry] localhost:5000/oras:v12
pushed the file to [registry] localhost:5000/oras:v13
Digest: sha256:466a0ca65eff1b3602f5ef44cf6e32bac75976ccbdacf3d7c09218a5cd2db373

How can we reproduce it?

Described in the first question

What is the version of your ORAS CLI?

v1.1.0

What is your OS environment?

Ubuntu

Are you willing to submit PRs to fix it?

qweeah commented 11 months ago

oras push localhost:5000/oras:v11,v12,v13 hello.txt = oras push localhost:5000/oras:v11 hello.txt + orag tag localhost:5000/oras:v11, the Tagged xxx output is just to be consistent with oras tag logs.

qweeah commented 8 months ago

BTW I just found such output is also applied in oras cp and oras manifest push

# copy
$ oras cp localhost:5000/command/artifacts:foobar localhost:5000/to:v1,v2,v3,v4
✓ Copied  application/vnd.oci.image.manifest.v1+json                                          851/851  B 100.00%   24ms
  └─ sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb
Copied [registry] localhost:5000/command/artifacts:foobar => [registry] localhost:5000/to:v1
Tagged v2
Tagged v4
Tagged v3
Digest: sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb

# push manifest
oras manifest fetch localhost:5000/to:v1 -o manifest.json
oras manifest push localhost:5000/to:v1,v2,v3 manifest.json
Pushed [registry] localhost:5000/to:v1
Tagged v2
Tagged v3
Digest: sha256:fd6ed2f36b5465244d5dc86cb4e7df0ab8a9d24adc57825099f522fe009a22bb
Wwwsylvia commented 2 months ago

@FeynmanZhou is this really needed? As @qweeah has mentioned, the current output is by design. It is not appropriate to print something like

Tagged v11 and pushed the file to [registry] localhost:5000/oras:v11
Tagged v12 and pushed the file to [registry] localhost:5000/oras:v12
Tagged v13 and pushed the file to [registry] localhost:5000/oras:v13

, because of the following reasons:

  1. The file is pushed as a layer, not a manifest, and it can't be represented by a tag such as v11
  2. If the push target is an OCI layout, what ORAS does behind the scenes is pushing the manifest first and tagging them