【发布时间】:2021-12-12 14:27:48
【问题描述】:
这几天我就遇到了这个问题。
我已经在使用 Vagrant 构建的 Fedora 34 VM 上安装了 Gcloud sdk。
我已经执行了gcloud init、gcloud auth login 和gcloud config set project <my_project>。
在过去的几天里,我无法正确使用 gsutil。我在这篇文章中找到了一些参考:Gsutil Always Time Out,建议使用选项 -D 来调试 gsutil。
在使用gsutil之前,我设置了bucket name变量并执行命令授权服务账户“
export GCS_BUCKET_URL="gs://<my_project>-<string>/<bucket_subname>/" gcloud auth activate-service-account --key-file=/home/<myuser>/DEV/auth/credentials.json
当我执行“gsutil -D cp ./gcp-config "${GCS_BUCKET_URL}/data-${date_time}/gcp-config”时,我确实看到了:
gsutil version: 5.4
checksum: <checksum> (OK)
boto version: 2.49.0
python version: 3.9.7 (default, Aug 30 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]
OS: Linux 5.14.13-200.fc34.x86_64
multiprocessing available: True
using cloud sdk: True
pass cloud sdk credentials to gsutil: True
config path(s): /home/<myuser>/.boto, /home/<myuser>/.config/gcloud/legacy_credentials/<gserviceaccount.dir>/.boto
gsutil path: /home/<myuser>/google-cloud-sdk/bin/gsutil
compiled crcmod: False
installed via package manager: False
editable install: False
Command being run: /home/<myuser>/google-cloud-sdk/platform/gsutil/gsutil -o GSUtil:default_project_id=<my_project> -D cp ./gcp-config gs://<my_project>-<string>/<bucket_subname>/data-211027082549/gcp-config
config_file_list: ['/home/<myuser>/.boto', '/home/<myuser>/.config/gcloud/legacy_credentials/<service_account>@<my_project>.iam.gserviceaccount.com/.boto']
config: [('working_dir', '/mnt/pyami'), ('debug', '0'), ('https_validate_certificates', 'True'), ('working_dir', '/mnt/pyami'), ('debug', '0'), ('content_language', 'en'), ('default_api_version', '2'), ('default_project_id', '<my_project>')]
DEBUG 1027 08:35:42.782979 multiprocess_file_storage.py] Read credential file
DEBUG 1027 08:35:42.783419 multiprocess_file_storage.py] Read credential file
INFO 1027 08:35:42.784689 base_api.py] Calling method storage.objects.list with StorageObjectsListRequest: <StorageObjectsListRequest
bucket: '<my_project>-<string>'
delimiter: '/'
maxResults: 1000
prefix: '<bucket_subname>/data-211027082549/gcp-config'
projection: ProjectionValueValuesEnum(noAcl, 1)>
INFO 1027 08:35:42.785718 base_api.py] Making http GET to https://storage.googleapis.com/storage/v1/b/<my_project>-<string>/o?alt=json&fields=nextPageToken%2Cprefixes%2Citems%2Fname&delimiter=%2F&maxResults=1000&prefix=<bucket_subname>%2Fdata-211027082549%2Fgcp-config&projection=noAcl
INFO 1027 08:35:42.786104 base_api.py] Headers: {'accept': 'application/json',
'accept-encoding': 'gzip, deflate',
'content-length': '0',
'user-agent': 'apitools Python/3.9.7 gsutil/5.4 (linux) analytics/enabled '
'interactive/True command/cp google-cloud-sdk/362.0.0'}
INFO 1027 08:35:42.786389 base_api.py] Body: (none)
INFO 1027 08:35:42.786540 transport.py] Attempting refresh to obtain initial access_token
DEBUG 1027 08:35:42.786998 multiprocess_file_storage.py] Read credential file
DEBUG 1027 08:35:42.787312 multiprocess_file_storage.py] Read credential file
DEBUG 1027 08:35:42.790359 crypt.py] [<crypt_data>]
INFO 1027 08:35:42.790598 client.py] Refreshing access_token
INFO 1027 08:36:42.926645 retry_util.py] Retrying request, attempt #1...
DEBUG 1027 08:36:42.927215 http_wrapper.py] Caught socket error, retrying: timed out
DEBUG 1027 08:36:42.927584 http_wrapper.py] Retrying request to url https://storage.googleapis.com/storage/v1/b/<my_project>-<string>/o?alt=json&fields=nextPageToken%2Cprefixes%2Citems%2Fname&delimiter=%2F&maxResults=1000&prefix=<bucket_subname>%2Fdata-211027082549%2Fgcp-config&projection=noAcl after exception timed out
INFO 1027 08:36:44.856812 transport.py] Attempting refresh to obtain initial access_token
DEBUG 1027 08:36:44.858911 multiprocess_file_storage.py] Read credential file
DEBUG 1027 08:36:44.859711 multiprocess_file_storage.py] Read credential file
DEBUG 1027 08:36:44.862151 crypt.py] [<crypt_data>]
INFO 1027 08:36:44.862644 client.py] Refreshing access_token
INFO 1027 08:37:44.899579 retry_util.py] Retrying request, attempt #2...
DEBUG 1027 08:37:44.903247 http_wrapper.py] Caught socket error, retrying: timed out
DEBUG 1027 08:37:44.905944 http_wrapper.py] Retrying request to url https://storage.googleapis.com/storage/v1/b/<my_project>-<string>/o?alt=json&fields=nextPageToken%2Cprefixes%2Citems%2Fname&delimiter=%2F&maxResults=1000&prefix=<bucket_subname>%2Fdata-211027082549%2Fgcp-config&projection=noAcl after exception timed out
INFO 1027 08:37:49.982855 transport.py] Attempting refresh to obtain initial access_token
DEBUG 1027 08:37:49.983732 multiprocess_file_storage.py] Read credential file
DEBUG 1027 08:37:49.984001 multiprocess_file_storage.py] Read credential file
DEBUG 1027 08:37:49.985360 crypt.py] [<crypt_data>]
INFO 1027 08:37:49.985699 client.py] Refreshing access_token
INFO 1027 08:38:50.090714 retry_util.py] Retrying request, attempt #3...
这会重复很多次。
我检查了凭据文件(.boto 文件),它们看起来不错。
服务帐户“
具有“安全管理员”和“存储管理员”权限
我已尝试重新安装 Gcloud SDK,但没有帮助。
从 this answer 看来,我的虚拟机上的 gsutil 面临代理问题。
因此,我还尝试了不安全选项来更改路由器的安全级别:
- 禁用防火墙
- 启用 WAN ping(在 this topic 之后)
我仍然有同样的行为。
在GoogleDocs/GoogleSDK install 我读到:“Cloud SDK 需要 Python;支持的版本是 Python 3(首选,3.5 到 3.8)和 Python 2(2.7.9 或更高版本)。”
由于我的python版本是3.9.7,不知道是不是这个问题。
任何建议都会在这里有所帮助。提前致谢!
更新
我已经更改了python版本,安装了3.6.15,但是并没有解决问题。
【问题讨论】:
标签: google-cloud-platform gcloud gsutil