Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Check push permissions before building images#622

Merged
dlorenc merged 3 commits intoGoogleContainerTools:masterfrom
imjasonh:check
Mar 19, 2019
Merged

Check push permissions before building images#622
dlorenc merged 3 commits intoGoogleContainerTools:masterfrom
imjasonh:check

Conversation

@imjasonh
Copy link
Copy Markdown
Contributor

This calls remote.CheckPushPermission for each unique repository in --destination flags, and fails if the current keychain doesn't have push permissions to any repository.

Tested locally:

$ ./run_in_docker.sh ./integration/dockerfiles/Dockerfile_test_target $PWD gcr.io/mattmoor-public/foo
error checking push permissions: checking push permission: DENIED: Token exchange failed for project 'mattmoor-public'. Caller does not have permission 'storage.buckets.get'. To configure permissions, follow instructions at: https://cloud.google.com/container-registry/docs/access-control
$ ./run_in_docker.sh ./integration/dockerfiles/Dockerfile_test_target $PWD gcr.io/jasonhall-kube/foo
INFO[0000] Resolved base name gcr.io/distroless/base:latest to gcr.io/distroless/base:latest 
INFO[0000] Resolved base name scratch to scratch        
INFO[0000] Resolved base name base to base              
...

@imjasonh imjasonh requested a review from dlorenc March 18, 2019 18:17
Comment thread cmd/executor/cmd/root.go Outdated
logrus.Warn("kaniko is being run outside of a container. This can have dangerous effects on your system")
}
if err := executor.CheckPushPermissions(opts); err != nil {
exit(errors.Wrap(err, "error checking push permissions"))
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.

The main use case here is to fail early because of a typo right? Maybe a more user-friendly error message would be useful here in this case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's possible it's a typo, but it could also be the wrong account logged in at the time. I'm not sure I could detect the error messages for one or the other well enough to give a better message.

Unless you mean something like error checking permissions -- check for typos and try again?

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.

Yeah, just adding something like: "make sure you entered the right repository %s and that you are authenticated correctly and try again"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done:

error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: checking push permission for "gcr.io/g0000000000gle/foo:latest": UNKNOWN: Project 'projects/g0000000000gle' not found or deleted.

@dlorenc dlorenc merged commit 3fa411c into GoogleContainerTools:master Mar 19, 2019
@iciclespider
Copy link
Copy Markdown

This breaks pushing to remote registries which are http based.

@ghost
Copy link
Copy Markdown

ghost commented Aug 14, 2019

@iciclespider Agreed it does appear to be breaking pushing to remote registries that are HTTP based; I am getting the following error:
$ kubectl logs pod/registry-test-kaniko-push-np7wg
error checking push permissions -- make sure you entered the correct tag name, and that you are authenticated correctly, and try again: checking push permission for "kubernetes.docker.internal:5000/registrytest/kanikopush:latest": Get https://kubernetes.docker.internal:5000/v2/: http: server gave HTTP response to HTTPS client
Using gcr.io/kaniko-project/executor:debug-v0.10.0
When I switch back to v0.9.0 this goes away.
I have tried using the --insecure, --skip-tls-verify flags and none of them seem to have any effect on the push permission check.
Executor command:
/kaniko/executor --destination=kubernetes.docker.internal:5000/registrytest/kanikopush:latest --insecure *.internal

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants