Using gcloud console for Google App Engine causes a Runtime error from metrics

夙愿已清 提交于 2019-12-30 09:50:21

问题


I'm trying to use the gcloud console through the browser. When I clone my repository and start the dev server, I get a runtime error from metrics:

$ dev_appserver.py $PWD
Traceback (most recent call last):
  File "/google/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 101, in <module>
    _run_file(__file__, globals())
  File "/google/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 97, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1041, in <module>
    main()
  File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1037, in main
   dev_server.stop()
 File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 845, in stop
   metrics.GetMetricsLogger().Stop()
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/metrics.py", line 117, in Stop
  total_run_time = int((Now() - self._start_time).total_seconds())
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'

I'm not calling the metrics module directly or otherwise using it. How can I disable it in the console or in the code so that I can start my app ok?

It runs ok locally via the SDK.


回答1:


dev_appserver.py metrics were recently added in the Cloud SDK version 144.0.0 for users who have opted-in during SDK installation. The Cloud SDK installation provided in the Cloud console at https://console.cloud.google.com is also opted in to using these metrics.

In response to this post, we've added some additional logic to prevent this misleading error message in the future. This update will appear in one of the upcoming releases.




回答2:


I got this working by resolving an issue in my app.yaml file, one of my routes wasn't specified correctly.

Fixing that route with a leading slash, and escaping the dot within the route regex, seemed to resolve the error too:

diff --git a/app.yaml b/app.yaml
index 8a165a0..39c68b3 100644
--- a/app.yaml
+++ b/app.yaml
@@ -13,7 +13,7 @@ handlers:
 - url: /ui
   static_dir: ui

-- url: robots.txt
+- url: /robots\.txt$
   static_files: robots.txt
   upload: robots.txt


来源:https://stackoverflow.com/questions/42495197/using-gcloud-console-for-google-app-engine-causes-a-runtime-error-from-metrics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!