Flex env migration, many questions.

132 views
Skip to first unread message

Kun Li

unread,
Dec 15, 2017, 12:57:41 AM12/15/17
to google-appengine-go
Long story short, I'm trying to migrate my backend from managed vm to flex env, and just can not get it deployed. Any help is appreciated because seems like today is the deadline for migration, my whole service could be down if I don't find a way out.

1. I heard that I can submit my application to a whitelist which allows it to keep on running even after 15th. I filled in the form this morning but haven't heard back anything yet. How can I confirm if my app is already whitelisted? And do I still need to do anything if it's whitelisted? This would be the ideal solution for me now, because I still haven't found solution for all my task queues yet.

2. Meanwhile I do want to continue my effort for migration. I have commented out all incompatible code, updated all necessary packages, and I can compile the code locally now. However, when I try to deploy, there is an error. Interestingly the instance does appear in the console for a while, then it disappears, and I can still send request to it! Can anyone help me to understand what's going on here? This is the error message returned:

Updating service [backend] (this may take several minutes)...\DEBUG: Operation [apps/xxx/operations/b841c050-d8d0-4277-a2f9-68072535ba7e] complete. Result: {
"metadata": {
"target": "apps/xxx/services/backend/versions/20171214t223730",
"method": "google.appengine.v1.Versions.CreateVersion",
"user": "xxxx",
"insertTime": "2017-12-15T05:38:21.579Z",
"ephemeralMessage": "Deployment failed. Attempting to cleanup deployment artifacts.",
},
"done": true,
"name": "apps/xxx/operations/b841c050-d8d0-4277-a2f9-68072535ba7e",
"error": {
"message": "\nApplication startup error:\n+ exec app\n",
"code": 9
}
}
Updating service [backend] (this may take several minutes)...failed.
DEBUG: (gcloud.app.deploy) Error Response: [9]
Application startup error:
+ exec app

3. I have some custom commands in my old Dockerfile in order to compile some of the C++ code to binaries for my Go code to invoke. Now flex env Go runtime doesn't allow Dockerfile, what's the recommended way to handle this? I can think of one way, which is to call the compiler directly in the main func using exec library. However, how do I guarantee all the necessary compilers are installed on the host machine without the Dockerfile?

Derek Perkins

unread,
Dec 15, 2017, 1:35:37 AM12/15/17
to google-appengine-go
3. I have some custom commands in my old Dockerfile in order to compile some of the C++ code to binaries for my Go code to invoke. Now flex env Go runtime doesn't allow Dockerfile, what's the recommended way to handle this?

Dockerfiles are definitely still supported. We use them now and the docs are here. What makes you think that they aren't allowed?

I can think of one way, which is to call the compiler directly in the main func using exec library. However, how do I guarantee all the necessary compilers are installed on the host machine without the Dockerfile?

This sounds like a terrible rabbit hole that I wouldn't wish on my worst enemy. :) Just use a Dockerfile multi-step build and don't include any compilers on the host machine. 

Kun Li

unread,
Dec 15, 2017, 2:38:55 AM12/15/17
to Derek Perkins, google-appengine-go
I just saw that page, so the third questions is answered. 

I also figured out what's wrong with the second question too, it turns out the deployment will fail if I don't put "appengine.Main()" in my main func. Which is kind of strange and silly because the examples in the doc don't have "appengine.Main()" in main func either. If this is absolutely required, don't you want to make it crystal clear on the doc page?

Anyway, it seems like some of the endpoints are broken, so I will dedicate most of my time on those issues. It would still be nice to know the answer for question 1.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine-go/ac91f58c-5e77-41e2-8d73-170872fd26b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kun Li

unread,
Dec 15, 2017, 2:59:35 PM12/15/17
to google-appengine-go
Okay, so the answer to the first question is that once my app is added to whitelist, I got the email confirmation and then everything is good. Thanks!


