appengine icon indicating copy to clipboard operation
appengine copied to clipboard

trouble getting started

Open kevinburke opened this issue 7 years ago • 5 comments

I'm trying to port x/build/devapp (which powers dev.golang.org) to App Engine Flex, since the normal App Engine context only supports the (now deprecated) Go 1.6, that project depends on code that no longer supports Go 1.6, and I've been unable to find any information about when it will upgrade.

Here are some problems I've run into. Hopefully these will be helpful in figuring out how/where other people are getting stuck.

  • The documentation for Appengine Flex states:

    The flexible environment is intended to be complementary to the standard environment. If you have an existing application running in the standard environment, it’s not usually necessary to migrate the entire application to the flexible environment. Instead, identify the parts of your application that require more CPU, more RAM, a specialized third-party library or program, or that need to perform actions that aren’t possible in the standard environment. Once you’ve identified these parts of your application, create small App Engine services that use the flexible environment to handle just those parts. Your existing service running in the standard environment can call the other services using HTTP, Task Queues, or Cloud Pub/Sub.

    That seems to indicate that it's more of a replacement for something like EC2 spot instances, not for running a fixed-size webapp. But this is the only environment that supports Go 1.8, and seems to be getting more of the fixes that let you run a Go application (like an unencumbered HTTP client), so I'm really confused about which one I should be using going forward.

  • aedeploy gcloud app deploy takes about 20 minutes, minimum, to deploy a new version. This seems long compared with e.g. a go build on Heroku, which completes in about 20 seconds. I understand the build process is considerably more involved here, but it's not clear from the build output or the log file how long I should expect it to take, or how long to wait for it to complete.

  • I ran into an error message pointing me to this link pretty early on when developing for Flex: https://godoc.org/google.golang.org/appengine#Main. That seems fine, though I'd like my app to be easily deployable without app engine as well. So my package main has two entrypoints:

    main.go

    // Copyright 2017 The Go Authors. All rights reserved.
    / Use of this source code is governed by a BSD-style
    / license that can be found in the LICENSE file.
    
    / Devapp generates the dashboard that powers dev.golang.org.
    /
    / Usage:
    /
    /	devapp --port=8081
    /
    / By default devapp listens on port 8081.
    /
    / Github issues and Gerrit CL's are stored in memory in the running process.
    / To trigger an initial download, visit http://localhost:8081/update or
    / http://localhost:8081/update/stats in your browser.
    
    / +build !appengine
    
    ackage main
    
    mport (
    "flag"
    "fmt"
    "log"
    "net"
    "net/http"
    "os"
    
    _ "golang.org/x/build/devapp"
    
    
    unc init() {
    flag.Usage = func() {
    	os.Stderr.WriteString(`usage: devapp [-port=port]
    
    evapp generates the dashboard that powers dev.golang.org.
    )
    	os.Exit(2)
    }
    
    
    unc main() {
    port := flag.Uint("port", 8081, "Port to listen on")
    flag.Parse()
    ln, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
    if err != nil {
    	log.Fatal(err)
    }
    fmt.Fprintf(os.Stderr, "Listening on port %d\n", *port)
    log.Fatal(http.Serve(ln, nil))
    
    

    appengine_main.go

    	// Copyright 2017 The Go Authors. All rights reserved.
    / Use of this source code is governed by a BSD-style
    / license that can be found in the LICENSE file.
    
    / Build for running on app engine flex, following the instructions set here:
    / https://godoc.org/google.golang.org/appengine#Main
    
    / +build appengine
    
    ackage main
    
    mport (
    // this registers HTTP handlers
    _ "golang.org/x/build/devapp"
    "google.golang.org/appengine"
    
    
    unc main() {
    appengine.Main()
    
    

    However I can't figure out which build tag to set. In particular the flex build log seems to indicate that it's running go install -v -tags appenginevm. But I tried using that build tag (instead of // +build appengine) and still got Listening on port 8081 in the logs in the Google Cloud console, indicating that main.go was running, and not the appenginevm file. I'm confused about which build tags will trigger for the build environment and I can find nothing about it in the documentation. The aefix tool also doesn't seem to mention or parse build tags.

  • The readme for this project says to set vm: true in your app.yaml. But the getting started guide says to set env: flex in your app.yaml (https://cloud.google.com/appengine/docs/flexible/go/quickstart). These can't coexist and I'm confused about which one to set.

  • It would be nice if there was a timeline or some more information around the appearance of Go 1.7 or Go 1.8 in the standard environment; will it go live within a month? Within 3-6 months? Never?

So right now I'm stuck; I haven't been able to actually see any of the code I pushed live, though I have gotten a lot of 502 and 404 error pages. I pushed my changes here if you can help me figure out what I'm doing wrong. https://github.com/kevinburke/build/commit/d1b15091134215ab7266a8d33f24b87ee751eb86

kevinburke avatar Mar 14 '17 07:03 kevinburke

My next thought was to ditch the build flags and do something like this:

func main() {
	appengine := flag.Bool("appengine", false, "Run in the appengine environment")
	port := flag.Uint("port", 8081, "Port to listen on")
	flag.Parse()
	if *appengine {
		appengine.Main()
	} else {
		ln, err := net.Listen("tcp", fmt.Sprintf(":%d", *port))
		if err != nil {
			log.Fatal(err)
		}
		fmt.Fprintf(os.Stderr, "Listening on port %d\n", *port)
		log.Fatal(http.Serve(ln, nil))
	}
}

Though I realize now there's no way to pass a build flag to the main function on App Engine.

kevinburke avatar Mar 14 '17 17:03 kevinburke

will app engine standard always be go 1.6?

robert-king avatar Mar 23 '17 01:03 robert-king

@robert-king One of GAE Go devs said they going to update the Standard to 1.8 but no timelines except "soon".

So it can be tomorrow, can be next month, can be in a year. Or never.

It's frustrating.

trakhimenok avatar Mar 28 '17 15:03 trakhimenok

They have now updated their timeline by saying that Go 1.8 AE should be released by the end of June at the latest (this is my perspective from their comments). One of the Go devs said this on June 9, so it is the latest information, and they have some more fixes this week, so if all of those go through well, then they should be good to go.

adhiravishankar avatar Jun 12 '17 18:06 adhiravishankar

For anyone that comes across this ... Go 1.8 is now available in beta on AppEngine Standard (yay)

Re: the Flex config - anything that includes vm: true is for the old version of flex which was deprecated / never released (and is due to be turned off later this year). The env: flex reference means it's talking about the new, supported one.

I've found GCE + a Docker image (on the Docker Optimized instances) has worked better for when I need to step outside of AppEngine Standard. The http load balancer + auto-scaling groups make it usable for front-end instances and without much effort.

CaptainCodeman avatar Jul 07 '17 22:07 CaptainCodeman