Skip to content
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

com.google.cloud.core.ServiceOptions.getDefaultProjectId() does not work in App Engine local environment #2209

Closed
jabubake opened this issue Jun 30, 2017 · 10 comments
Assignees
Labels
api: bigquery Issues related to the BigQuery API. api: core api: pubsub Issues related to the Pub/Sub API. running on app engine status: blocked Resolving the issue is dependent on other work. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@jabubake
Copy link
Contributor

APIs like google-cloud-pubsub require users to explicitly provide a project id.
When App Engine Maven Plugin is used to run locally using mvn appengine:run
ServiceOptions.getDefaultProjectId() returns no-app-id unless
<application>project-id</application> exists in appengine-web.xml

Note : returns project-id without the application entry when deployed to App Engine.

@ludoch @lesv

@lesv lesv added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Jul 6, 2017
@lesv
Copy link
Contributor

lesv commented Jul 6, 2017

Ideally, when running locally on GAE std, you'll try to grab from either GOOGLE_CLOUD_PROJECT, if defined, or (typical case), get it from gcloud.

@garrettjonesgoogle garrettjonesgoogle added api: bigquery Issues related to the BigQuery API. api: pubsub Issues related to the Pub/Sub API. labels Jul 17, 2017
@garrettjonesgoogle garrettjonesgoogle added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Jul 17, 2017
@garrettjonesgoogle
Copy link
Member

This appears to be a problem even with clients trying to load project ID implicitly, e.g. BigQuery (user-filed issue: #2235 )

@neozwu
Copy link
Contributor

neozwu commented Jul 26, 2017

Our current approaches to retrieving project/application id fail when using gcloud sdk maven plugin and when application id is not specified in appengine-web.xml. I have filed an issue to app-maven-plugin. On a different note, based on appengine runtime contract, both GCLOUD (deprecated) and GOOGLE_CLOUD_PROJECT Env Vars should be injected to app engine runtime container. However, I'm not seeing any of these (for both local or remote servers). I'm tracking this issue with runtime team.

@chanseokoh
Copy link
Contributor

chanseokoh commented Jul 26, 2017

Our current approaches to retrieving project/application id fail when using gcloud sdk maven plugin and when application id is not specified in appengine-web.xml.

This happens regardless of the Maven plugin. For example, where and how will you get a project ID if an app doesn't use any build system? In such a case, users will run the local server directly at the command-line (which is what the Eclipse plugin does, for example.)

I also left some comment in the maven plugin issue: GoogleCloudPlatform/app-maven-plugin#202 (comment)

@neozwu
Copy link
Contributor

neozwu commented Jul 27, 2017

@chanseokoh thank you for your reply on this. The information (project/application id) is actually there (in gcloud sdk). Since this is a gcloud sdk-based plugin, I thought it would retrieive a project id when running "mvn appengine:run". I think "mvn appengine:deploy" by default does this - using the project id set by "gcloud init" as the project property. What is the design idea behind this asymmetry ?

@chanseokoh
Copy link
Contributor

chanseokoh commented Jul 27, 2017

The Maven plugin is not the only tool that is Cloud SDK-based. For example, the Eclipse plugin and the IntelliJ plugin (which share the core gcloud-related code with the Maven plugin) run gcloud app deploy (under the hood) like this:

$ gcloud app deploy .../app.yaml ... --project <project ID where you want the app to be deployed> ...

As you can see, the project ID does not come from gcloud init but from the argument explicitly given. In other words, the project ID is part of a deploy configuration, which is available (and only needed) at the time of deployment. We ask Eclipse/IntelliJ users to which projects they want their apps to be deployed through a friendly GUI. It does not make sense for users to go out of an IDE and do gcloud init every time to designate/change target projects. It's also very dangerous for IDEs to silently pick up the project set by gcloud init. That said, when running the dev server in the IDEs, a project ID simply doesn't exist.

So, even if the Maven plugin (and the Gradle plugin) populate and set a project ID configured by gcloud init, it will not solve the problem for IDE users. (Remember that this user hitting this problem is using the Eclipse plugin: #2235). You need a more fundamental solution to this problem.

@chanseokoh
Copy link
Contributor

In such a case, users will run the local server directly at the command-line (which is what the Eclipse plugin does, for example.)

Also, don't forget the case where users don't use any tool (not even gcloud) but directly invoke the dev server at the command-line.

$ java ... -Dappengine.sdk.root=... -cp .../appengine-tools-api.jar com.google.appengine.tools.development.DevAppServerMain --port=8080 <some app directory>

We need a solution to avoid the problem in this case too.

@chanseokoh
Copy link
Contributor

Have you reached any resolution? I am very curious. If not, please update later when you come up with one. Whatever it will be, I can anticipate many problems as long as the dev server wants to know some project ID. Ideally, the dev server should just not need it.

@lesv
Copy link
Contributor

lesv commented Aug 21, 2017

I asked for a feature in GoogleCloudPlatform/appengine-plugins#439 to set it. It would still be nice if you picked up GOOGLE_CLOUD_PROJECT or .config/gcloud/configurations/config_[.config/gcloud/active_config] and grab "project = " from it.

@danoscarmike danoscarmike added triaged for GA priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Jan 17, 2018
@yihanzhen yihanzhen added the status: blocked Resolving the issue is dependent on other work. label Jan 30, 2018
@JustinBeckwith JustinBeckwith added the 🚨 This issue needs some love. label Jun 8, 2018
@sduskis sduskis added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed 🚨 This issue needs some love. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 8, 2019
@JesseLovelace JesseLovelace removed their assignment Mar 14, 2019
@sduskis
Copy link
Contributor

sduskis commented Jul 1, 2019

This issue seems a bit stale. This is also not actionable in this repository. GoogleCloudPlatform/appengine-plugins#439 is open, so I'm going to close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. api: core api: pubsub Issues related to the Pub/Sub API. running on app engine status: blocked Resolving the issue is dependent on other work. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

10 participants