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

perf: save auth requests for push and attach #1097

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

Wwwsylvia
Copy link
Member

@Wwwsylvia Wwwsylvia commented Aug 31, 2023

What this PR does / why we need it:
Add pull, push scope hints before calling Copy for oras push and oras attach.
This can potentially save 2 requests for each command.

oras push

oras push $myreg/$myrepo:$mytag --debug

Before

request #0: HEAD manifest digest - 401
request #1: POST token (scope: pull) - 200
request #2: HEAD manifest digest - 404
request #3: HEAD config ({}) - 404
request #4: POST config ({}) - 401
request #5: POST token (scope: pull, push) - 200
request #6: POST config ({}) - 202
request #7: PUT config ({}) - 201
request #8: PUT manifest tag - 201

After

request #0: HEAD manifest digest - 401
request #1: POST token (scope: pull) - 200
request #2: HEAD manifest digest - 404
request #3: HEAD config ({}) - 404
request #4: POST config ({}) - 202
request #5: PUT config ({}) - 201
request #6: PUT manifest tag - 201

oras attach

oras attach myreg/myrepo:mytag --artifact-type application/test foo --debug

Before

request #0: HEAD subject tag - 401
request #1: POST token (scope: pull) - 200
request #2: HEAD subject tag - 200
request #3: HEAD manifest digest - 404
request #4: HEAD config ({}) - 200
request #5: HEAD layer - 404
request #6: POST layer - 401
request #7: POST token (scope: pull, push) - 200
request #8: POST layer - 202
request #9: PUT layer - 201
request #10: PUT manifest tag - 201

After

request #0: HEAD subject tag - 401
request #1: POST token (scope: pull) - 200
request #2: HEAD subject tag - 200
request #3: HEAD manifest digest - 404
request #4: HEAD config ({}) - 200
request #5: HEAD layer - 404
request #6: POST layer - 202
request #7: PUT layer - 201
request #8: PUT manifest tag - 201

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 #1084

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

Signed-off-by: Sylvia Lei <lixlei@microsoft.com>
@codecov-commenter
Copy link

Codecov Report

Merging #1097 (a6a80b8) into main (2d6d36e) will increase coverage by 0.08%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main    #1097      +/-   ##
==========================================
+ Coverage   79.99%   80.08%   +0.08%     
==========================================
  Files          56       57       +1     
  Lines        2914     2927      +13     
==========================================
+ Hits         2331     2344      +13     
  Misses        405      405              
  Partials      178      178              
Files Changed Coverage Δ
cmd/oras/root/attach.go 82.64% <100.00%> (+0.74%) ⬆️
cmd/oras/root/push.go 75.70% <100.00%> (+0.70%) ⬆️
internal/registryutil/auth.go 100.00% <100.00%> (ø)

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@qweeah qweeah left a comment

Choose a reason for hiding this comment

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

LGTM but this change can also be applied to manifest delete and blob delete

Copy link
Member

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

LGTM.

@TerryHowe
Copy link
Member

LGTM but this change can also be applied to manifest delete and blob delete

Follow up?

@qweeah qweeah merged commit 31f9b91 into oras-project:main Sep 1, 2023
6 checks passed
@qweeah
Copy link
Contributor

qweeah commented Sep 1, 2023

LGTM but this change can also be applied to manifest delete and blob delete

Follow up?

Created #1104. @Wwwsylvia Do we still need to create the issue for copying?

@Wwwsylvia
Copy link
Member Author

Wwwsylvia commented Sep 4, 2023

LGTM but this change can also be applied to manifest delete and blob delete

Follow up?

Created #1104. @Wwwsylvia Do we still need to create the issue for copying?

Created #1105.

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.

Consider optimizing the number of auth requests
5 participants