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

GCP auth issue with registrar #6

Closed
pisuke opened this issue Aug 1, 2020 · 2 comments
Closed

GCP auth issue with registrar #6

pisuke opened this issue Aug 1, 2020 · 2 comments
Assignees

Comments

@pisuke
Copy link
Collaborator

pisuke commented Aug 1, 2020

Running the registrar program, I've run into this issue:

LDNML14RHV2F:udmi francesco.anselmo$ bin/registrar project_name local/project_name
Building validator...
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/username/Documents/Code/Repositories/github/udmi/validator/src/main/java/com/google/daq/mqtt/validator/Validator.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
fatal: No names found, cannot describe anything.
Running tools version
Using gcloud auth:
username@gmail.com
Using cloud project project_name
Using site config dir local/project_name
Using schema root dir bin/../schema
Using device filter
java args project_name local/project_name bin/../schema
Reading Cloud IoT config from /Users/username/Documents/Code/Repositories/github/udmi/local/project_name/cloud_iot_config.json
Initializing with default credentials...
Aug 01, 2020 10:38:57 AM com.google.auth.oauth2.ComputeEngineCredentials runningOnComputeEngine
INFO: Failed to detect whether we are running on Google Compute Engine.
java.lang.RuntimeException: While initializing Cloud IoT project projects/arup-8-fitzroy-st/locations/europe-west1
	at com.google.daq.mqtt.util.CloudIotManager.initializeCloudIoT(CloudIotManager.java:94)
	at com.google.daq.mqtt.util.CloudIotManager.<init>(CloudIotManager.java:61)
	at com.google.daq.mqtt.registrar.Registrar.setSiteConfigPath(Registrar.java:119)
	at com.google.daq.mqtt.registrar.Registrar.main(Registrar.java:75)
Caused by: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
	at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:132)
	at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:127)
	at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:100)
	at com.google.daq.mqtt.util.CloudIotManager.initializeCloudIoT(CloudIotManager.java:84)
	... 3 more
Registrar complete, exit 255

It's easy to sort this out by adding the GOOGLE_APPLICATION_CREDENTIALS environment variable as suggested

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json

but it would be useful to handle it directly in the code since the service account is already indicated inside local/system.conf

@grafnu
Copy link
Collaborator

grafnu commented Aug 1, 2020

local/system.conf is for DAQ. UDMI is not likely to follow the same mechanism for doing this, although it might be something similar.

The concept of setting it in the code is fine, we just need to figure out how to do it properly. I think, maybe, there should be a
{site_folder}/local directory that could contain local site-specific information? Or maybe it should be {site_folder}/projects/{project_id}/config?

The reason it's separated out is that the same site folder can apply to different projects, and each project would have different credentials!

@pisuke
Copy link
Collaborator Author

pisuke commented Aug 1, 2020

I think I was following an old doc file which was referring to local/system.conf.
Using sites/projects/{project_id}/config sounds good, indeed these creds apply to individual projects.

@pisuke pisuke closed this as completed Apr 8, 2022
grafnu referenced this issue in grafnu/udmi Nov 8, 2022
* Cleanup testing run

* Isolated test

* Pubber logging

* Adding restart count

* Empty Commit for Test

* Empty Commit for Test

* Empty Commit for Test

* Empty Commit for Test

* Empty Commit for Test

* Working reset test

* Empty Commit for Test

* Hourly cron

* Adjust to hourly

* Add always wait for config sync

* Fix recursion

* Fix config waiting
grafnu pushed a commit that referenced this issue Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants