Skip to content

Unable to connect to emulator running on docker compose with client 7.5.1 #1119

Closed
@pokutuna

Description

@pokutuna

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

  1. Using Docker Compose, set up the Datastore emulator and an application container that uses the client library.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: datastoreIssues related to the googleapis/nodejs-datastore API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions