每次我尝试部署时都会得到 - (gcloud.preview.app.deploy)错误响应:[4] DEADLINE_EXCEEDED

时间:2016-04-20 02:37:52

标签: ruby-on-rails ruby google-cloud-platform gcloud google-cloud-sdk

我是谷歌云的新手,我正在尝试首次部署它。我的第一个部署是Ruby on Rails项目。

我基本上跟随this guide in the google cloud documentation。唯一的区别是我使用自己的项目而不是他们提供的“hello world”项目。

这是我的app.yaml文件

runtime: custom
vm: true
entrypoint: bundle exec rackup -p 8080 -E production config.ru
resources:
  cpu: 0.5
  memory_gb: 1.3
  disk_size_gb: 10

当我转到我的项目目录并运行gcloud preview app deploy时,它会启动部署但最终会超时。它给出了错误(gcloud.preview.app.deploy) Error Response: [4] DEADLINE_EXCEEDED

进行一些研究我发现gcloud preview app deploy--verbosity debug一起运行会提供额外的调试信息,但它无法帮助我找到导致其超时的内容。

这是控制台日志的最后一块。

Bundle complete! 35 Gemfile dependencies, 102 gems now installed.
Bundled gems are installed into ./vendor/bundle.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Post-install message from compass:
    Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
DEBUG: Operation [operations/build/guidir-1286/MmFkZjNmOGYtZDhhZi00NTJmLTk0YWEtMmQzMjBmM2JkOTg2OlVT] complete. Result: {
    "metadata": {
        "@type": "type.googleapis.com/google.devtools.cloudbuild.v1.BuildOperationMetadata", 
        "build": {
            "finishTime": "2016-04-20T01:55:44.961635Z", 
            "status": "TIMEOUT", 
            "timeout": "600.000s", 
            "projectId": "guidir-1286", 
            "id": "2adf3f8f-d8af-452f-94aa-2d320f3bd986", 
            "source": {
                "storageSource": {
                    "object": "us.gcr.io/guidir-1286/appengine/default.20160420t110030:latest", 
                    "bucket": "staging.guidir-1286.appspot.com"
                }
            }, 
            "steps": [
                {
                    "args": [
                        "us.gcr.io/guidir-1286/appengine/default.20160420t110030:latest"
                    ], 
                    "name": "gcr.io/cloud-builders/dockerizer"
                }
            ], 
            "startTime": "2016-04-20T01:45:43.216420Z", 
            "logsBucket": "staging.guidir-1286.appspot.com", 
            "images": [
                "us.gcr.io/guidir-1286/appengine/default.20160420t110030:latest"
            ], 
            "createTime": "2016-04-20T01:45:41.861657Z"
        }
    }, 
    "done": true, 
    "name": "operations/build/guidir-1286/MmFkZjNmOGYtZDhhZi00NTJmLTk0YWEtMmQzMjBmM2JkOTg2OlVT", 
    "error": {
        "message": "DEADLINE_EXCEEDED", 
        "code": 4
    }
}
DEBUG: (gcloud.preview.app.deploy) Error Response: [4] DEADLINE_EXCEEDED
Traceback (most recent call last):
  File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 654, in Execute
    result = args.cmd_func(cli=self, args=args)
  File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 1401, in Run
    resources = command_instance.Run(args)
  File "/Users/Robert/google-cloud-sdk/lib/surface/preview/app/deploy.py", line 507, in Run
    config_cleanup)
  File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/deploy_command_util.py", line 195, in BuildAndPushDockerImages
    storage_client)
  File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/deploy_command_util.py", line 245, in _BuildImagesWithCloudBuild
    image.tag, cloudbuild_client)
  File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/cloud_build.py", line 181, in ExecuteCloudBuild
    retry_callback=log_tailer.Poll)
  File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/api/operations.py", line 69, in WaitForOperation
    encoding.MessageToPyValue(completed_operation.error)))
OperationError: Error Response: [4] DEADLINE_EXCEEDED
ERROR: (gcloud.preview.app.deploy) Error Response: [4] DEADLINE_EXCEEDED

这是最远的,但有时它会在它超时之前安装宝石的中途,有时它甚至不会安装宝石。

如何阻止这种情况发生?

2 个答案:

答案 0 :(得分:8)

Docker构建有一个10分钟的默认超时(runtime: custom App Engine构建工作的机制)。您可以通过运行gcloud config set app/cloud_build_timeout [NUMBER OF SECONDS]来增加此功能。

您也可以通过自己执行构建来解决这个问题:

docker build . -t gcr.io/myapp/myimage
gcloud docker push gcr.io/myapp/myimage
gcloud preview app deploy app.yaml --image-url=gcr.io/myapp/myimage

但是,一般来说,你的Docker构建不应该花这么长时间。通常情况下,拥有一个已经内置了所有依赖项的基本映像会更好,并且只需从该映像派生最终版本并安装您的应用程序。这样,您的构建将更快。

答案 1 :(得分:4)

总体请求超时时,会引发此错误。

任务队列请求的执行限制为10分钟。 您可以通过输入gcloud config set app/cloud_build_timeout [TIMEOUT_SECONDS]

来增加Google Cloud Shell的超时限制

示例

gcloud config set app/cloud_build_timeout 1000