ServiceOptions.getDefaultProjectId() in Cloud Shell picks up "no-project-id" from metadata server
See original GitHub issueIn 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:
- Created 6 years ago
- Comments:12 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.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?