On Friday, December 15, 2017 at 12:38:55 AM UTC-7, Kun Li wrote:
I just saw that page, so the third questions is answered. 

I also figured out what's wrong with the second question too, it turns out the deployment will fail if I don't put "appengine.Main()" in my main func. Which is kind of strange and silly because the examples in the doc don't have "appengine.Main()" in main func either. If this is absolutely required, don't you want to make it crystal clear on the doc page?

Anyway, it seems like some of the endpoints are broken, so I will dedicate most of my time on those issues. It would still be nice to know the answer for question 1.

On Thu, Dec 14, 2017 at 11:35 PM Derek Perkins <de...@derekperkins.com> wrote:
3. I have some custom commands in my old Dockerfile in order to compile some of the C++ code to binaries for my Go code to invoke. Now flex env Go runtime doesn't allow Dockerfile, what's the recommended way to handle this?

Dockerfiles are definitely still supported. We use them now and the docs are here. What makes you think that they aren't allowed?

I can think of one way, which is to call the compiler directly in the main func using exec library. However, how do I guarantee all the necessary compilers are installed on the host machine without the Dockerfile?

This sounds like a terrible rabbit hole that I wouldn't wish on my worst enemy. :) Just use a Dockerfile multi-step build and don't include any compilers on the host machine. 

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.

Herbie Ong

unread,
Jan 22, 2018, 5:22:48 PM1/22/18
to google-appengine-go

Sorry, I just noticed your posting.  It seems like you are doing a custom Flex runtime by providing your own Dockerfile.  You shouldn't need to use appengine.Main in your main func if that is the case.

Do make sure that your app.yaml is configured properly for a custom runtime, i.e. it should contain `runtime: custom`.

-- Herbie

Kun Li

unread,
Jan 23, 2018, 12:51:36 PM1/23/18
to Herbie Ong, google-appengine-go
Whenever I remove appengine.Main I got this error:

ERROR: (gcloud.app.deploy) Error Response: [9] 

Application startup error:

+ exec app


aedeploy: Error: unable to run "gcloud app deploy": exit status 1


To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine-go/9f7c1b18-2cbe-4ae4-9b02-22ff20fe5946%40googlegroups.com.

Herbie Ong

unread,
Jan 23, 2018, 1:17:24 PM1/23/18
to google-appengine-go

Are you using aedeploy still?  Do use `gcloud app deploy` directly instead as mentioned in these docs -- https://cloud.google.com/appengine/docs/flexible/custom-runtimes/testing-and-deploying-your-app#remote-container-build

-- Herbie


On Tuesday, January 23, 2018 at 9:51:36 AM UTC-8, Kun Li wrote:
Whenever I remove appengine.Main I got this error:

ERROR: (gcloud.app.deploy) Error Response: [9] 

Application startup error:

+ exec app


aedeploy: Error: unable to run "gcloud app deploy": exit status 1


On Mon, Jan 22, 2018 at 3:22 PM 'Herbie Ong' via google-appengine-go <google-ap...@googlegroups.com> wrote:

Sorry, I just noticed your posting.  It seems like you are doing a custom Flex runtime by providing your own Dockerfile.  You shouldn't need to use appengine.Main in your main func if that is the case.

Do make sure that your app.yaml is configured properly for a custom runtime, i.e. it should contain `runtime: custom`.

-- Herbie


On Friday, December 15, 2017 at 11:59:35 AM UTC-8, Kun Li wrote:
Okay, so the answer to the first question is that once my app is added to whitelist, I got the email confirmation and then everything is good. Thanks!

On Friday, December 15, 2017 at 12:38:55 AM UTC-7, Kun Li wrote:
I just saw that page, so the third questions is answered. 

I also figured out what's wrong with the second question too, it turns out the deployment will fail if I don't put "appengine.Main()" in my main func. Which is kind of strange and silly because the examples in the doc don't have "appengine.Main()" in main func either. If this is absolutely required, don't you want to make it crystal clear on the doc page?

