First Appengine experience

gmarik 6 min
Table Of Contents ↓

or how I almost had to invert a binary tree to use it.

Good

Google announced ‘Always Free’ products during its Google Cloud Next‘17

Plus, we’re introduced new Always Free products – non-expiring usage limits that you can use to test and develop applications at no cost. Visit the Google Cloud Platform Free Tier page for details.

(see FAQ for more)

It’s a great incentive to start tinkering with Google’s infrastructure I must say. Unfortunately the experience using it is not that great as it should be in my opinion. Below is my log trying to launch a “hello world” on Appengine

I’ve been following Go web workshop by Francesc Campoy which is a great tutorial to get started.

But I got stuck at Section 4 at deploying the app.

For some reason I had to do way more than tutorial describes and the Appengine developer experience was definitely not “google level”.

Bad

Right at deployment step I got an error:

gosq$ goapp deploy --version=1 --application=appname-123456

02:31 AM Application: appname-123456; version: None
Error 404: --- begin server output ---
This application does not exist (project_id=u'appname-123456'). To create an App Engine application in this project, run "gcloud beta app create" in your console.
--- end server output ---
error while running appcfg.py: exit status 1

Quick Googling/stackoverflowing didn’t help so I had to follow with an actual error message:

To create an App Engine application in this project, run "gcloud beta app create" in your console

Google Cloud SDK

gcloud is part of Google Cloud SDK and has to be downloaded from Google Cloud SDK downloads page.

Once downloaded I proceeded:

gosq$ gcloud beta app deploy
You do not currently have this command group installed.  Using it
requires the installation of components: [beta]

Your current Cloud SDK version is: 146.0.0
Installing components from version: 146.0.0

┌─────────────────────────────────────────────┐
│     These components will be installed.     │
├──────────────────────┬────────────┬─────────┤
│         Name         │  Version   │   Size  │
├──────────────────────┼────────────┼─────────┤
│ gcloud Beta Commands │ 2016.01.12 │ < 1 MiB │
└──────────────────────┴────────────┴─────────┘

For the latest full release notes, please visit:
  https://cloud.google.com/sdk/release_notes

Do you want to continue (Y/n)?

WTF? Hasn’t I just downloaded the SDK? I stopped the process and tried without beta:

gosq$ gcloud app create
ERROR: (gcloud.app.create) The required property [project] is not currently set.
You may set it for your current workspace by running:

  $ gcloud config set project VALUE

or it can be set temporarily by the environment variable [CLOUDSDK_CORE_PROJECT]

Okay, let’s try to set it:

gosq$ gcloud config set project appname-123456
Updated property [core/project].

Woot! Worked! Okay back to creating the app:

gosq$ gcloud app create
ERROR: (gcloud.app.create) You do not currently have an active account selected.
Please run:

  $ gcloud auth login

to obtain new credentials, or if you have already logged in with a
different account:

  $ gcloud config set account ACCOUNT

to select an already authenticated account to use.

Hm, not so fast!

gosq$ gcloud auth login
Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?redirect_uri=*********

WARNING: `gcloud auth login` no longer writes application default credentials.
If you need to use ADC, see:
  gcloud auth application-default --help

You are now logged in as [******@gmail.com].
Your current project is [appname-123456].  You can change this setting by running:

$ gcloud config set project PROJECT_ID

Alright logged in! Let’s deploy with goapp again. And failed just like above! Damn.

But apparently gcloud does deploys too so let’s try that one:

gosq$ gcloud app deploy
ERROR: The [application] field is specified in file [gosq/app.yaml]. This field is not used by gcloud and must be removed. Project name should instead be specified either by `gcloud config set project MY_PROJECT` or by setting the `--project` flag on individual command executions.
ERROR: (gcloud.app.deploy) Errors occurred while parsing the App Engine app configuration.

So the application property that tutorial mentions is invalid so I had to remove that one and retry:

gosq$ gcloud app deploy
You are creating an app for project [appname-123456].
WARNING: Creating an App Engine application for a project is irreversible and the region
cannot be changed. More information about regions is at
https://cloud.google.com/appengine/docs/locations.

Please choose the region where you want your App Engine application 
located:

 [1] europe-west   (supports standard)
 [2] us-central    (supports standard and flexible)
 [3] us-east1      (supports standard and flexible)
 [4] asia-northeast1 (supports standard and flexible)
 [5] cancel

Please enter your numeric choice: 

I typed 3 and pressed enter, it proceeded:

Creating App Engine application in project [appname-123456] and region [us-east1]....done.
You are about to deploy the following services:
 - appname-123456/default/20170311t023516 (from [~/gosq/app.yaml])
     Deploying to URL: [https://appname-123456.appspot.com]

Do you want to continue (Y/n)?  y

Yes, I agreed to continue:

Beginning deployment of service [default]...
The component [app-engine-go] is required for staging this 
application.


Your current Cloud SDK version is: 146.0.0
Installing components from version: 146.0.0

┌────────────────────────────────────────────────────┐
│        These components will be installed.         │
├───────────────────────────────┬─────────┬──────────┤
│              Name             │ Version │   Size   │
├───────────────────────────────┼─────────┼──────────┤
│ App Engine Go (MacOS, x86_64) │  1.9.50 │ 47.7 MiB │
│ App Engine Go Extensions      │         │          │
│ gcloud app Python Extensions  │  1.9.50 │  7.2 MiB │
└───────────────────────────────┴─────────┴──────────┘

For the latest full release notes, please visit:
  https://cloud.google.com/sdk/release_notes

Do you want to continue (Y/n)?  Y

What? More stuff to download? What is this? Fine, and pressed Y :

╔════════════════════════════════════════════════════════════╗
╠═ Creating update staging area                             ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: App Engine Go (MacOS, x86_64)                ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: App Engine Go Extensions                     ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Installing: gcloud app Python Extensions                 ═╣
╠════════════════════════════════════════════════════════════╣
╠═ Creating backup and activating new installation          ═╣
╚════════════════════════════════════════════════════════════╝

Performing post processing steps...done.                                                                                                                                                                                                                                        

Update done!

Restarting command:
  $ gcloud app deploy

You are about to deploy the following services:
 - appname-123456/default/000000000000000 (from [~/gosq/app.yaml])
     Deploying to URL: [https://appname-123456.appspot.com]

Do you want to continue (Y/n)?  y

Now it asked me if I want to deploy…this must be a joke because I’ve been trying to do that for hours now…

Beginning deployment of service [default]...
File upload done.
Updating service [default]...done.                                                                                                                                                                                                                                              
Deployed service [default] to [https://appname-123456.appspot.com]

You can stream logs from the command line by running:
$ gcloud app logs tail -s default

To view your application in the web browser run:

$ gcloud app browse

Okay, now we’re done. Took me too long too troubleshoot it.

Summary

Read More
How to code review
Wordfight: a multi-player word game
Comments
read or add one↓