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

Treat exceptions accessing GCE credential cache file as a cache miss #140

Merged
merged 2 commits into from
Jan 19, 2017

Conversation

thobrla
Copy link
Contributor

@thobrla thobrla commented Jan 18, 2017

This fixes an issue where problems accessing the cache file on
the filesystem (for example, in a container with no mounted
filesystem) would cause apitools to abort entirely, as opposed to
simply not caching the credentials.

Fixes #139

This fixes an issue where problems accessing the cache file on
the filesystem (for example, in a container with no mounted
filesystem) would cause apitools to abort entirely, as opposed to
simply not caching the credentials.

Fixes google#139
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 87.547% when pulling 3cfaf2c on thobrla:master into cb827e4 on google:master.

@@ -302,6 +302,9 @@ def _CheckCacheFileForMatch(self, cache_filename, scopes):
if (creds['scopes'] in
(None, cached_creds['scopes'])):
scopes = cached_creds['scopes']
except: # pylint: disable=bare-except
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it not possible to list specific exceptions we care to skip. This would also supress Ctrl-C.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, do you have any other suggestions beyond KeyboardInterrupt?

@@ -331,6 +334,9 @@ def _WriteCacheFile(self, cache_filename, scopes):
# If it's not locked, the locking process will
# write the same data to the file, so just
# continue.
except: # pylint: disable=bare-except
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we care to add any unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would require mocking locked_file which was removed from more recent versions of oauth2client; this code is simple enough that I'd prefer not to unless you object.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 87.509% when pulling b204d3a on thobrla:master into cb827e4 on google:master.

@cherba cherba merged commit a8536ee into google:master Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn instead of fail on GCE cache file access errors
5 participants