Appengine Go1.11 beta deployment failure - google-app-engine

I am trying my hands on Go, and started with the go1.11 beta.
The first Hello world example worked fine and I was able to view it via the browser.
In my second attempt, I created multiple .go files (main.go, datastore.go).
I am able to run it locally and it works fine.
However when I attempt to deploy, I get the following error (deployment in first example worked just fine):
gcloud app deploy
...
File upload done.
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 67d67177-13cd-4e80-980a-ea36a0760678 status: FAILURE.
Build error details: go build: cannot use -o with multiple packages
On the server, the build logs show:
Step #1 - "builder": building app with command '[go build -o /tmp/staging735225713/usr/local/bin/start ./...]', env '[PATH=/go/bin:/usr/local/go/bin:/builder/google-cloud-sdk/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=d0f271c7f5b8 HOME=/builder/home BUILDER_OUTPUT=/builder/outputs DEBIAN_FRONTEND=noninteractive GOROOT=/usr/local/go/ GOPATH=/go GOPATH=/tmp/staging735225713/srv/gopath]': err=exit status 1, out=go build: cannot use -o with multiple packages
Finished Step #1 - "builder"
ERROR
ERROR: build step 1 "gcr.io/gae-runtimes/go111_app_builder:go111_20181212_RC00" failed: exit status 1
What am I doing wrong?
UPDATE:
Tried various things, including subfolder or a 'vendor' folder as suggested, but no avail.
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 79c39e82-3185-4ae1-a7ff-6afa1be448e7 status: FAILURE.
Build error details: srv/proto/myfile.pb.go:8:2: cannot find package "github.com/golang/protobuf/proto" in any of:
/usr/local/go/src/github.com/golang/protobuf/proto (from $GOROOT)
/tmp/staging770905501/srv/gopath/src/github.com/golang/protobuf/proto (from $GOPATH)

Related

Why would an AppEngine deploy fail with a build failure?

