Skip to content

Suppress clutter from docker-credential-gcloud error messages #4705

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

Merged
merged 2 commits into from
Aug 20, 2020

Conversation

briandealwis
Copy link
Member

@briandealwis briandealwis commented Aug 20, 2020

Follows on #4451

Description

The change in #4451 makes Skaffold's image-pulling follow the approach used with docker pull: first try with credentials, and then without credentials. When pulling from GCR, that first pull may result in an error being emitted from docker-credential-gcloud when there is no user or credentials have been revoked.

This happens surprisingly often — even when users have not run gcloud auth configure-docker — as Skaffold tries using docker-credential-gcloud for *.gcr.io. This is the case with Cloud Code as the Cloud SDK is automatically installed, but users may not yet have performed an action requiring authentication (e.g., to deploy to GCP).

This PR sets CLOUDSDK_CORE_VERBOSITY=none prior to pulling images to suppress error messages emitted from docker-credential-gcloud. These messages are unnecessary as should the image pull fail, the error reported from the registry and shown to the user contains sufficient information to rectify the situation.

Before:

$GCLOUDSDK/bin/skaffold build
Generating tags...
 - skaffold-buildpacks -> skaffold-buildpacks:v1.13.1-49-g98ba2d818
Checking cache...
 - skaffold-buildpacks: Not found. Building
Found [minikube] context, using local docker daemon.
Building [skaffold-buildpacks]...
ERROR: (gcloud.auth.docker-helper) You do not currently have an active account selected.
Please run:

  $ gcloud auth login

to obtain new credentials.

If you have already logged in with a different account:

    $ gcloud config set account ACCOUNT

to select an already authenticated account to use.
v1: Pulling from buildpacks/builder
ab0f59294661: Pulling fs layer 
c2ae8b336f77: Pulling fs layer 

Now:

$ skaffold build
Generating tags...
 - skaffold-buildpacks -> skaffold-buildpacks:v1.13.1-48-g28d305c44
Checking cache...
 - skaffold-buildpacks: Not found. Building
Found [minikube] context, using local docker daemon.
Building [skaffold-buildpacks]...
v1: Pulling from buildpacks/builder
ab0f59294661: Pull complete 
c2ae8b336f77: Pull complete 
3c2cba919283: Pull complete 

Error when pulling from a private repository:

$ skaffold build
Generating tags...
 - skaffold-buildpacks -> skaffold-buildpacks:v1.13.1-50-g456977b80-dirty
Checking cache...
 - skaffold-buildpacks: Not found. Building
Found [minikube] context, using local docker daemon.
Building [skaffold-buildpacks]...
couldn't build "skaffold-buildpacks": failed to fetch builder image 'gcr.io/<private-project>/first:latest': pulling image from repository: Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication

@briandealwis briandealwis requested a review from a team as a code owner August 20, 2020 15:21
@briandealwis briandealwis added this to the v1.14.0-friction milestone Aug 20, 2020
@briandealwis briandealwis requested a review from nkubala August 20, 2020 15:21
@codecov
Copy link

codecov bot commented Aug 20, 2020

Codecov Report

Merging #4705 into master will decrease coverage by 0.01%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4705      +/-   ##
==========================================
- Coverage   73.35%   73.34%   -0.02%     
==========================================
  Files         338      338              
  Lines       13389    13394       +5     
==========================================
+ Hits         9822     9824       +2     
- Misses       2961     2962       +1     
- Partials      606      608       +2     
Impacted Files Coverage Δ
pkg/skaffold/docker/image.go 75.21% <40.00%> (-0.79%) ⬇️

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 28d305c...3db355d. Read the comment docs.

Copy link
Contributor

@gsquared94 gsquared94 left a comment

Choose a reason for hiding this comment

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

LGTM!

@nkubala nkubala merged commit 47ff260 into GoogleContainerTools:master Aug 20, 2020
nkubala pushed a commit to nkubala/skaffold that referenced this pull request Aug 20, 2020
…ContainerTools#4705)

* Suppress clutter from docker-credential-gcloud error messages

* Use `critical`
nkubala pushed a commit to nkubala/skaffold that referenced this pull request Aug 20, 2020
…ContainerTools#4705)

* Suppress clutter from docker-credential-gcloud error messages

* Use `critical`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants