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

bigtable.client for CI/CD emulator without credentials #184

Closed
chapmanjacobd opened this issue Dec 5, 2020 · 5 comments
Closed

bigtable.client for CI/CD emulator without credentials #184

chapmanjacobd opened this issue Dec 5, 2020 · 5 comments
Assignees
Labels
api: bigtable Issues related to the googleapis/python-bigtable API. external This issue is blocked on a bug with the actual product. needs more info This issue needs more information from the customer to proceed. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@chapmanjacobd
Copy link

chapmanjacobd commented Dec 5, 2020

maybe related to:
googleapis/java-bigtable-hbase#1070
googleapis/python-datastore#11 (comment)

Environment details

  • OS type and version: Fedora 33
  • Python version: 3.7
  • pip version: 20.2.2
  • google-cloud-bigtable version: 1.6.1

Steps to reproduce

  1. Start bigtable emulator
  2. 🌳 env BIGTABLE_EMULATOR_HOST=localhost:8086 python src/tasks/get_pixel.py

This works locally but not inside of GitHub Actions. Running with BigTable Emulator in a CI/CD context shouldn't require credentials.

Code example

    client = Client(project=PROJECT_ID, admin=True)
    instance = client.instance(INSTANCE_ID, LOCATION_ID)
    connection = happytable.Connection(instance=instance)
...
        batch = happytable.Batch(bigtable_table, transaction=True)
...
            batch.put(key, columns)

Stack trace

Unpacking google-cloud-sdk-bigtable-emulator (319.0.0-0) ...
Setting up google-cloud-sdk-bigtable-emulator (319.0.0-0) ...
Processing triggers for google-cloud-sdk (319.0.0-0) ...
Executing: /usr/lib/google-cloud-sdk/platform/bigtable-emulator/cbtemulator --host=localhost --port=8086
[bigtable] Cloud Bigtable emulator running on 127.0.0.1:8086
Traceback (most recent call last):
  File "src/tasks/get_pixel.py", line 129, in <module>
    pipePixelsToBigTable(1, 1, "tests/data/wealth_roc_value_raster.tif")
  File "src/tasks/get_pixel.py", line 23, in pipePixelsToBigTable
    client = Client(project=PROJECT_ID, admin=True)
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/google/cloud/bigtable/client.py", line 180, in __init__
    client_options=client_options,
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/google/cloud/client.py", line 250, in __init__
    Client.__init__(self, credentials=credentials, client_options=client_options, _http=_http)
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/google/cloud/client.py", line 151, in __init__
    credentials, _ = google.auth.default(scopes=scopes)
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/google/auth/_default.py", line 356, in default
    raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see cloud.google.com/docs/authentication/getting-started
@product-auto-label product-auto-label bot added the api: bigtable Issues related to the googleapis/python-bigtable API. label Dec 5, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Dec 5, 2020
@crwilcox
Copy link
Contributor

I wouldn't expect different behavior with credential detection from a GitHub action. Are you sure that the environment variable is being detected from within get_pixel.py?

import os
print(os.getenv("BIGTABLE_EMULATOR_HOST"))

@crwilcox crwilcox added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 15, 2020
@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label Dec 15, 2020
@tseaver tseaver added needs more info This issue needs more information from the customer to proceed. and removed 🚨 This issue needs some love. labels Dec 15, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Dec 15, 2020
@chapmanjacobd
Copy link
Author

Yes. The env var is there. I just double checked

      - name: Test against BigTable emulator
        run: |
          sudo apt-get install google-cloud-sdk google-cloud-sdk-bigtable-emulator
          echo $BIGTABLE_EMULATOR_HOST
          gcloud beta emulators bigtable start --host-port=localhost:8086 --quiet &
          sleep 5
          python src/tasks/get_pixel.py

prints localhost:8086

   File "src/tasks/get_pixel.py", line 23, in pipePixelsToBigTable
    client = Client(project=PROJECT_ID)
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/google/cloud/bigtable/client.py", line 180, in __init__
    client_options=client_options,
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/google/cloud/client.py", line 250, in __init__
    Client.__init__(self, credentials=credentials, client_options=client_options, _http=_http)
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/google/cloud/client.py", line 151, in __init__
    credentials, _ = google.auth.default(scopes=scopes)
  File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/google/auth/_default.py", line 356, in default
    raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application

@crwilcox
Copy link
Contributor

crwilcox commented Jan 5, 2021

@chapmanjacobd where are you running this in CI? Is it by chance on Google Cloud?

@tseaver
Copy link
Contributor

tseaver commented Jul 16, 2021

I ran into something related just recently: the Github Action was setting the env var, but the script it called was actually a wrapper around (several) docker run commands. By default, the caller's environment is not passed through to the docker container: I had to add --env MY_ENV_VAR=value to the docker invocation.

@crwilcox
Copy link
Contributor

I am going to consider this resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/python-bigtable API. external This issue is blocked on a bug with the actual product. needs more info This issue needs more information from the customer to proceed. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants