dongnuo2879 2018-04-08 11:49
浏览 75
已采纳

gcloud deploy应用无法找到导入包-Golang

I have already deployed a version of my app to GAE, but now I have trouble deploying a newer version. When I try gcloud app deploy --version=VERSION, I get a bunch of errors showing that remote build cannot find my import packages:

Beginning deployment of service [default]...
Building and pushing image for service [default]
Some files were skipped. Pass `--verbosity=info` to see which ones.
You may also view the gcloud log file, found at
[/home/****/.config/gcloud/logs/2018.04.08/***.log].
Started cloud build [***].
To see logs in the Cloud Console: https://console.cloud.google.com/gcr/builds/****?project=**

------------- REMOTE BUILD OUTPUT --------------------------------------------

starting build "****"

FETCHSOURCE
Fetching storage object: gs://staging.****.appspot.com/us.gcr.io/****/appengine/default.20180408t040210:latest#****
Copying gs://staging.****.appspot.com/us.gcr.io/****/appengine/default.***:latest#***...
/ [1 files][  6.9 MiB/  6.9 MiB]                                                
Operation completed over 1 objects/6.9 MiB.                                      
BUILD
Starting Step #0
Step #0: Pulling image: gcr.io/gcp-runtimes/go1builder@sha256:****
Step #0: sha256:***: Pulling from gcp-runtimes/go1-builder
Step #0: Digest: sha256:***
Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder@sha256:***
Step #0: main.go:5:2: cannot find package "config" in any of:
Step #0:    /usr/local/go/src/config (from $GOROOT)
Step #0:    /workspace/_gopath/src/config (from $GOPATH)
Step #0: main.go:6:2: cannot find package "db" in any of:
Step #0:    /usr/local/go/src/db (from $GOROOT)
Step #0:    /workspace/_gopath/src/db (from $GOPATH)
...
Finished Step #0
ERROR
ERROR: build step 0 "gcr.io/gcp-runtimes/go1builder@sha256:***" failed: exit status 1
-------------------------------------------------------------------------------

ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at https://console.cloud.google.com/gcr/builds/***?project=*** Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details

I have tried several suggestions wrt proper setting of the GOPATH, including running command as root, sudo -E, and setting a system-wide GOPATH, no luck so far. I get the same set of errors no matter if I deploy in Cloud Shell or run the command in my local setup. If I set a wrong GOPATH build fails before getting to the remote build stage. I have not changed the source code structure from the first deployment either.

I have spent lot's of time on this, and appreciate any help or advice. Thanks.

EDIT: Here is my app.yaml

runtime: go
env: flex
api_version: go1

env_variables:
   APP_DATABASE_CONFIG: "{...}"
   APP_CONFIG: "{...}"

Also running dev_appserver.py app.yaml I get the following output: dev_appserver.py app.yaml

INFO     2018-04-11 05:20:51,040 application_configuration.py:506] No version specified. Generated version id: 20180411t052051
WARNING  2018-04-11 05:20:51,040 application_configuration.py:163] The Managed VMs runtime is deprecated, please consider migrating your application to use the Flexible runtime. See https://cloud.google.com/appengine/docs/flexible/python/migrating for more details.
INFO     2018-04-11 05:20:51,040 devappserver2.py:105] Skipping SDK update check.
INFO     2018-04-11 05:20:51,102 api_server.py:265] Starting API server at: http://localhost:46211
INFO     2018-04-11 05:21:16,233 dispatcher.py:255] Starting module "default" running at: http://localhost:8080
INFO     2018-04-11 05:21:16,234 admin_server.py:152] Starting admin server at: http://localhost:8000
...

It generally works fine except for that warning at the beginning. I don't know why it gives that warning despite my app.yaml configuration, but if it helps the first instance I deployed was a standard project (the Google demo project), and I deleted that instance later.

I am wondering where those GOROOT (/usr/local/go/) and GOPATH (/workspace/_gopath/) on the remote side come from? Are those the default settings? Also if it helps, those db and config packages shown in error messages are mine, and they are under project-root/src.

app.yaml is under project-root/src/web. My GOPATH is set to project-root. My GOROOT is empty.

  • 写回答

1条回答 默认 最新

  • douzi6992 2018-04-11 12:21
    关注

    Your Flex app.yaml file should not include

    api_version: go1
    

    You can delete the line entirely. It is only needed for App Engine Standard.

    Here is an example App Engine Flexible app.yaml file. See the docs for a reference of what you can configure in a Flex app.yaml file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 有偿求qftp工具。能连接,下载文件,发送代码,windows环境,最好qt6 要qt creator写的
  • ¥70 刚刚看到一个人的网站居然是通过cname访问的
  • ¥15 Attributeerror:super object has no attribute '__sklearn_tags__'_'
  • ¥15 逆置单链表输出不完整
  • ¥15 宇视vms-B200-A16@R启动不了,如下图所示,在软件工具搜不到,如何解决?(操作系统-linux)
  • ¥500 寻找一名电子工程师完成pcb主板设计(拒绝AI生成式答案)
  • ¥15 关于#mysql#的问题:UNION ALL(相关搜索:sql语句)
  • ¥15 matlab二位可视化能否针对不同数值范围分开分级?
  • ¥15 已经创建了模拟器但是不能用来运行app 怎么办😭自己搞两天了
  • ¥15 关于#极限编程#的问题,请各位专家解答!