【发布时间】:2020-02-18 22:54:17
【问题描述】:
类似于this issue.(我将在下面更详细地描述链接)
问题: 运行我的 Google Cloud Build 时,我收到一条错误消息:
django.db.utils.OperationalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/cloudsql/sample-kubernetes-268320:us-west1:cloud-build-staging/.s.PGSQL.3306"
我正在关注合作者posted here 的解决方案。他们提供了一个示例 cloudbuild.yaml,我没有任何运气就密切关注它。
工作 cloudbuild.yaml
steps:
- id: proxy-install
name: alpine:3.10
entrypoint: sh
args:
- -c
- 'wget -O /workspace/cloud_sql_proxy https://storage.googleapis.com/cloudsql-proxy/v1.16/cloud_sql_proxy.linux.386 && chmod +x /workspace/cloud_sql_proxy'
waitFor: ['-']
- id: execute-with-proxy
name: python:3.7
timeout: 100s
entrypoint: sh
args:
- -c
- '(/workspace/cloud_sql_proxy -dir=/workspace -instances=[INSTANCE_CONNECTION_NAME] & sleep 2) && (pip install -r requirements.txt && python test_sql.py)'
waitFor: ['proxy-install']
我的 cloudbuild.yaml
steps:
- id: proxy-install
name: alpine:3.10
entrypoint: sh
args:
- -c
- 'wget -O /workspace/cloud_sql_proxy https://storage.googleapis.com/cloudsql-proxy/v1.16/cloud_sql_proxy.linux.386 && chmod +x /workspace/cloud_sql_proxy'
waitFor: ['-']
- id: Test
name: 'python:3.7.6-buster'
env:
- "CLOUDBUILD_TEST=True"
timeout: 100s
entrypoint: /bin/sh
args:
- -c
- '(/workspace/cloud_sql_proxy -dir=/workspace -instances=sample-kubernetes-268320:us-west1:cloud-build-staging & sleep 2) && (pip install -r requirements.txt && cd fastestfollowup && python3 manage.py test)'
waitFor: ['proxy-install']
我已采取的调试步骤:
- 我已将 Cloud Build Service 添加为 Cloud SQL Admin
- 我已通过使用
gcloud sqlinstances describe cloud-build-staging并复制“连接名称”来确保我的实例名称是正确的
编辑: 我从
更改了我的 cloudbuild.yaml 文件 args:
- -c
- '(/workspace/cloud_sql_proxy -dir=/workspace -instances=sample-kubernetes-268320:us-west1:cloud-build-staging & sleep 2) && (pip install -r requirements.txt && cd fastestfollowup && python3 manage.py test)'
到:
args:
- -c
- '(/workspace/cloud_sql_proxy -dir=/cloudsql -instances=sample-kubernetes-268320:us-west1:cloud-build-staging & sleep 2) && (pip install -r requirements.txt && cd fastestfollowup && python3 manage.py test)'
没有效果。
【问题讨论】:
-
看来您正在将套接字安装在
/workspace上,我认为应该是/cloudsql?例如:` - '(/workspace/cloud_sql_proxy -dir=/cloudsql -instances=sample-kubernetes-268320:us-west1:cloud-build-staging & sleep 2) && (pip install -r requirements.txt && cd fasterfollowup && python3 manage.py test)' ` -
@JerpDertin 我改变了它没有任何效果。我上面的编辑反映了这一点。但是,我认为我做错了什么,因为你和 Kurtis 都得出了同样的结论。
-
感谢您提供该 github 链接
标签: google-app-engine google-cloud-storage google-cloud-build