Anyway, it seems like some of the endpoints are broken, so I will dedicate most of my time on those issues. It would still be nice to know the answer for question 1.

On Thu, Dec 14, 2017 at 11:35 PM Derek Perkins <de...@derekperkins.com> wrote:
3. I have some custom commands in my old Dockerfile in order to compile some of the C++ code to binaries for my Go code to invoke. Now flex env Go runtime doesn't allow Dockerfile, what's the recommended way to handle this?

Dockerfiles are definitely still supported. We use them now and the docs are here. What makes you think that they aren't allowed?

I can think of one way, which is to call the compiler directly in the main func using exec library. However, how do I guarantee all the necessary compilers are installed on the host machine without the Dockerfile?

This sounds like a terrible rabbit hole that I wouldn't wish on my worst enemy. :) Just use a Dockerfile multi-step build and don't include any compilers on the host machine. 

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.

Kun Li

unread,
Jan 23, 2018, 2:22:31 PM1/23/18
to Herbie Ong, google-appengine-go
Does this require me to use some dependency management tool like Glide?

Also I was basically using the same Dockerfile I used for managed vm before, and it has 

RUN go-wrapper download
RUN go-wrapper install -tags appenginevm

in the end of file. The `go-wrapper download` gives me trouble if I just do `gcloud app deploy`. It would fail all the time with error "returned a non-zero code: 1".

Do I still need these two lines if I don't do `aedploy`?  I attached my docker file here just in case it's helpful.

To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine-go/f3b15ff4-2bac-4f24-ae64-f79ab21a5100%40googlegroups.com.
Dockerfile

Herbie Ong

unread,
Jan 23, 2018, 2:52:32 PM1/23/18
to google-appengine-go

I'm not familiar with go-wrapper.  Looking at the source, seems like go-wrapper download will do a `go get` for dependencies.  It may require that your source files are put in certain location or GOPATH being set properly.

If you have all the dependencies already in your local GOPATH workspace, then you shouldn't need to call `go-wrapper download`.

If you simply want an image with the latest Go SDK, I'd recommend using gcr.io/gcp-runtimes/go1-builder instead.  The source repo for its Dockerfile is here -- https://github.com/GoogleCloudPlatform/golang-docker/tree/master/runtime-builder and there's a simple README that shows using a multi-stage Dockerfile.  Currently that builder image is based off debian8, so similarly you can use apt-get to grab the C++ tools and libs.  You can then use invoke the go tool from /usr/local/go/bin.

-- Herbie

To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine-go+unsub...@googlegroups.com.

Kun Li

unread,
Jan 23, 2018, 7:08:08 PM1/23/18
to Herbie Ong, google-appengine-go
Hi Herbie,

I'm not very familiar with how the deployment of flex env works so bear with me on some basic questions. 

I don't understand why is that If I have all the dependencies already in my local GOPATH workspace, then I shouldn't need to call `go-wrapper download`? Which step in the Docker file actually install those dependencies for me?

I don't know the advantage of having two stage Dockerfile either. What advantage it brings to me?

I do updated my dockerfile a little bit based on the runtime-builder file you put there, and this is the latest version,



RUN apt-get update
RUN apt-get install --no-install-recommends -y -q apt-utils curl build-essential bzr git
RUN apt-get install --no-install-recommends -y -q cmake gcc-multilib g++-multilib libc6-dev-i386 lib32z1-dev lib32ncurses5 lib32stdc++6

COPY . /go/src/app
WORKDIR /go/src/app
RUN cd ./drivers/fit && bash cmake
RUN go build -o app .
CMD ["app"]


But when I deploy, no dependency is installed so all of them are missing. Does it mean if I want to remove aedeploy, I will have to use the dependency management tool?


To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine-go/0faa2c31-f729-47c9-9a35-b5bcd51197a3%40googlegroups.com.

Herbie Ong

unread,
Jan 24, 2018, 12:40:56 AM1/24/18
to google-appengine-go


