This change prevents the GenServer from crashing for SDK users when the project_id is not available.
After some investigation, if the project id is not set in the dynamic_config or through one of the following environment variables(GOOGLE_CLOUD_PROJECT, GCLOUD_PROJECT, DEVSHELL_PROJECT_ID) then a request is sent to Google to retrieve the project id through metadata. If the request fails, the GenServer crashes. However, if the request completes, even if the response contains bad data, the GenServ will continue to run.
For SDK users, there is a second file that contains the project id and email address. This change will parse the file (configurations/config_default) to have another way of locally obtaining the project id and email address before attempting a request to Google for the project id.
This change performs the following steps:
1) Parse the new configuration file if it's present.
2) Merge the required configuration data with the credential data.
3) Add a check for project id in determine_project_id as another method for retrieving the project id.
Also, I was unable to use the TOML module to parse the ini formatted file since it contains a bare email address which is considered invalid TOML because of the ampersand. I wrote a small function that would just parse what was needed to retrieve the project id and email.
Here is the format of my configurations/config_default:
[core]
account = user@domain.com
project = my_project
disable_usage_reporting = False
[compute]
zone = us-central1-c
region = us-central1
This change prevents the GenServer from crashing for SDK users when the project_id is not available.
After some investigation, if the project id is not set in the dynamic_config or through one of the following environment variables(GOOGLE_CLOUD_PROJECT, GCLOUD_PROJECT, DEVSHELL_PROJECT_ID) then a request is sent to Google to retrieve the project id through metadata. If the request fails, the GenServer crashes. However, if the request completes, even if the response contains bad data, the GenServ will continue to run.
For SDK users, there is a second file that contains the project id and email address. This change will parse the file (configurations/config_default) to have another way of locally obtaining the project id and email address before attempting a request to Google for the project id.
This change performs the following steps: 1) Parse the new configuration file if it's present. 2) Merge the required configuration data with the credential data. 3) Add a check for project id in
determine_project_id
as another method for retrieving the project id.Also, I was unable to use the TOML module to parse the ini formatted file since it contains a bare email address which is considered invalid TOML because of the ampersand. I wrote a small function that would just parse what was needed to retrieve the project id and email.
Here is the format of my
configurations/config_default
: [core] account = user@domain.com project = my_project disable_usage_reporting = False[compute] zone = us-central1-c region = us-central1