[英]gcloud app deploy cannot find app.yaml if go.mod is in a different directory
I have been unable to deploy my Go app to Google App Engine Flexible for a weeks now, although I don't remember changing anything relevant.我已经无法将我的 Go 应用程序部署到 Google App Engine Flexible 一个星期了,尽管我不记得更改任何相关内容。 The go.mod and go.sum files are in the top directory, while the app.yaml is in
./cmd/app/
. go.mod 和 go.sum 文件位于顶层目录,而 app.yaml 位于
./cmd/app/
中。
Error message on gcloud app deploy
: gcloud app deploy
上的错误消息:
Services to deploy:
descriptor: [/Users/me/go/src/github.com/me/project/cmd/app/app.yaml]
source: [/Users/me/go/src/github.com/me/project/cmd/app]
target project: [project-us-central1]
target service: [default]
target version: [20220118t234216]
target url: [https://project-us-central1.uc.r.appspot.com]
target service account: [App Engine default service account]
Do you want to continue (Y/n)?
Beginning deployment of service [default]...
ERROR: (gcloud.app.deploy) Required file is not uploaded: [app.yaml].
This file should not be added to an ignore list
(https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore)
(Of course, app.yaml has been never on the ignore list.) (当然,app.yaml 从未出现在忽略列表中。)
I tried the following:我尝试了以下方法:
.app.yaml
to .gcloudignore file.app.yaml
添加到.gcloudignore 文件.gcloudignore
file.gcloudignore
文件gcloud config set gcloudignore/enabled false
gcloud
is released (Google Cloud SKD 368.0.0).gcloud
发布(Google Cloud SKD 368.0.0)。 Note that this happens both to my existing Go app which was deployed successfully many times over the last few years (the last time in November 2021), and also to a newly created simple web server app under the same directory structure.请注意,这既发生在我现有的 Go 应用程序上,该应用程序在过去几年(最后一次是 2021 年 11 月)成功部署了很多次,也发生在同一目录结构下新创建的简单 web 服务器应用程序上。 However, if I create a simple app without Go modules (go.mod, so.sum),
gcloud app deploy
works as expected.但是,如果我创建一个没有 Go 模块(go.mod,so.sum)的简单应用程序,
gcloud app deploy
将按预期工作。
I just found a workaround while posting this question.我刚刚在发布此问题时找到了解决方法。 Initially, this seems to be working:
最初,这似乎有效:
gcloud app deploy --appyaml=app.yaml
However, after about 30 minutes the deployment always fails with the following error:但是,大约 30 分钟后,部署总是失败并出现以下错误:
Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [13] The system encountered a fatal error
The deployed version seems to be running but it returns HTTP 404 for any request.部署的版本似乎正在运行,但对于任何请求,它都会返回 HTTP 404。 After stopping and restarting the version in the Console, it's still non-functional: it returns mostly HTTP 502, and sometimes HTTP 503 and "Service error -27".
在控制台中停止并重新启动版本后,它仍然不起作用:它主要返回 HTTP 502,有时返回 HTTP 503 和“服务错误 -27”。 I can see in the logs that /readiness_check calls all fail with 503,
failReason:"null"
我可以在日志中看到 /readiness_check 调用都以 503 失败,
failReason:"null"
After a lot of struggling it turned out that the issue was that the ./cmd/app/app.yaml
file was not in the same directory as the ./go.mod
and ./go.sum
files.经过一番努力,事实证明问题在于
./cmd/app/app.yaml
文件与./go.mod
和./go.sum
文件不在同一目录中。
My workaround is renaming go.mod
temporarily before invoking gcloud app deploy
, and then moving it back once the deployment is done.我的解决方法是在调用
gcloud app deploy
之前暂时重命名go.mod
,然后在部署完成后将其移回。 That way everything works fine again.这样,一切都会再次正常运行。
My workaround is copying go.mod and go.sum to your working directory from where you are running gcloud app deploy command.我的解决方法是将 go.mod 和 go.sum 复制到运行 gcloud app deploy 命令的工作目录。 This works for me.
这对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.