0

症状

我有一个在开发服务器上运行的新标准环境端点框架 (v2) 项目,但是当部署到 GCP 时,响应是:此应用程序暂时超出其服务配额。请稍后再试。

但是,如果我尝试添加配额限制和指标(根据https://cloud.google.com/endpoints/docs/frameworks/quotas-configure),开发服务器会出错:AttributeError: 'tuple' object has no attribute 'metric_name '。

记录的完整错误如下。我怀疑有关 oauth2client 的警告与配额问题无关,但与当前的端点模块有关。

该错误似乎指向 limit_definitions 但这些来自 Google 示例。

代码片段:

quota_limits = [
    ("read-requests", "Read Requests", 1000),
    ("list-requests", "List Requests", 100),
    ("write-requests", "Write Requests", 50),
]

@endpoints.api(
    name='echo',
    version='v1',
    limit_definitions=quota_limits,

问题:
我怎样才能:不使用配额或正确配置配额?还是有错误?

SDK: gcloud信息

Google Cloud SDK [180.0.0]

Platform: [Linux, x86_64] ('Linux', 'host-name', '4.4.0-98-generic', '#121-Ubuntu SMP Tue Oct 10 14:24:03 UTC 2017', 'x86_64', 'x86_64')
Python Version: [2.7.12 (default, Nov 19 2016, 06:48:10)  [GCC 5.4.0 20160609]]
Python Location: [/usr/bin/python2]
Site Packages: [Disabled]

Installation Root: [/home/steve/google-cloud-sdk]
Installed Components:
  core: [2017.11.10]
  app-engine-python: [1.9.63]
  gcloud: []
  beta: [2017.09.15]
  gsutil: [4.28]
  cloud-datastore-emulator: [1.3.0]
  bq: [2.0.27]
System PATH: [/home/steve/google-cloud-sdk/bin:/home/steve/.nvm/versions/node/v6.11.1/bin:/home/steve/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/steve/google-cloud-sdk/platform/google_appengine:/home/steve/Android/Sdk/tools:/home/steve/Android/Sdk/tools/bin:/home/steve/Android/Sdk/platform-tools:~/bin:~/.config/yarn/global/node_modules/.bin]
Python PATH: [/home/steve/google-cloud-sdk/lib/third_party:/home/steve/google-cloud-sdk/lib:/usr/lib/python2.7/:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload]
Cloud SDK on PATH: [True]
Kubectl on PATH: [False]
There are alternate versions of the following Google Cloud Platform tools on your system PATH.
  /home/steve/google-cloud-sdk/platform/google_appengine/dev_appserver.py
  /home/steve/google-cloud-sdk/platform/google_appengine/endpointscfg.py

Installation Properties: [/home/steve/google-cloud-sdk/properties]
User Config Directory: [/home/steve/.config/gcloud]
Active Configuration Name: [default]
Active Configuration Path: [/home/steve/.config/gcloud/configurations/config_default]

Account: [<removed-for-public-post>]
Project: [project-name]

Current Properties:
  [core]
    project: [project-name]
    account: [<removed for public post>]
    disable_usage_reporting: [False]

Logs Directory: [/home/steve/.config/gcloud/logs]
Last Log File: [/home/steve/.config/gcloud/logs/2017.11.18/11.00.31.517561.log]

git: [git version 2.7.4]
ssh: [OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016]

显示完整错误:

WARNING  2017-11-18 05:57:18,958 multistore_file.py:62] The oauth2client.contrib.multistore_file module has been deprecated and will be removed in the next release of oauth2client. Please migrate to multiprocess_file_storage.
ERROR    2017-11-18 05:57:19,080 wsgi.py:263] 
Traceback (most recent call last):
  File "/home/steve/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/home/steve/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/home/steve/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/home/steve/gae/prototyping/endpoint+fbauth/main.py", line 35, in <module>
    'https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com')}
  File "/home/steve/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0/protorpc/util.py", line 173, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/steve/gae/prototyping/endpoint+fbauth/lib/endpoints/api_config.py", line 1038, in api
    limit_definitions=limit_definitions)
  File "/home/steve/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0/protorpc/util.py", line 173, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/steve/gae/prototyping/endpoint+fbauth/lib/endpoints/api_config.py", line 508, in __init__
    base_path=base_path, limit_definitions=limit_definitions)
  File "/home/steve/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0/protorpc/util.py", line 173, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/steve/gae/prototyping/endpoint+fbauth/lib/endpoints/api_config.py", line 601, in __init__
    _CheckLimitDefinitions(limit_definitions)
  File "/home/steve/gae/prototyping/endpoint+fbauth/lib/endpoints/api_config.py", line 243, in _CheckLimitDefinitions
    if not ld.metric_name:
AttributeError: 'tuple' object has no attribute 'metric_name'
4

1 回答 1

0

quota_limits需要是endpoints.api_config.LimitDefinition实例列表,而不是元组列表。这是文档中的错误;我会确保它们得到纠正,并且我会改进错误消息以使其更加清晰。

于 2017-11-20T23:38:27.863 回答