oras icon indicating copy to clipboard operation
oras copied to clipboard

Print out the digest and media type even when a unnamed content is skipped for pulling

Open qweeah opened this issue 2 years ago • 5 comments

Print out the digest and media type even when a unnamed content is skipped for pulling and verbose option is set.

  • unnamed: the to-be-pulled content doesn't have a title annotation(org.opencontainers.image.title).

  • skipped: the content won't be fetch during the pull.

  • For one digest, the skipped log should be only printed out once.

Originally posted by @shizhMSFT in https://github.com/oras-project/oras/pull/412#discussion_r903937191

qweeah avatar Jun 22 '22 16:06 qweeah

@wangxiaoxuan273 Could you take a look?

shizhMSFT avatar Aug 02 '22 03:08 shizhMSFT

@wangxiaoxuan273 Could you take a look?

Sure

wangxiaoxuan273 avatar Aug 02 '22 03:08 wangxiaoxuan273

We came up with an edge case and need to confirm the design: imagine a manifest A which has 2 successors, node B and C, both have empty content and thus the same digest. If both of them are unnamed, we will skip them and the current UI will print "skipped 44136fa35v" twice. How should we handle this? @shizhMSFT @qweeah Correct me if I have any mistake.

wangxiaoxuan273 avatar Aug 08 '22 09:08 wangxiaoxuan273

If both of them are unnamed, we will skip them and the current UI will print "skipped 44136fa35v" twice. How should we handle this?

Let's print twice as it is.

shizhMSFT avatar Aug 10 '22 10:08 shizhMSFT

Let's print twice as it is.

I think this is already avoided by current implementation with the printed map.

There is still an edge case pending for confirm: Should we print both skipped and downloaded for content with same digest?

Suppose we pull the below oras artifact:

+-----------------+    +----------------+
|  ORAS Manifest  +---->  OCI Manifest  |
+-----------------+    +----------------+
           |                 |        |
   title:"test"   +--config--+     +--v------+
           |      |                |Layers...|+
         +-v------v-+              +---------+|+
         |    {}    |               +---------+|
         +-44136fa3++                +---------+

The config blob is referred by blobs in oras manifest with name "test", but used as an unamed config in OCI manifest.

Pulling the oras artifact, the log can be like:

Downloading 44136fa355b3 test
Skipped     44136fa355b3 application/vnd.unknown.config.v1+json
Downloading 181210f8f9c7 bar
Downloaded  44136fa355b3 test
Downloaded  181210f8f9c7 bar
Downloading 698937e06ee5 application/vnd.oci.image.manifest.v1+json
Downloaded  698937e06ee5 application/vnd.oci.image.manifest.v1+json
Downloading f495973f108a application/vnd.cncf.oras.artifact.manifest.v1+json
Downloaded  f495973f108a application/vnd.cncf.oras.artifact.manifest.v1+json

Pulled test.somecr.io/oras@sha256:f495973f108a8cf006bf23dc4f690e6c7e0258c9e88444234fb90384d0272227
Digest: sha256:f495973f108a8cf006bf23dc4f690e6c7e0258c9e88444234fb90384d0272227

Should we avoid printing line1, line2 and line4 and the same time? @shizhMSFT @wwwSylvia

qweeah avatar Aug 10 '22 13:08 qweeah

@wangxiaoxuan273 Synced offline with @shizhMSFT on the above case, it's acceptable.

qweeah avatar Aug 18 '22 05:08 qweeah

As per discussion offline with @qweeah and @shizhMSFT, there are currently four small to-do items in this issue, the order matters:

  • [x] docs: add a doc comment before the loop of successors, describing the 2 things done inside the loop. #508
  • [x] fix: empty string should not be written to Annotations, and the unnamed check should use the variable ok. #509
  • [x] feat: when unnamed content is skipped, print its digest and media type only once with sync.Map. #510
  • [x] fix: the verbose flag should work properly when content is skipped. #511

Closed pr #479 as it went out of control.

wangxiaoxuan273 avatar Aug 18 '22 06:08 wangxiaoxuan273

Closed by #508, #509, #510, #511

shizhMSFT avatar Aug 19 '22 11:08 shizhMSFT