Skip to content

perf: save auth requests for push and attach#1097

Merged
qweeah merged 1 commit into
oras-project:mainfrom
Wwwsylvia:scope_hints
Sep 1, 2023
Merged

perf: save auth requests for push and attach#1097
qweeah merged 1 commit into
oras-project:mainfrom
Wwwsylvia:scope_hints

Conversation

@Wwwsylvia

@Wwwsylvia Wwwsylvia commented Aug 31, 2023

Copy link
Copy Markdown
Member

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
Copy Markdown

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%> (ø)

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@qweeah qweeah left a comment

Copy link
Copy Markdown
Contributor

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

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@TerryHowe

Copy link
Copy Markdown
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
@qweeah

qweeah commented Sep 1, 2023

Copy link
Copy Markdown
Contributor

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

Wwwsylvia commented Sep 4, 2023

Copy link
Copy Markdown
Member Author

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