2017-11-18 168 views
0

症狀配額在開發環境終點框架v2和部署項目

我開發服務器上工作,但在部署到GCP的響應是一個新的標準環境終點框架(V2)項目:應用程序暫時超過其服務配額。請稍後再試。

但是,如果我嘗試添加配額限制和指標(根據https://cloud.google.com/endpoints/docs/frameworks/quotas-configure),則開發服務器錯誤爲:AttributeError:'tuple'對象沒有屬性'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, 

問:
如何,我不是:不使用配額或正確配置配額?還是有錯誤?顯示 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] 

完整的錯誤:

SDK

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/[email protected]')} 
    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' 

回答

0

quota_limits需求是endpoints.api_config.LimitDefinition實例,而不是一個元組的列表清單。這是文檔中的錯誤;我會確保它們得到糾正,並且我會改進錯誤信息以便更清楚。

相關問題