Skip to content

Service account throws 503 Backend Error when executing gcloud.datastore.Query() #869

Closed

Description

@charlesbclifford

See below the python script which throws the 50 error. The credentials being used are those of a GCP service account.

$ python
Python 2.7.8 (default, Apr 15 2015, 09:26:43) 
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gcloud import datastore
>>> datastore.set_default_dataset_id('tmp')
>>> datastore_conn = datastore.get_connection()
>>> datastore.set_default_connection(datastore_conn)
>>> q=datastore.Query('foo')
>>> print list(q.fetch())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/gcloud/datastore/query.py", line 421, in __iter__
    self.next_page()
  File "/usr/lib/python2.7/site-packages/gcloud/datastore/query.py", line 388, in next_page
    transaction_id=transaction and transaction.id,
  File "/usr/lib/python2.7/site-packages/gcloud/datastore/connection.py", line 257, in run_query
    datastore_pb.RunQueryResponse)
  File "/usr/lib/python2.7/site-packages/gcloud/datastore/connection.py", line 108, in _rpc
    data=request_pb.SerializeToString())
  File "/usr/lib/python2.7/site-packages/gcloud/datastore/connection.py", line 85, in _request
    raise make_exception(headers, content, use_json=False)
gcloud.exceptions.ServiceUnavailable: 503 Backend Error

These .bashrc environment variables have been set, and last is set to use the service account:

CLOUDSDK_CONFIG
CLOUDSDK_PYTHON
GOOGLE_APPLICATION_CREDENTIALS

And, $ gcloud auth activate-service-account has been run, to make the service account the 'active' credentials.

The Cloud Datastore API is enabled on the GCP project.

Also, 'gcloud config set project' has been run.

Any suggestions on how to correct this (credentials configuration) mistake are appreciated.

Activity

  1. jgeewax commented on May 10, 2015

    @jgeewax
    Contributor

    Is tmp the name of your project / dataset ID ?

    datastore.set_default_dataset_id('tmp')

    Seems like this should be:

    datastore.set_default_dataset_id('your-project-id-here')
  2. added
    type: questionRequest for information or clarification. Not an issue.
    api: datastoreIssues related to the Datastore API.
    on May 10, 2015
  3. dhermes commented on May 10, 2015

    @dhermes
    Contributor

    I should also note that gcloud config set project and gcloud auth activate-service-account will have no bearing on this library. However, setting GOOGLE_APPLICATION_CREDENTIALS will be sufficient.

  4. charlesbclifford commented on May 10, 2015

    @charlesbclifford
    Author

    Wow! That is the fix!
    Too bad the documentation does not make it clear that the literal data value of the gcloud.datastore 'dataset_id' config param must match the literal data value of the GCP project_id.

  5. jgeewax commented on May 10, 2015

    @jgeewax
    Contributor

    Gotcha -- right now Dataset ID and Project ID are one-to-one. Eventually you'll be able to create new Datasets in the UI, and it'll make much more sense :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions