简体   繁体   English

gcloud app deploy 找不到 app.yaml 如果 go.mod 在不同的目录中

[英]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:我尝试了以下方法:

  1. Add .app.yaml to .gcloudignore file.app.yaml添加到.gcloudignore 文件
  2. Delete .gcloudignore file删除.gcloudignore文件
  3. gcloud config set gcloudignore/enabled false
  4. Wait until a new version of 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.

相关问题 解析 go.mod 时出错 如何使用 Cloud build 在 App Engine 上部署 go 应用程序? - errors parsing go.mod How to deploy go app on App Engine with Cloud build? 如何在不同于app.yaml的文件夹中上载Google App Engine(Go)项目 - How to upload a Google App Engine (Go) project in a different folder than the app.yaml 如何在appengine Go中使用与app.yaml不同的文件夹中的主包? - How to use main package in different folder than app.yaml for appengine Go? 如何在 app.yaml 中为 Go 传递运行 arguments? - How to pass run arguments in app.yaml for Go? 在 go.mod 目录中将 package 安装到 GOPATH - Installing a package to GOPATH in directory with go.mod Golang Cloud SDK-gcloud应用部署无法找到导入包 - Golang Cloud SDK - gcloud app deploy cannot find import package 为什么 Go 程序挂在 gcloud app deploy 上? - Why is Go program hanging on gcloud app deploy? app.yaml api_version的问题将Google AppEngine从Go 1.9迁移到Go 1.11 - Problems with app.yaml api_version migrating Google AppEngine from Go 1.9 to Go 1.11 使用 go.mod 部署到 google app engine flexible 失败,因为它正在 GOPATH 中寻找依赖库 - Deploying to google app engine flexible with go.mod fails because it is looking for dependent libraries in GOPATH go build -mod=mod 没有 go.mod - go build -mod=mod with no go.mod
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM