我所有的 gsutil 命令超时

All of my gsutil commands timeout

所以我已经在我的 mac 上成功安装了最新的 google-cloud-sdk 所以我所有的 gcloud 和 gsutil 命令行工具都是最新的。

但是,每当我尝试 gsutil 命令时,它都会超时。例如,当我 运行:

gsutil mb gs://cloud-storage-analysis

它开始 运行,正在打印:

Creating gs://cloud-storage-analysis/...

但它永远不会停止。我使用 Control-C 停止它并打印出这个。

Caught signal 2 - exiting
Traceback (most recent call last):
  File "/Users/jazz/google-cloud-sdk/bin/bootstrapping/gsutil.py", line 71, in <module>
    main()
  File "/Users/jazz/google-cloud-sdk/bin/bootstrapping/gsutil.py", line 54, in main
    'platform/gsutil', 'gsutil', *args)
  File "/Users/jazz/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 45, in ExecutePythonTool
    execution_utils.ArgsForPythonTool(_FullPath(tool_dir, exec_name), *args))
  File "/Users/jazz/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 86, in _ExecuteTool
    execution_utils.Exec(args + sys.argv[1:], env=_GetToolEnv())
  File "/Users/jazz/google-cloud-sdk/bin/bootstrapping/../../lib/googlecloudsdk/core/util/execution_utils.py", line 146, in Exec
    ret_val = p.wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1357, in wait
    pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 478, in _eintr_retry_call
    return func(*args)
KeyboardInterrupt

有一次我让它运行放了半天,居然超时停了。我尝试的每个 gsutil 命令都会发生这种情况。 我的 bq 命令有效(但它们真的很慢)。

不知道怎么回事

感谢您的帮助。

编辑:

所以我的问题并没有完全消失,但 gsutil 有时确实有效。它时断时续,似乎 运行dom 当它工作时,当它不工作时。似乎刷新 shell and/or 退出并重新打开终端有帮助,但并非每次都如此。我还是想一探究竟。

所以按照 Misha 的建议,我 运行 gsutil -D ls 作为测试。 它到达这里然后停了一会儿(可能 2-3 分钟):(一些信息已被 [删除])

gsutil version: 4.13
checksum: [key] (OK)
boto version: 2.38.0
python version: 2.7.5 (default, Mar  9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
OS: Darwin 13.4.0
multiprocessing available: True
using cloud sdk: True
config path: [path-to-home/.boto
gsutil path: [path-to-home]/google-cloud-sdk/platform/gsutil/gsutil
compiled crcmod: True
installed via package manager: False
editable install: False
Command being run: [path-to-home]/google-cloud-sdk/platform/gsutil/gsutil -o GSUtil:default_project_id=storagelogstest -D ls
config_file_list: ['[path-to-home]/.config/gcloud/legacy_credentials/[email]@gmail.com/.boto', '/.boto']
config: [('debug', '0'), ('working_dir', '/mnt/pyami'), ('https_validate_certificates', 'True'), ('debug', '0'), ('working_dir', '/mnt/pyami'), ('content_language', 'en'), ('default_api_version', '2'), ('default_project_id', 'storagelogstest')]
DEBUG 0626 10:43:29.972406 oauth2_client.py] GetAccessToken: checking cache for key 9886bbc6e7e67cf6d2b8b3a707046f2a326dcceb
DEBUG 0626 10:43:29.972712 oauth2_client.py] FileSystemTokenCache.GetToken: key=9886bbc6e7e67cf6d2b8b3a707046f2a326dcceb not present (cache_file=/var/folders/25/zs7lm5jd7dg5jljd4qdxjpnc0000gq/T/oauth2_client-tokencache.503.9886bbc6e7e67cf6d2b8b3a707046f2a326dcceb)
DEBUG 0626 10:43:29.972882 oauth2_client.py] GetAccessToken: token from cache: None
DEBUG 0626 10:43:29.973030 oauth2_client.py] GetAccessToken: fetching fresh access token...
INFO 0626 10:43:29.973551 client.py] Refreshing access_token

然后,它输出了这个:

