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

Check push permissions before building images #622

Merged
merged 3 commits into from
Mar 19, 2019

Conversation

imjasonh
Copy link
Collaborator

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
@@ -79,6 +78,9 @@ var RootCmd = &cobra.Command{
}
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
Collaborator

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
Collaborator 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
Collaborator

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
Collaborator 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

This breaks pushing to remote registries which are http based.

@ghost
Copy link

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 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.

4 participants