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

Prevent asking pull scope for cross-repo mounting #604

Merged
merged 1 commit into from
Nov 8, 2019
Merged

Prevent asking pull scope for cross-repo mounting #604

merged 1 commit into from
Nov 8, 2019

Conversation

antechrestos
Copy link
Contributor

@antechrestos antechrestos commented Nov 7, 2019

@jonjohnsonjr As promised, I implemented the fix we discussed. I also added a test to enforce the implementation.

See #600

@codecov-io
Copy link

codecov-io commented Nov 7, 2019

Codecov Report

Merging #604 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #604   +/-   ##
=======================================
  Coverage   72.85%   72.85%           
=======================================
  Files         102      102           
  Lines        4487     4487           
=======================================
  Hits         3269     3269           
  Misses        807      807           
  Partials      411      411
Impacted Files Coverage Δ
pkg/v1/remote/write.go 64.28% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50b26ee...18d612f. Read the comment docs.

Copy link
Collaborator

@jonjohnsonjr jonjohnsonjr left a comment

Choose a reason for hiding this comment

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

Thanks! I have one small issue, but otherwise lgtm.

if ml.Reference.Context() != ref.Context() {
// we will add push scope for ref.Context() after the loop.
// for now we ask pull scope for references of the same registry
if ml.Reference.Context().Registry == ref.Context().Registry {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we want to keep both the old check and the new check, otherwise you could end up with scopes like:

repository:test-kaniko/test-kaniko:push,pull&repository:test-kaniko/test-kaniko:pull

... which might confuse a registry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jonjohnsonjr Ok. I also added a test to validate this behaviour.

In the mean time, I find (but I am not an expert) the two lines confusing:

scopeSet[ml.Reference.Context().Scope(transport.PullScope)] = struct{}{}
...
scopes = append(scopes, ref.Scope(transport.PushScope))

Why don't we do

scopeSet[ml.Reference.Context().Scope(transport.PullScope)] = struct{}{}
scopes = append(scopes, ref.Context().Scope(transport.PushScope))
...

(or without `Context()` in both instruction?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why don't we do

Good question!

(or without Context() in both instruction?

I'd prefer this. I'm not sure why we call Context on the MountableLayer -- I'm guessing the author was thinking "I need read scopes for this layer's repository, so I'll call Context", but I believe there's no different. You could just call ml.Reference.Scope(transport.PullScope) instead, which I think is cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I've re pushed this change

Copy link
Collaborator

@jonjohnsonjr jonjohnsonjr left a comment

Choose a reason for hiding this comment

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

Thanks!

@jonjohnsonjr jonjohnsonjr merged commit 79629ba into google:master Nov 8, 2019
@antechrestos antechrestos deleted the fix/croos_repo_mounting_scopes branch November 8, 2019 17:24
nanzhong added a commit to nanzhong/lifecycle that referenced this pull request Mar 6, 2020
This bumps the github.com/google/go-containerregistry dependency so
that a fix for supporting app and run images on from different
registries is pulled in.

In particular, google/go-containerregistry#604
is the fix. Previously, when the app and run image are on different
registries, the app image registry would be asked for the pull scope
of the run image which will fail since it's not present.
nanzhong added a commit to nanzhong/lifecycle that referenced this pull request Mar 6, 2020
This bumps the github.com/google/go-containerregistry dependency so
that a fix for supporting app and run images on from different
registries is pulled in.

In particular, google/go-containerregistry#604
is the fix. Previously, when the app and run image are on different
registries, the app image registry would be asked for the pull scope
of the run image which will fail since it's not present.

Signed-off-by: Nan Zhong <nan@notanumber.io>
nanzhong added a commit to nanzhong/lifecycle that referenced this pull request Mar 11, 2020
This bumps the github.com/google/go-containerregistry dependency so
that a fix for supporting app and run images on from different
registries is pulled in.

In particular, google/go-containerregistry#604
is the fix. Previously, when the app and run image are on different
registries, the app image registry would be asked for the pull scope
of the run image which will fail since it's not present.

Signed-off-by: Nan Zhong <nan@notanumber.io>
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.

3 participants