I started working on an app and suddenly it fails to deploy to appengine, with the following error message:
siim#pebble:~/projects/xyz$ gcloud app deploy
Services to deploy:
descriptor: [/home/siim/projects/xyz/app.yaml]
source: [/home/siim/projects/xyz]
target project: [xyz]
target service: [default]
target version: [20220313t182940]
target url: [https://xyz.uc.r.appspot.com]
target service account: [App Engine default service account]
Do you want to continue (Y/n)? y
Beginning deployment of service [default]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 2 files to Google Cloud Storage ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 016c4604-6ea6-47df-8144-e7f1471c6df6 status: FAILURE
removing /layers/google.go.gomod/gopath: unlinkat /layers/google.go.gomod/gopath/pkg/mod/github.com/golang/protobuf#v1.3.1/regenerate.sh: permission denied
Full build logs: https://console.cloud.google.com/cloud-build/builds;region=us-central1/016c4604-6ea6-47df-8144-e7f1471c6df6?project=576574664421
Clicking through to the build log, I see:
===> DETECTING
google.go.appengine_gomod 0.9.0
google.go.gomod 0.9.0
google.go.build 0.9.0
google.go.appengine 0.9.0
google.utils.label 0.0.2
===> ANALYZING
Previous image with name "us.gcr.io/xyz/app-engine-tmp/app/default/ttl-18h:69af35b6-6fc6-4167-88f3-da16f9cfc7e7" not found
Restoring metadata for "google.go.gomod:gopath" from cache
===> RESTORING
Restoring data for "google.go.gomod:gopath" from cache
===> BUILDING
=== App Engine Gomod (google.go.appengine_gomod#0.9.0) ===
--------------------------------------------------------------------------------
Running "cp --dereference -R . /layers/google.go.appengine_gomod/srv"
Done "cp --dereference -R . /layers/google.go.appengine_gomod/srv" (53.220262ms)
=== Go - Gomod (google.go.gomod#0.9.0) ===
DEBUG: go.mod SHA has changed: clearing GOPATH layer's cache
Failure: (ID: f51775d1) removing /layers/google.go.gomod/gopath: unlinkat /layers/google.go.gomod/gopath/pkg/mod/github.com/golang/protobuf#v1.3.1/regenerate.sh: permission denied
--------------------------------------------------------------------------------
Running "mv -f /builder/outputs/output-5577006791947779410 /builder/outputs/output"
Done "mv -f /builder/outputs/output-5577006791947779410 /builder/o..." (5.980458ms)
ERROR: failed to build: exit status 1
I'm completely mystified by this. AFAICT this is something AppEngine does internally so I don't think I have any way to debug this further? FWIW, my app is super simple ATM:
module xyz
go 1.17
require (
github.com/go-chi/chi/v5 v5.0.7
go.etcd.io/bbolt v1.3.6
google.golang.org/appengine/v2 v2.0.1
)
require (
github.com/golang/protobuf v1.3.1 // indirect
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d // indirect
)
And:
runtime: go116
main: ./cmd/server
The solution was to go to container registry (maybe artifact registry soon) in the cloud console and delete all the containers there. The issue was quite likely just one of those images (maybe the build cache one) but my app is not released so I could just delete all of them.
I resolve it using --no-cache option, but its not perfect because cache is not enabled.
$ gcloud app deploy app.yaml --no-cache

Why can't I deploy to GAE using the gcloud command in go?

I'm trying to deploy an application written in go to GAE. When I call gcloud app deploy it says this:
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 64850a38-3b7b-4223-97bc-27643b8ab1d5 status: FAILURE.
Build error details: go build: cannot use -o with multiple packages
.
Check the build log for errors: https://console.cloud.google.com/gcr/builds/64850a38-3b7b-4223-97bc-27643b8ab1d5?project=609165667740
I have looked everywhere but I can't find information related to this error in this context.

GAE deployment failing

I'm using GAE for a Laravel PHP site and using flex instances. I've always had no problem doing a "gcloud app deploy" to get my app deployed. However, for the last 24 hours or so when I attempt to deploy I get the following error:
Step #1: Package manifest generated successfully.
Step #1: > chmod -R 755 bootstrap/cache
Step #1: > php artisan cache:clear
Step #1:
Step #1: In AbstractConnection.php line 155:
Step #1:
Step #1: Connection timed out [tcp://1.2.3.4:6379]
Step #1:
Step #1:
Step #1: Script php artisan cache:clear handling the post-install-cmd event returned with error code 1
Step #1: The command '/bin/sh -c /build-scripts/composer.sh' returned a non-zero code: 1
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/docker#sha256:12345" failed: exit status 1
Step #1:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at https://console.cloud.google.com/gcr/builds/12345?project=1234 Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details
I have a Memorystore (redis) instance I use since GAE memcache isn't available on flex instances yet. My app uses redis as a cache, so as you can see above, once the new code is deployed composer is configured to clear the cache, which is where it's timing out and failing.
If I SSH into an existing instance, I can run php artisan cache:clear no problem. However, it's failing on deploy. It's a pretty simple code change that's only UI tweaks (html/javascript) so none of the redis or connection code has changed.
Any ideas?

conversation+discovery java code is working

I am trying to run the sample java watson conversation with discovery service in my IBM account.
I have created the java app and added the service details in environment variables and tried to deploy the code but getting below error .
please let me know what is the cause for this issue.
Preparing to start the job...
Cloning the 'master' branch from repo 'https://git.eu-gb.bluemix.net/anil.narayanaswamy002/tnchatbot.git'
Repository successfully cloned
Download https://plugins.gradle.org/m2/com/moowork/gradle/gradle-node-plugin/0.12/gradle-node-plugin-0.12.pom
Download https://plugins.gradle.org/m2/com/moowork/gradle/gradle-gulp-plugin/0.12/gradle-gulp-plugin-0.12.pom
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'conversation-with-discovery'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve org.codehaus.groovy:groovy-backports-compat23:2.3.5.
Required by:
com.ibm.watson.wea.app:conversation-with-discovery:0.5.0-SNAPSHOT
Could not GET 'https://plugins.gradle.org/m2/org/codehaus/groovy/groovy-backports-compat23/2.3.5/groovy-backports-compat23-2.3.5.pom'.
peer not authenticated
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.217 secs
Finished: FAILED

AppEngine Deploy is Conflicting SHA1 sum for a file

I want to deploy an update to our app but we have an issue with gcloud command which failed to "Conflicting SHA1 sum for file". Here is the output:
➜ gcloud app deploy xxx-xxx-xxxx.yaml --project xxx-xxx-xxxx --quiet
Services to deploy:
descriptor: [/home/vzool/Workspace/xxx-xxxx-xxxxxxxxxxx/xxx-xxx-xxxx.yaml]
source: [/home/vzool/Workspace/xxx-xxxx-xxxxxxxxxxx]
target project: [xxx-xxx-xxxx]
target service: [default]
target version: [20180917t110153]
target url: [https://xxx-xxx-xxxx.appspot.com]
Beginning deployment of service [default]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 1 file to Google Cloud Storage ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [3] The following errors occurred while copying files to App Engine:
File https://storage.googleapis.com/staging.xxx-xxx-xxxx.appspot.com/c819d7599ceb31df8d4370eed1981defcb5034c6 failed with: Conflicting SHA1 sum for file. Expected "ddb6af3b_cf4bff57_613fb78d_208480fa_1717b3c4" but received "c819d759_9ceb31df_8d4370ee_d1981def_cb5034c6".
Details: [
[
{
"#type": "type.googleapis.com/google.rpc.ResourceInfo",
"description": "Conflicting SHA1 sum for file. Expected \"ddb6af3b_cf4bff57_613fb78d_208480fa_1717b3c4\" but received \"c819d759_9ceb31df_8d4370ee_d1981def_cb5034c6\".",
"resourceName": "https://storage.googleapis.com/staging.xxx-xxx-xxxx.appspot.com/c819d7599ceb31df8d4370eed1981defcb5034c6",
"resourceType": "file"
}
]
]
I do delete this file c819d7599ceb31df8d4370eed1981defcb5034c6 but everytime new hash will be generated, delete entire block staging.xxx-xxx-xxxx.appspot.com and I did clear Memcache but with no luck trying all these options! :(
I don't know what to do anymore with this, any suggestions may help me out?
Thanks
I think after sometime in research the issue, the app itself has a live feature which lead to update one file while you open live page.
So, that change what gcloud uploaded.
gcloud upload then verify. And if file changed after upload and before verify gcloud will through this error on your face. Ha ha ha ^_^
OP's answer seemed to indicate that a file got touched during the gcloud deploy process.
The solution for me was to:
git checkout some random branch
git checkout the branch I was actually trying to deploy again
run gcloud app deploy . --version my_version_id --project my_project_id

Resources