Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

GCR: ignore exceptions when building images #773

Merged
merged 2 commits into from
Jun 1, 2017

Conversation

mattnworb
Copy link
Member

Ignore exceptions refreshing the accessToken in
ContainerRegistryAuthSupplier when building the image or getting the
RegistryAuth to be used for swarm.

Since authForBuild() has no arguments, we currently try to return an
AccessToken to use in case the image being built needs to pull from
gcr.io, but we should ignore failures in the case that the image being
built does not need to pull anything from gcr.io.

This way someone using ContainerRegistryAuthSupplier with credentials
that do not actually have access to GCR do not get exceptions when
building non-GCR images.

If the accessToken can't be fetched in authForBuild for a gcr.io
image, then the build will still fail but at a later point when the
docker daemon tries to pull the FROM image and throws an error about how
the image is "missing or access is denied".

@mattnworb
Copy link
Member Author

This will prevent unexpected exceptions in cases where the Application Default Credentials are loaded (for example: if running in GCE) but where the credentials do not have the devstorage scope, as in https://travis-ci.org/spotify/dockerfile-maven/jobs/238029396.

@davidxia @mavenraven

@mavenraven
Copy link

👍

@codecov-io
Copy link

codecov-io commented Jun 1, 2017

Codecov Report

Merging #773 into master will increase coverage by 0.21%.
The diff coverage is 100%.

@@             Coverage Diff              @@
##             master     #773      +/-   ##
============================================
+ Coverage     65.27%   65.49%   +0.21%     
- Complexity      674      675       +1     
============================================
  Files           156      156              
  Lines          2955     2965      +10     
  Branches        340      340              
============================================
+ Hits           1929     1942      +13     
+ Misses          876      873       -3     
  Partials        150      150

mattnworb added 2 commits May 31, 2017 20:32
Ignore exceptions refreshing the accessToken in
ContainerRegistryAuthSupplier when building the image or getting the
RegistryAuth to be used for swarm.

Since `authForBuild()` has no arguments, we currently try to return an
AccessToken to use _in case_ the image being built needs to pull from
gcr.io, but we should ignore failures in the case that the image being
built does not need to pull anything from gcr.io.

This way someone using ContainerRegistryAuthSupplier with credentials
that do not actually have access to GCR do not get exceptions when
building non-GCR images.

If the accessToken can't be fetched in `authForBuild` for a gcr.io
image, then the build will still fail but at a later point when the
docker daemon tries to pull the FROM image and throws an error about how
the image is "missing or access is denied".
@mattnworb mattnworb force-pushed the mattbrown/ignore-some-gcr-auth-exceptions branch from deb5a5d to 023246d Compare June 1, 2017 00:33
@mattnworb mattnworb merged commit bad0a2b into master Jun 1, 2017
@mattnworb mattnworb deleted the mattbrown/ignore-some-gcr-auth-exceptions branch June 1, 2017 01:14
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.

3 participants