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

docs: Improve ORAS diagnose experience #1483

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

FeynmanZhou
Copy link
Member

@FeynmanZhou FeynmanZhou commented Aug 19, 2024

What this PR does / why we need it:

This proposal document aims to:

  1. Identify the issues associated with the current implementation of the --verbose and --debug options.
  2. Clarify the concepts of verbose output and debug logs.
  3. List the guiding principles to write comprehensive, clear, and conducive verbose output and debug logs for effective diagnosis.
  4. Propose solutions to improve the diagnostic experience for ORAS CLI users and developers.
  5. Add examples for proposed changes (more examples will be appended).

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1091

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.02%. Comparing base (60b1369) to head (8fab3d0).
Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1483      +/-   ##
==========================================
+ Coverage   85.54%   86.02%   +0.47%     
==========================================
  Files         113      118       +5     
  Lines        3936     4228     +292     
==========================================
+ Hits         3367     3637     +270     
- Misses        342      352      +10     
- Partials      227      239      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Feynman Zhou <[email protected]>
Signed-off-by: Feynman Zhou <[email protected]>
Copy link

@toddysm toddysm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, if a user decides to get verbose output, he or she will be prepared to receive a lot of information in the output (including very technical information - for example, curl gives details about the encryption algorithm). I am still not convinced that we need to complicate the interface to suppress some of the output.

docs/proposals/diagnose-experience.md Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
Signed-off-by: Feynman Zhou <[email protected]>
Signed-off-by: Feynman Zhou <[email protected]>
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
- Introduce a new flag `--detail` to replace the existing global flag `--verbose` of commands like `pull`, `push`, `attach`, and `discover` for detailed output.
- Add separator lines between each request and response for readability.
- Add timestamp of each request and response to the beginning of each request and response.
- Add the response body including [error code](https://github.com/opencontainers/distribution-spec/blob/main/spec.md#error-codes) and the metadata of processed OCI object (e.g. image manifest) to the debug logs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean? Is it applicable to OCI image layout?

Copy link
Member Author

@FeynmanZhou FeynmanZhou Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error code is not included in the response body in ORAS debug logs now. We need to add it to make it analyzable.

This is not applicable to OCI image layout but only registry.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error code is in the response body as we do extract error code from the JSON response body.

docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Show resolved Hide resolved
Signed-off-by: Feynman Zhou <[email protected]>
Signed-off-by: Feynman Zhou <[email protected]>
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
- Introduce a new flag `--detail` to replace the existing global flag `--verbose` of commands like `pull`, `push`, `attach`, and `discover` for detailed output.
- Add separator lines between each request and response for readability.
- Add timestamp of each request and response to the beginning of each request and response.
- Add the response body including [error code](https://github.com/opencontainers/distribution-spec/blob/main/spec.md#error-codes) and the metadata of processed OCI object (e.g. image manifest) to the debug logs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error code is in the response body as we do extract error code from the JSON response body.

"Www-Authenticate": "Bearer realm=\"https://ghcr.io/token\",service=\"ghcr.io\",scope=\"repository:oras-project/oras:pull\""
"Date": "Fri, 02 Aug 2024 23:56:03 GMT"
< Response body:
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format seems wrong

- Make the verbose output of command `discover` as a formatted output, controlled by `--format tree-full`.
- Add an empty line as the separator between each request and response for readability.
- Add timestamp of each request and response to the beginning of each request and response.
- Add the response body including [error code](https://github.com/opencontainers/distribution-spec/blob/main/spec.md#error-codes) and the metadata of processed OCI object (e.g. image manifest) to the debug logs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never print out binary response body. We need a list of printable content types such as application/json.


Currently, the output of ORAS `--verbose` flag only exists in oras `pull/push/attach/discover` commands, which prints out detailed status output and metadata output. Since ORAS v1.2.0, progress bar is enabled in `pull/push/attach` by default, thus the ORAS output is already verbose on a terminal.

It is intended for end-users who want to observe the detailed file operation when using ORAS. It gives users a comprehensive view of what the tool is doing at every step and how long does it take when push or pull a file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "it" refer to?

docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
Comment on lines +104 to +134
**Current debug log**

```
[DEBU0000] Request #0
> Request URL: "https://ghcr.io/v2/oras-project/oras/manifests/v1.2.0"
> Request method: "GET"
> Request headers:
"User-Agent": "oras/1.2.0+Homebrew"
"Accept": "application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, application/vnd.oci.artifact.manifest.v1+json"
DEBU[0001] Response #0
< Response Status: "401 Unauthorized"
< Response headers:
"Content-Length": "73"
"X-Github-Request-Id": "9FC6:30019C:17C06:1C462:66AD0463"
"Content-Type": "application/json"
"Www-Authenticate": "Bearer realm=\"https://ghcr.io/token\",service=\"ghcr.io\",scope=\"repository:oras-project/oras:pull\""
"Date": "Fri, 02 Aug 2024 16:08:04 GMT"
DEBU[0001] Request #1
> Request URL: "https://ghcr.io/token?scope=repository%3Aoras-project%2Foras%3Apull&service=ghcr.io"
> Request method: "GET"
> Request headers:
"User-Agent": "oras/1.2.0+Homebrew"
DEBU[0002] Response #1
< Response Status: "200 OK"
< Response headers:
"Content-Type": "application/json"
"Docker-Distribution-Api-Version": "registry/2.0"
"Date": "Fri, 02 Aug 2024 16:08:05 GMT"
"Content-Length": "69"
"X-Github-Request-Id": "9FC6:30019C:17C0D:1C46C:66AD0464"
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, debug logs are showed differently in TTY and non-TTY. For example,

in TTY:

DEBU[0000] Request #0
> Request URL: "http://localhost:5000/v2/240923test1/manifests/v1"
> Request method: "HEAD"
...

in non-TTY:

time=2024-10-10T18:45:10+08:00 level=debug msg=Request #0
> Request URL: "http://localhost:5000/v2/240923test1/manifests/v1"
> Request method: "HEAD"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should non-tty use the json formatter? Looks like it has everything else in there for structured logging.

docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
docs/proposals/diagnose-experience.md Outdated Show resolved Hide resolved
Signed-off-by: Feynman Zhou <[email protected]>
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

Successfully merging this pull request may close these issues.

Improve verbose logging for oras commands
7 participants