gcloud app deploy在go.mod文件位于不同目录时找不到app.yaml文件。

huangapple go评论89阅读模式
英文:

gcloud app deploy cannot find app.yaml if go.mod is in a different directory

问题

我最近几周一直无法将我的Go应用部署到Google App Engine Flexible上,尽管我不记得有改动任何相关的内容。go.mod和go.sum文件位于顶级目录,而app.yaml文件位于./cmd/app/目录下。

在执行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)

(当然,app.yaml从未被添加到忽略列表中。)

我尝试了以下方法:

  1. .gcloudignore文件中添加!app.yaml
  2. 删除.gcloudignore文件。
  3. 运行gcloud config set gcloudignore/enabled false命令。
  4. 等待新版本的gcloud发布(Google Cloud SDK 368.0.0)。

请注意,这个问题不仅发生在我已经成功部署过多次的现有Go应用上(最后一次是在2021年11月),也发生在同一目录结构下新创建的简单Web服务器应用上。然而,如果我创建一个没有Go模块(go.mod、go.sum)的简单应用,gcloud app deploy命令可以正常工作。

英文:

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. The go.mod and go.sum files are in the top directory, while the app.yaml is in ./cmd/app/.

Error message on 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.)

I tried the following:

  1. Add !app.yaml to .gcloudignore file
  2. Delete .gcloudignore file
  3. gcloud config set gcloudignore/enabled false
  4. Wait until a new version of gcloud is released (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. However, if I create a simple app without Go modules (go.mod, so.sum), gcloud app deploy works as expected.

答案1

得分: 1

我刚刚在发布这个问题时找到了一个解决方法。最初,这似乎是有效的:

gcloud app deploy --appyaml=app.yaml

然而,大约30分钟后,部署总是失败,并显示以下错误:

Updating service [default] (this may take several minutes)...failed.                                                                                  
ERROR: (gcloud.app.deploy) Error Response: [13] The system encountered a fatal error

部署的版本似乎正在运行,但对于任何请求都返回HTTP 404。在控制台中停止和重新启动版本后,它仍然无法正常工作:大部分情况下返回HTTP 502,有时返回HTTP 503和"Service error -27"。我可以在日志中看到所有的/readiness_check调用都失败了,failReason:"null"

英文:

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:

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. 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". I can see in the logs that /readiness_check calls all fail with 503, failReason:"null"

答案2

得分: 1

经过一番努力,发现问题是./cmd/app/app.yaml文件与./go.mod./go.sum文件不在同一个目录下。

我的解决方法是在调用gcloud app deploy之前临时重命名go.mod文件,然后在部署完成后将其移回原位。这样一切都能正常工作。

英文:

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.

My workaround is renaming go.mod temporarily before invoking gcloud app deploy, and then moving it back once the deployment is done. That way everything works fine again.

答案3

得分: 0

我的解决方法是将 go.mod 和 go.sum 从运行 gcloud app deploy 命令的位置复制到你的工作目录中。这对我有效。

英文:

My workaround is copying go.mod and go.sum to your working directory from where you are running gcloud app deploy command. This works for me.

huangapple
  • 本文由 发表于 2022年1月19日 06:57:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/70763381.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定