Set goproxy in cloud build on deploying to appengine - google-app-engine

We are deploying our Go app to Google app engine with the command: gcloud app deploy
This creates a cloud build, which normally works fine. However, sometimes there are some dependencies which are flaky (sometimes unavailable or down) or gone (revision no longer existing).
These issues break our complete deploy and build and we can only get rid of the dependency or wait until it is fixed on that side.
Solution for this is using a proxy for the go dependencies (like https://proxy.golang.org/), but I don't have any way of setting this setting for our app engine deployments.
Does anyone know how I can use a proxy for google app engine deploys to make our builds more stable?

Related

Why am I still getting a warning after including app_engine_apis in app.yaml?

I have just deployed an app on Google App Engine using gcloud app deploy and I get a warning such as below:
WARNING: There is a dependency on App Engine APIs, but they are not enabled in your app.yaml. Set the app_engine_apis property.
So what I did was to include app_engine_apis: true in the app.yaml, saved it, and proceed to gcloud app deploy again. However I'm still getting the same warning. What am I missing?
I fixed the warning by running:
google beta app deploy
instead of
google app deploy
I got the fix from this document. I believe it's necessary because at the time of this answer the migration of the python2 app_engine_apis to python3 isn't complete.

can't run or deploy Google App Engine from IntelliJ

I'd like to deploy an app on GAE, but I think I must be missing something.
I've downloaded the google cloud code plugin for IntelliJ.
I've installed the gcloud SDK
I've authenticated with my google account
I've created a new project of type GAE project, which in the project structure window shows the GAE facet, and has an appengine-web.xml file.
Yet when I try and run my new project the log shows an error:
21:51 Error running 'Google App Engine Deployment': Deployment is not selected
I presume it's referring to this window:
As you can see there are no deployments. When I try to edit the Run configuration, there's not much there:
What am I doing wrong?
what happens if you try adding AppEngine support explicitly, i.e. using Tools -> Cloud Code -> App Engine -> Add App Engine Support -> App Engine Standard menu? Will the deployment target appear or anything changes?

Google App Engine: Build Timed Out during Deployment

Edit: Google Cloud at its finest. Made absolutely no changes but deployed fine this morning.
Error after ~10m of deployment (10+ deploy attempts).
I've changed the app to add a simply function with less than 10 lines of code. It has no affect on libraries and uses native python only and hence I'm not sure how it can affect the deployment.
I've tested the app and it runs fine locally.
Here is the error that I get:
ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at
https://console.cloud.google.com/xxxxxxxx/ Failure status: UNKNOWN:
Error Response: [4] DEADLINE_EXCEEDED
Previously to that, logs don't show any errors, in fact everything is going as expected.
Newest entries first:
9302e2430a0e: Pushed
4f56eb74b6bf: Pushed
21df82f90a72: Layer already exists
f0e2b3558b28: Layer already exists
99c71ba2c817: Layer already exists
2483da9621d1: Layer already exists
af09d2110abe: Layer already exists
d968669f4b42: Pushed
4b1e707066a6: Layer already exists
55530b72c8c8: Layer already exists
62c169a7d462: Layer already exists
According to this you can change the build timeout setting with:
gcloud config set app/cloud_build_timeout 1000
Setting it to 1000 seconds in this example.
I have this problem too when deploying my custom image to AppEngine flex. My image requires a few ML models and takes around 2 hours to build and GAE does not seem to like it.
To build your container images outside of Google Cloud Platform, you must first upload your images to a container image repository before you can deploy your images to App Engine with the gcloud app deploy command.
In short, push your image to Google Container Registry or container image repository of your choice, then deploy with this command
gcloud app deploy --image-url gcr.io/YOUR_PROJECT_ID/YOUR_CONTAINER_IMAGE
More info here and here
For my case, I've found out the problem was that I have the same version for all gcloud app deploy command.
When there's traffic, the deployment will timeout.

Deploy gcloud app to diff environments

I have an app that uses the following command to deploy a static app generated by create-react-app:
gcloud app deploy --project MY_PROJECT -v dev
After that, my app is available on myproject.appstop.com.
But I don't figure out how to deploy this app using a diff URL for each environment. Like.: dev.myproject.appspot.com, stg.myproject.com and so on.
If you know or have other ideas about how to solve this please share your thoughts.
It depends on what you understand by environment. I would definitely recommend you to create different projects for the different environments (my-project-dev, my-project-staging, my-project-test, my-project-prod...)
If you just want to have a different url for your deployment, you are doing ok by using the -v (version parameter).
Once you've deployed again:
gcloud app deploy --project MY_PROJECT -v test
you'll have both versions accessible at:
dev.myproject.appspot.com
test.myproject.appspot.com
Also, check Dan's answer below as it contains very relevant info.
To complement #MarCialR's answer, you can use SSL as well, but with *-dot-* URLs like https://test-dot-myproject.appspot.com, see Targeted routing.
But personally I'm not a big fan of a version-based environment, it brings trouble, see Continuous integration/deployment/delivery on Google App Engine, too risky?
I chose to implement environments at app level - each environment as a different app, each with its own URL. See Advantages of implementing CI/CD environments at GAE project/app level vs service/module level?
Since I'm using a wildcard custom-domain SSL certificate I'm simply mapping the different apps (environments) to different hosts/subdomains in my custom domain - thus ensuring everything works as expected with a custom domain at every point in the CI/CD pipeline, no surprises in production.

Deploying Push Queues in Google Cloud

I'm deploying an app in Google Cloud that has multiple microservices. For one of them, I wish to use a push queue. I configured my queue.yaml file as follows:
queue:
- name: equeue
rate: 10/s
retry_parameters:
task_retry_limit: 1
task_age_limit: 2d
I spin up the SDK and the queue is working fine, just as it should. But then I go to push it to my app on Google Cloud using:
gcloud app deploy --project=<projectname> --promote --stop-previous-version
The code all loads correctly, but the queue never gets created. I am getting errors from my code as follows:
API error 1 (taskqueue: UNKNOWN_QUEUE)
And when I look in the console, on https://console.cloud.google.com/appengine/taskqueues, the queue has not been created.
I've read the documentation and it seems to indicate that all I need to do is create the queue.yaml file and deploy the app (and that has worked for me in the past, albeit with an older version of the SDK.)
In case it helps, here are the components I'm running locally:
Google Cloud SDK 164.0.0
app-engine-go
app-engine-python 1.9.57
bq 2.0.24
core 2017.07.25
gcloud
gsutil 4.27
Thanks!
Dan
The queue.yaml is an app-level configuration file, not a service-specific one. See (marginally related) Why do I need to deploy a "default" app before I can deploy multiple services in GCP?
While in a single service app case deploying the default service might also update one or more of these app-level configs that is not guaranteed in a multi-service app case. Which is why each of these configs also comes with an individual dedicated method of deployment which can be performed independently of and/or without updating any of the app's services.
For queue.yaml in particular deployment can be done using gcloud app deploy:
gcloud app deploy [...] queues.yaml
or, if you're using the GAE SDK, using appcfg.py update_queues:
appcfg.py update_queues -A <app_id>

Resources