On Tuesday, January 23, 2018 at 4:08:08 PM UTC-8, Kun Li wrote:
Hi Herbie,

I'm not very familiar with how the deployment of flex env works so bear with me on some basic questions.

Since you are going with a custom runtime, it's mostly about building your application Docker image.  If you can build the image using docker, then it's very similar.

You just need to make sure you have `runtime: custom` and `env: flex` in your app.yaml file.  What gcloud does is upload files from the directory where app.yaml resides, which is also where the Dockerfile for your app should exist.  Once uploaded, it will run docker on that directory.

Having said that, if you have a local GOPATH workspace with all the sources available (i.e you have previously downloaded them say using go get already or check them out from some repos), e.g.

$GOPATH/src/foo/bar/...

When defining the Dockerfile, you'll want to have the same structure inside the image for the go tool to build.  So, one simple suggestion is to have app.yaml and Dockerfile at the root of $GOPATH/src when you run `gcloud app deploy` and with the following Dockerfile command ...

COPY . /go/src/

Above will copy all files and directories from your local $GOPATH/src/ to the image's /go/src/.  Set GOPATH env inside the image to point to /go directory, and run the `go build` or `go install` command appropriately.  It's basically setting up a GOPATH environment inside the image to do the build.

 

I don't understand why is that If I have all the dependencies already in my local GOPATH workspace, then I shouldn't need to call `go-wrapper download`? Which step in the Docker file actually install those dependencies for me?

As mentioned above, if you have all the dependencies, then you can simply just copy those into the image.  If you do prefer to download the dependencies during the docker build phase, you can do so too.  go-wrapper download is just calling `go get` which you can apply directly as long as you have the right workspace configured.

 

I don't know the advantage of having two stage Dockerfile either. What advantage it brings to me?

It is not required to use multi-stage Dockerfile.  A multi-stage Dockerfile allows for having a smaller resulting image w/o the extra binaries/libraries that were used for building the application, e.g. Go SDK, C++ compiler, etc.  The idea is that you grab all tools necessary for doing builds in the first stage, and on second stage or following stages, you simply gather up the files (built binaries, resource files, etc.) and put them into the final resulting image.  It can save a decent amount of disk space.

For more info about multi-stage Dockerfile, see https://docs.docker.com/engine/userguide/eng-image/multistage-build/.

Again, it is not required.  You can stay with a simple Dockerfile.



I do updated my dockerfile a little bit based on the runtime-builder file you put there, and this is the latest version,



RUN apt-get update
RUN apt-get install --no-install-recommends -y -q apt-utils curl build-essential bzr git
RUN apt-get install --no-install-recommends -y -q cmake gcc-multilib g++-multilib libc6-dev-i386 lib32z1-dev lib32ncurses5 lib32stdc++6

COPY . /go/src/app
WORKDIR /go/src/app
RUN cd ./drivers/fit && bash cmake
RUN go build -o app .
CMD ["app"]


But when I deploy, no dependency is installed so all of them are missing. Does it mean if I want to remove aedeploy, I will have to use the dependency management tool?

See above for my explanation and simple example on what you need to do.  I don't know the details of your workspace layout, but as I've mentioned above, the idea is to create a GOPATH workspace inside the image with all the source files for doing the build.  You can either copy them from your local GOPATH if they exists there or you can use `go get` to grab them.

Just to reiterate, since you are defining your own Dockerfile, you should be able to create the image locally using the docker tool to test it out.  Running `gcloud app deploy` is taking that step and doing it in Cloud container builder and then deploying the resulting image to your instances.  Here's info regarding custom runtimes -- https://cloud.google.com/appengine/docs/flexible/custom-runtimes/build.

Hope that helps.

Kun Li

unread,
Jan 24, 2018, 12:56:10 AM1/24/18
to Herbie Ong, google-appengine-go
Many thanks for the answer, I think it's more clear to me on how to test this process. I will give it a try tomorrow and keep you posted.

--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages