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

Support connecting to firestore emulator running on separate container/machine #335

Closed
rpeach opened this issue Apr 4, 2021 · 7 comments
Assignees
Labels
api: firestore Issues related to the googleapis/python-firestore API. type: question Request for information or clarification. Not an issue.

Comments

@rpeach
Copy link

rpeach commented Apr 4, 2021

From what I can tell the firestore client has to be running on the same machine as the emulator, otherwise you end up with a gRPC error: endpoint is neither UDS or TCP loopback address

This makes running the firestore client and emulator in different docker containers impossible (well not exactly - see the monkeypatch).

The reason that this happens is that the client creates local_credentials which gRPC enforces are only used for connections via the loopback adapter or unix sockets.

Description of my setup:
docker container1: Our app which connects to firestore emulator
docker container2: firestore emulator

Possible solutions:

  • Use an insecure channel to talk to the emulator
  • Create proper credentials to talk to the emulator

My initial thoughts are: just use insecure channel, it is only the emulator. But that might be missing something.

For anyone seeing this issue and wondering if there is a temporary workaround, I'm using this monkeypatch for our testing setup:

import grpc
from google.cloud.firestore_v1.base_client import BaseClient


def monkey_patch_firestore_emulator():
    def _emulator_channel(self, transport):
        if "GrpcAsyncIOTransport" in str(transport.__name__):
            return grpc.aio.insecure_channel(self._emulator_host)
        else:
            return grpc.insecure_channel(self._emulator_host)

    BaseClient._emulator_channel = _emulator_channel


monkey_patch_firestore_emulator()
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/python-firestore API. label Apr 4, 2021
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Apr 6, 2021
@dmahugh dmahugh added priority: p2 Moderately-important priority. Fix may not be included in next release. type: question Request for information or clarification. Not an issue. labels Apr 9, 2021
@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label Apr 9, 2021
@nate-trojian
Copy link

Same thing happened for my team. We'd been using the python firebase-admin library for one of our services, and running the emulators in a Docker container for local development and integration tests in our CI/CD pipelines. This change in v2.1.0 broke the local setups and the pipelines. We have strict versioning for all the higher level dependencies, but the firebase-admin library always uses the latest of this library so it didn't matter much.

@jhartquist
Copy link

Same thing happened for my team. We'd been using the python firebase-admin library for one of our services, and running the emulators in a Docker container for local development and integration tests in our CI/CD pipelines. This change in v2.1.0 broke the local setups and the pipelines. We have strict versioning for all the higher level dependencies, but the firebase-admin library always uses the latest of this library so it didn't matter much.

Having the same issue. Pinning google-cloud-firestore==2.0.2 for now..

@nate-trojian
Copy link

nate-trojian commented May 3, 2021

Having the same issue. Pinning google-cloud-firestore==2.0.2 for now..

If you are also using the firebase-admin-python library, make sure you don't update past 4.5.3. Minimum supported version of this library it now supports is the breaking version.
Was updated here: https://github.com/firebase/firebase-admin-python/blob/master/requirements.txt#L10

@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Aug 2, 2021
@craiglabenz
Copy link
Contributor

Thanks for reporting this, @rpeach, especially with the detailed explanation. Since #402, which was released in version 2.2.1, it's possible that the insecure channel used for emulator communication has helped this issue.

Would you mind re-checking your set up against version 2.2.1 and reporting back on your results?

@nate-trojian
Copy link

With the change in e28272a, I can confirm this is now working for my project. Unfortunately, this -> #359 (comment) is now the issue blocking me, but I'll post my problems there

@tseaver
Copy link
Contributor

tseaver commented Oct 4, 2021

@rpeach Thanks for the report! AFAICT, your usecase should be satisfied by the fix in PR #402. Can you please verify that it works for you as of google-cloud-firestore 2.3.0 or later?

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Nov 3, 2021
@meredithslota meredithslota removed priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. labels Nov 9, 2021
@meredithslota
Copy link
Contributor

I believe the question has been answered so I'm going to close this. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/python-firestore API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

8 participants