Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Allow GCE credentials even if GAE SDK is detected. #208

Merged
merged 2 commits into from
Jul 2, 2015

Conversation

pcostell
Copy link
Contributor

@pcostell pcostell commented Jul 1, 2015

Allows GCE credentials to load if the App Engine SDK is present but the appropriate environment variable 'SERVER_SOFTWARE' is not.

This change also refactors implicit environment detection to only make an external call in GCE if the well known file credentials don't exist.

Fixes #205.

@dhermes
Copy link
Contributor

dhermes commented Jul 1, 2015

LGTM pending Travis.

That code needs some love (this whole library makes me sad though).

@pcostell
Copy link
Contributor Author

pcostell commented Jul 1, 2015

Sorry, realized I didn't include the tests my first commit.

@dhermes
Copy link
Contributor

dhermes commented Jul 1, 2015

Honestly no new tests (probably) would have been accepted. Pretty low standards for current PRs 😞

@pcostell
Copy link
Contributor Author

pcostell commented Jul 1, 2015

:-( it looks like test_oauth2client.py doesn't actually get run.... I'm going to dig into it a bit.

@pcostell
Copy link
Contributor Author

pcostell commented Jul 1, 2015

Looks like nosetests ignores tests files if they are executable. Gotta fix some tests, but I'm going to do that tomorrow.

@dhermes
Copy link
Contributor

dhermes commented Jul 1, 2015

That is scary. We detected this many months ago and realized it caused a false belief that Python3 was supported. I am going to do some git history sleuthing to see when the executable bit got added back. Feels like a zombie risen from the dead

@dhermes
Copy link
Contributor

dhermes commented Jul 1, 2015

From HEAD:

$ git log -1 --pretty=%H
c47dcd7f66cb8463e5432ad1f2a2a54cc4653df4
$
$ export LINES_BEFORE=20  # Needed to actually see the commit messages
$
$ git log --summary | \
> grep "mode change" -B ${LINES_BEFORE} | \
> grep test_oauth2client\.py -B ${LINES_BEFORE} | \
> grep -e '^commit'
commit bb37fa5ed9e81e951017e813dc8e39b952f40c33
commit 1426ec69137f1290e58104d036ab1bd9c19d321d
commit 39972db41344b46685c0ee202c4665e4b0514eeb
commit 7e1c3b23e4734e546a290edf4d22766d31046a63
commit f25fd3cce7b7df450fd7245d406eac9b4feb4cfa
$
$ git show bb37fa5ed9e81e951017e813dc8e39b952f40c33 --summary
commit bb37fa5ed9e81e951017e813dc8e39b952f40c33
Merge: c815c2b 1426ec6
Author: Nathaniel Manista <nathaniel@google.com>
Date:   Thu Jun 18 08:10:23 2015 -0700

    Merge pull request #196 from eamonnmcmanus/master

    Remove @util.positional from the authorize() wrapper.

$
$ git show 1426ec69137f1290e58104d036ab1bd9c19d321d --summary
commit 1426ec69137f1290e58104d036ab1bd9c19d321d
Author: Éamonn McManus <eamonn@mcmanus.net>
Date:   Wed Jun 17 17:49:55 2015 -0700

    Add a regression test for the @util.positional bug

 mode change 100644 => 100755 tests/test_oauth2client.py
$
$ git show 39972db41344b46685c0ee202c4665e4b0514eeb --summary
commit 39972db41344b46685c0ee202c4665e4b0514eeb
Author: Danny Hermes <daniel.j.hermes@gmail.com>
Date:   Fri Dec 5 17:25:50 2014 -0800

    Fixing code that causes test_oauth2client to fail.

    In particular:
    - Removing executable bit from "test_oauth2client".
    - Temporarily disabling slow (network bound) tests.
    - Making client.SETTINGS a class so it can be mutable.
    - Making GoogleCredentials._get_implicit_credentials a classmethod
      so it can access `cls`.
    - Changing use of `urlparse.parse_qs` to `urllib.parse.parse_qs` (did
      not get converted during Py3K switch).

    Partially addresses #85. Not closing out until slow tests are
    re-enabled and other test failures of `py33openssl14` and
    `py34openssl14` pass.

 mode change 100755 => 100644 tests/test_oauth2client.py
$
$ git show 7e1c3b23e4734e546a290edf4d22766d31046a63 --summary
commit 7e1c3b23e4734e546a290edf4d22766d31046a63
Author: INADA Naoki <inada-n@klab.com>
Date:   Wed Jul 9 01:14:19 2014 +0900

    Update django to 1.6.5

$
$ git show f25fd3cce7b7df450fd7245d406eac9b4feb4cfa --summary
commit f25fd3cce7b7df450fd7245d406eac9b4feb4cfa
Author: Pat Ferate <pferate@gmail.com>
Date:   Sun Jul 6 01:07:03 2014 -0700

    Cleaned up more imports.  Fixed exceptions.  Used 'six' for iteritems().

 mode change 100644 => 100755 tests/test_oauth2client.py

@dhermes
Copy link
Contributor

dhermes commented Jul 1, 2015

H/T to http://stackoverflow.com/a/5094604/1068170 for how to see about a mode change

Looks it was added back in 1426ec6 which came in #196, so luckily it hasn't been in for long.


How could we avoid this? Is it worth checking that the modes of the test files don't change?


@eamonnmcmanus any idea how the executable bit got set?

@pcostell
Copy link
Contributor Author

pcostell commented Jul 1, 2015

One option might be to use --exe on nosetest. It makes it so that nose will still run the tests even if they are executable.

Allows GCE credentials to load if the App Engine SDK is present but the appropriate environment variable 'SERVER_SOFTWARE' is not.

This change also refactors implicit environment detection to only make an external call in GCE if the well known file credentials don't exist.

Also re-enables test_oauth2client.py

Fixes googleapis#205.
@dhermes
Copy link
Contributor

dhermes commented Jul 1, 2015

@pcostell I suppose that'd work, but it's not common that people do that (the reason it's avoided is to keep from running scripts by accident).

@eamonnmcmanus
Copy link
Contributor

I guess I must have made the test executable while experimenting with the changes I made in that commit. I had no idea it would have such a surprising effect! My apologies for the inconvenience.

@pcostell
Copy link
Contributor Author

pcostell commented Jul 1, 2015

Alright @dhermes, I think this CL is actually ready now. PTAL.

@dhermes
Copy link
Contributor

dhermes commented Jul 1, 2015

LGTM. I really appreciate the tests!

@dhermes
Copy link
Contributor

dhermes commented Jul 1, 2015

I have merge privileges but maybe should hold off before an owner?

How long has it been since a release? Worth cutting a new one?

@pcostell
Copy link
Contributor Author

pcostell commented Jul 1, 2015

👍 I would definitely appreciate a release so I can integrate it with Remote API

@eamonnmcmanus
Copy link
Contributor

+1. A release would also allow us to apply the bugfix in #196 to the GAE SDK.

@dhermes
Copy link
Contributor

dhermes commented Jul 1, 2015

Looks like we've had 19 commits since the last release.

I don't know what @craigcitro was doing for releases and I don't know who is in charge now. @nathanielmanistaatgoogle might know.

I think the best way to do it is by making an account to let Travis publish a release, see gcloud-python config.


@eamonnmcmanus I assume you are in charge of the GAE SDK?

I just did a $ gcloud components update to version 1.9.21 (May 8, 2015) (at least according to ${GOOGLE_CLOUD_SDK}/platform/google_appengine/RELEASE_NOTES) and the latest version in ${GOOGLE_CLOUD_SDK}/platform/google_appengine/lib/oauth2client/oauth2client/__init__.py is 1.4.11.

This is a big surprise to me. I remember the old days of a frozen in time version created with a big nasty script that created a massive zipfile (pre-gcloud days).

@dhermes
Copy link
Contributor

dhermes commented Jul 2, 2015

Haven't heard from @nathanielmanistaatgoogle, we can rollback if a merge wasn't a good idea.

dhermes added a commit that referenced this pull request Jul 2, 2015
Allow GCE credentials even if GAE SDK is detected.
@dhermes dhermes merged commit df10cf7 into googleapis:master Jul 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants