-
Notifications
You must be signed in to change notification settings - Fork 699
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
fix regression on appEngine detection #1109
Conversation
@mattwhisenhunt PTAL Your commit 75ba03c causes a regression in some tests we don't have here. I'd like to either fully rollback that change (close out this PR, start a new PR) or go ahead with having both logic. Which do you think is better? And could you explain 75ba03c? I don't have the context for that unfortunately. |
I didn't know at the time there was another source of truth of this repo so I didn't squash my CL. This started out as a bit of a vague issue that Les and I used a couple of PRs as a back and forth to come to the result we wanted. |
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.
LGTM
return false; | ||
Class<?> systemPropertyClass = null; | ||
try { | ||
systemPropertyClass = forName("com.google.appengine.api.utils.SystemProperty"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There are 3 cases: Java 7 on std, Java 8 on std, and Java compat . The change you are bringing back will look to see if the GAE libraries have been included. That won't always be the case. It's better to use the environment variables as that will tell you reality, that always work for local development. Typically, your trying to find out if you need to use the metadata server, or he GAE api's to get a credential. (Java 7) (ie. what is the issue you are really trying to fix) |
@lesv Thanks for the context. In that case, I'd like to go forward with this, since there are internal users that depend on the old case and it sounds like we're trying to convince external users to use the new environment variable case. Does that sound appropriate to you? |
@jadekler, go ahead and start an internal email thread and share the log results from the internal failing test. The test may be incorrect and should maybe be updated instead. |
Note - I should have mentioned above that there are 3 GAE cases, there are of course, other cases. On Java 8 - Credentials should be gotten from the Metadata server: Flexible runtime - use Metadata server Locally - there should not be these environment variables set, you should get them from the normal DefaultAuth or ADC algorithm. All other GCP runtimes should use the ADC algorithm that checks for |
It's not clear to me what case is being solved by this change. @lesv, you said "credentials should be gotten through the code you are adding". But the adds are only in the detection part, not in actually retrieving the credentials. Is this fixing Flex? Although it sounds like Flex should enable the |
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.
My suggestions are ugly, please feel free to convert to decent reading code. They look like they should work, but once you've got it changed, I'll build something and test it. Basically, I'm telling things to prefer the metadata server if it's available.
return false; | ||
Class<?> systemPropertyClass = null; | ||
try { | ||
systemPropertyClass = forName("com.google.appengine.api.utils.SystemProperty"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -256,7 +258,6 @@ private GoogleCredential getCredentialUsingWellKnownFile( | |||
} | |||
} | |||
|
|||
|
|||
private boolean runningOnAppEngine() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -256,7 +258,6 @@ private GoogleCredential getCredentialUsingWellKnownFile( | |||
} | |||
} | |||
|
|||
|
|||
private boolean runningOnAppEngine() { | |||
if (getEnvEquals("GAE_ENV", "standard")) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -271,7 +272,38 @@ private boolean runningOnAppEngine() { | |||
return true; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Object environmentValueValue = valueMethod.invoke(environmentValue); | ||
return (environmentValueValue != null); | ||
} catch (NoSuchFieldException exception) { | ||
cause = exception; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@lesv PTAL - incorporated your fixes |
@@ -256,7 +258,6 @@ private GoogleCredential getCredentialUsingWellKnownFile( | |||
} | |||
} | |||
|
|||
|
|||
private boolean runningOnAppEngine() { | |||
if (getEnvEquals("GAE_ENV", "standard")) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -256,7 +258,6 @@ private GoogleCredential getCredentialUsingWellKnownFile( | |||
} | |||
} | |||
|
|||
|
|||
private boolean runningOnAppEngine() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Object environmentValueValue = valueMethod.invoke(environmentValue); | ||
return (environmentValueValue != null); | ||
} catch (NoSuchFieldException exception) { | ||
cause = exception; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -271,7 +272,38 @@ private boolean runningOnAppEngine() { | |||
return true; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@lesv PTAL |
private boolean runningOnAppEngine() { | ||
if (getEnvEquals("GAE_ENV", "standard")) { | ||
private boolean useGAEStandardAPI() { | ||
if (getEnvEquals("GAE_ENV", "standard") && getEnvEquals("GAE_RUNTIME", "java7")) { | ||
return true; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
return (environmentValueValue != null); | ||
} catch (NoSuchFieldException ignored) { | ||
// If the field does not exist then we treat it as false. | ||
} catch (SecurityException exception) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
return true; | ||
|
||
if (cause != null) { | ||
throw OAuth2Utils.exceptionWithCause(new RuntimeException(String.format( |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
if (cause != null) { | ||
throw OAuth2Utils.exceptionWithCause(new RuntimeException(String.format( | ||
"Unexpcted error trying to determine if runnning on Google App Engine: %s", |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
if (getEnvEquals("GAE_RUNTIME", "java8")) { | ||
return true; | ||
Exception cause = null; | ||
Field environmentField; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM |
You might wish to look at the 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.
I'm happy, but tests are failing, so something needs to be changed.
@lesv PTAL |
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.
LGTM.
I added these lines the same time I removed the reflection based app engine check. Now that its back these can go away.
And the tests pass. 😁 |
Ahh ok, thanks @mattwhisenhunt that's good context 👍 |
Will merge this tomorrow if tap train gives thumbs up. |
The method runningOnAppEngine was recently renamed to useGAEStandardAPI, and its logic was changed in googleapis#1109 and googleapis@75ba03c. This commit reverts back to the original logic before either of those commits. The reason for the revert is that several deployments failed with this change internally. See b/111173267, b/111149869.
The method runningOnAppEngine was recently renamed to useGAEStandardAPI, and its logic was changed in #1109 and 75ba03c. This commit reverts back to the original logic before either of those commits. The reason for the revert is that several deployments failed with this change internally. See b/111173267, b/111149869.
No description provided.