Treat exceptions accessing GCE credential cache file as a cache miss#140
Merged
cherba merged 2 commits intogoogle:masterfrom Jan 19, 2017
Merged
Treat exceptions accessing GCE credential cache file as a cache miss#140cherba merged 2 commits intogoogle:masterfrom
cherba merged 2 commits intogoogle:masterfrom
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
cherba
approved these changes
Jan 18, 2017
| if (creds['scopes'] in | ||
| (None, cached_creds['scopes'])): | ||
| scopes = cached_creds['scopes'] | ||
| except: # pylint: disable=bare-except |
Contributor
There was a problem hiding this comment.
Is it not possible to list specific exceptions we care to skip. This would also supress Ctrl-C.
Contributor
Author
There was a problem hiding this comment.
Sure, do you have any other suggestions beyond KeyboardInterrupt?
| # If it's not locked, the locking process will | ||
| # write the same data to the file, so just | ||
| # continue. | ||
| except: # pylint: disable=bare-except |
Contributor
There was a problem hiding this comment.
Do we care to add any unit tests?
Contributor
Author
There was a problem hiding this comment.
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.
cherba29
approved these changes
Jan 19, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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