question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ServiceOptions.getDefaultProjectId() in Cloud Shell picks up "no-project-id" from metadata server

See original GitHub issue

In Cloud Shell, where a project ID is properly configured in gcloud: gcloud config list --format 'value(core.project)' shows the project ID, and echo $CLOUDSDK_CONFIG shows the configuration directory.

Run a Java application that uses ServiceOptions.getProjectId() in cloud shell. It picks up no-project-id from the metadata server.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pongadcommented, Feb 12, 2018

Env var GOOGLE_CLOUD_PROJECT is set in cloud shell. We should be good now. I’ll close this; please reopen if the problem persists.

0reactions
saturnismcommented, Feb 12, 2018

Thanks. Just caught up. However, the current logic will always ping metadata server first rather than checking gcloud SDK credentials first, right? This is contrary to the doc, and can be inefficient. Is there a way to restore the behavior of using metadata server as the last resort?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Class ServiceOptions<ServiceT,OptionsT> (2.9.0) | Java client ...
... ServiceOptions<ServiceT,OptionsT> implements Serializable. Abstract class representing service options. ... public static String getDefaultProjectId().
Read more >
com.google.cloud.ServiceOptions.getDefaultProjectId java ...
Returns the default project ID, or null if no default project ID could be found. This method returns the first available project ID...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found