GeezerVison is showing github.com — ServiceOptions.getDefaultProjectId incorrectly defaults to GCE metadata before service account · Issue #3533 · googleapis/google-cloud-java
ServiceOptions.getDefaultProjectId incorrectly defaults to GCE metadata before service account #3533
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. Activity
yihanzhen commented on Aug 6, 2018
Compute Engine Project ID is looked up before the service account. We should adjust the documentation.
added
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2Moderately-important priority. Fix may not be included in next release. on Aug 6, 2018danielnorberg commented on Aug 6, 2018
The behavior used to match the documentation. And looking at the code, the current behavior seems non-intentional. Wouldn’t it make more sense to restore the previous behavior?
We have a fair amount of code in production relying on the documented behavior.
yihanzhen commented on Aug 6, 2018
Hi @danielnorberg ,
Sorry to see the problem is bothering you. However 1.4.0 was released almost a year ago and this part of the code has stayed unchanged since then. It wouldn't have been introduced by a rather recent change.
The behavior is actually intentional since the metadata server is the only way to determine the Project ID for GAE Flex and GAE 8. This behavior is pretty inseparable for those and GCE. We should have adjusted the documentations however, which we do apologize.
Alternatively, you could override the default project id but explicitly setting the project id using setProjectId and getProjectId.
danielnorberg commented on Aug 8, 2018
But then effectively when running on GCP, ServiceOptions.getDefaultProjectId() will never return the project id of the service account credentials. Is that desirable?
I understand that I can override this behavior in code that I have control over, but in my case I do not have full control over the code. I'm part of an infrastructure team operating a platform running code written by many teams across our organization, and this kind of breaking change is tricky for us to deal with.
yihanzhen commented on Aug 8, 2018
GAE/GCE credentials and project id would be considered default since that would make authentication work more seamlessly in most cases. This behavior is shared among libraries in multiple languages.
Metadata
Metadata
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. Development
No branches or pull requestsIssue actions