-
Notifications
You must be signed in to change notification settings - Fork 113
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
Conversation
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
@@ -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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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