Description
I have development environments and CI to run Datastore emulator and an application that connect to it on Docker Compose.
Those connections are resolved by the service name on the overlay network within it, such as datastore:8081
.
Since client version 7.5.1, these cannot connect to the emulator.
This was triggered by this PR: #1101
When the baseUrl_
does not include a part that means the local network, grpc.credentials.createInsecure
is no longer used.
This change is for a custom endpoint, and the endpoint is given by the DATASTORE_EMULATOR_HOST
environment variable.
As a result, authentication is not skipped when the emulator host is something like datastore:8081
.
To support custom endpoints requiring authentication, how about using a another environment variable instead of reusing the existing one? (like DATASTORE_CUSTOM_HOST
) I think users who set the DATASTORE_EMULATOR_HOST
are expecting development use and not expecting authentication to be required.
Workaround
Setting network_mode: "host"
and expose the emulator port for joining the host network, we can include localhost
in endpoint url. However, this occupies a port on the host and may need to be adjusted.
Environment details
- OS: macOS(host) & Linux(container)
- Node.js version: v20.2.0
- npm version: 9.6.6
@google-cloud/datastore
version: 7.5.1
Steps to reproduce
- Using Docker Compose, set up the Datastore emulator and an application container that uses the client library.
- You will encounter the error: "Could not load the default credentials." during connection.
This is the reproduction code using two different client versions, including docker-compose.yaml:
https://gist.github.com/pokutuna/314248d183f6fbfe60154f63751d3655