connect fail: (accounts.google.com, 443)
connect: (accounts.google.com, 443)
send: 'POST /o/oauth2/token HTTP/1.1\r\nHost: accounts.google.com\r\nContent-Length: 195\r\ncontent-type: application/x-www-form-urlencoded\r\naccept-encoding: gzip, deflate\r\nuser-agent: Python-httplib2/0.7.7 (gzip)\r\n\r\nclient_secret=ZmssLNjJy2998hD4CTg2ejr2&grant_type=refresh_token&refresh_token=1%2FUl4EXn6N5jPCjFVy6-U5HwIKNApkGmYEEQPZO654NxHBactUREZofsF9C7PrpE-j&client_id=32555940559.apps.googleusercontent.com'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: application/json; charset=utf-8
header: Cache-Control: no-cache, no-store, max-age=0, must-revalidate
header: Pragma: no-cache
header: Expires: Fri, 01 Jan 1990 00:00:00 GMT
header: Date: Fri, 26 Jun 2015 17:44:45 GMT
header: Content-Disposition: attachment; filename="json.txt"; filename*=UTF-8''json.txt
header: Content-Encoding: gzip
header: P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-XSS-Protection: 1; mode=block
header: Server: GSE
header: Set-Cookie: NID=68=PfDga1cpnMr8ho-0tlBrWNhgLzQsThRzV31vn8QD1cV45H8C4-ydGoMI0ITI0lPJHvKhN_uPSisTQwIzM2LEFKqjXZlgsJ-9l0HiflLdl1UGMevAQ2GFxFqa369vQxZG;Domain=.google.com;Path=/;Expires=Sat, 26-Dec-2015 17:44:45 GMT;HttpOnly
header: Alternate-Protocol: 443:quic,p=1
header: Transfer-Encoding: chunked
DEBUG 0626 10:44:45.808030 oauth2_client.py] GetAccessToken: fresh access token: AccessToken(token=ya29.ngEY7SR5AbdDZ2pWMtBJzAnJGYGUgXB6hKcAwE8I274ieyLmEpuD1WypFJ8jAZN9LS5zCZ3ldGL4MA, expiry=2015-06-26 18:44:45.806928Z)
DEBUG 0626 10:44:45.808321 oauth2_client.py] FileSystemTokenCache.PutToken: key=9886bbc6e7e67cf6d2b8b3a707046f2a326dcceb, cache_file=/var/folders/25/zs7lm5jd7dg5jljd4qdxjpnc0000gq/T/oauth2_client-tokencache.503.9886bbc6e7e67cf6d2b8b3a707046f2a326dcceb
INFO 0626 10:44:45.813867 base_api.py] Calling method storage.buckets.list with StorageBucketsListRequest: <StorageBucketsListRequest
 maxResults: 1000
 project: 'storagelogstest'
 projection: ProjectionValueValuesEnum(full, 0)>
INFO 0626 10:44:45.814872 base_api.py] Making http GET to https://www.googleapis.com/storage/v1/b?project=storagelogstest&fields=nextPageToken%2Citems%2Fid&alt=json&projection=full&maxResults=1000
INFO 0626 10:44:45.815298 base_api.py] Headers: {'accept': 'application/json',
 'accept-encoding': 'gzip, deflate',
 'content-length': '0',
 'user-agent': 'apitools gsutil/4.13 (darwin) Cloud SDK Command Line Tool 0.9.66'}
INFO 0626 10:44:45.815390 base_api.py] Body: (none)
DEBUG 0626 10:45:45.846443 http_wrapper.py] Caught socket error, retrying: timed out

它尝试重新连接几次,但每次都超时,然后我停止了。

我还没有在另一个 machine 上尝试过这个,但我已经和一个有同样问题的同事谈过了(通常它不会起作用,但有时会起作用)。

因此,如果您遇到此问题,只要基本上多多尝试,很可能就能让 gsutil 正常工作。尝试重新启动 shell (exec -l $SHELL) 和 quitting/reopening 命令行并继续尝试,它最终对我有用。这不是永久性修复,对我来说它仍然会超时大约 2/3 的时间。但你至少可以运行你的命令。

希望Google可以解决这个问题