Issues while creating and deploying an app to google app engine - google-app-engine

I am running into this error while deploying my app to google app-engine.
Error:
Error 404: --- begin server output ---
This application does not exist (project_id=u'homework-153002'). To create an App Engine application in this project, run "gcloud beta app create" in your console.
--- end server output ---
When I try to create the app using the above command this is what I see:
ERROR: (gcloud.beta.app.create) You do not have permission to access app [homework] (or it may not exist): Operation not allowed
I have created a project in google developers api website with project_name of "homework" and random id. Here is the url for that:
https://console.developers.google.com/apis/library?project=homework-153002
Any pointers on what I might be doing wrong here?
This is my yaml file:
application: homework-153002
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"

Your app URL indicates your app ID is homework-153002, but the
error message indicates you're connecting to an ap called homework - likely not your own, hence the permission issue.
Simply correcting the app ID in your deployment command and/or your app.yaml file should suffice.
As your comment indicates, for your case (gcloud deployment) the solution was:
gcloud config set project homework-153002
gcloud beta app create
appcfg.py update homework/

Related

Google App Engine - Issue with creating a bulkloading config

I keep getting the below error while trying to create a bulkloader_config
HTTPError: HTTP Error 404: Not Found
[ERROR ] Authentication Failed: Incorrect credentials or unsupported authentication type (e.g. OpenId).
Command I am trying to execute
appcfg.py create_bulkloader_config --filename=bulkloader.yaml --url=https://<app-id>.appspot.com/_ah/remote_api --application=s~<app-id>
app.yaml as below
application: <app-id>
version: alpha-1-1-2
runtime: python27
api_version: 1
threadsafe: yes
builtins:
- appstats: on
- remote_api: on
Help appreciated as to what could be going wrong. The username and password are spot on.

Google App engine needs periodic restarting

I have a module that works fine when I push it to app engine. When it works it logs stuff nicely and the logs are accessible in the console logs viewer. But then after a while it just stops working and when I try to access any url give me 500 server errors with no info (it just says waiting 30 seconds might be a good idea). When this happens nothing gets logged for requests.
If I restart the module (by pushing my code to app engine) then it works for a little while again.
The module is running a Pyramid app and the configuration file looks a little something like:
application: my_app
module: my_module
version: dev
runtime: python27
api_version: 1
threadsafe: false
instance_class: B2
basic_scaling:
max_instances: 2
idle_timeout: 10m
handlers:
- url: /actions/.*
script: my_module.application
login: admin
- url: /.*
script: my_module.application
builtins:
- appstats: off
libraries:
- name: webob
version: latest
- name: setuptools
version: latest
includes:
- mapreduce/include.yaml
I think what is happening is that it's hitting the idle timeout and shutting down. I need requests to the module to turn it back on again. How do I do that?
Let me know if you need more info, I'm an app engine noob at this stage. Any help would be greatly appreciated.
When a module start, App Engine call the url /_ah/start. You mustn't handle this request.
In you my_module.application you need to add in the handler who match this request :
def get(self):
# Let module start
if "X-Appengine-Cron" in self.request.headers or "X-AppEngine-TaskName" in self.request.headers or "X-Appengine-Failfast" in self.request.headers:
return
Even if you hit the idle timeout, AppEngine will spin a new instance when new request is coming in.
Use Cloud Debugger to inspect the state of your application. The debugger makes it easier to view the application state and understand what happens after your app has been running for while.
Check the docs on startup state https://cloud.google.com/appengine/docs/python/modules/#Python_Instance_states
you current default handler /.* should be able deal with a /_ah/start if youe handler can gracefully deal with a 404.
Thats how I handle startups. Goes through the main handler which can deal with non existent url requests using the default pyramid not found.
I have a config.add_notfound_view(notfound) registered.

Error Response: [13] An internal error occurred, when deploying project on Google Cloud SDK

I have been trying to deploy my project on Google Cloud SDK since yesterday and have been getting the same error over and over.
My app.yaml file looks like:
runtime: python27
api_version: 1
threadsafe: yes
- url: /
static_files: bin/index.html
upload: bin/index.html
- url: /assets
static_dir: bin/assets
- url: /src
static_dir: bin/src
- url: /vendor
static_dir: bin/vendor
- url: /templates-app.js
static_files: static/templates-app.js
upload: static/templates-app.js
- url: /templates-common.js
static_files: static/templates-common.js
upload: static/templates-common.js
- url: .*
script: main.app
I use this command to deploy:
gcloud preview app deploy app.yaml --version 1 --promote --force
And I get this error:
Beginning deployment...
Copying files to Google Cloud Storage...
Synchronizing files to [gs://staging.myapp.appspot.com/].
Updating module [default]...failed.
ERROR: (gcloud.preview.app.deploy) Error Response: [13] An internal error occurred.
I got the same error today Error Response: [13] An internal error occurred.
In my case, the issue was because I have a folder that has over 1000 files. Once I moved some of these files elsewhere, the internal error message disappeared!
I tried 1000 files in one folder, and it worked, then, I added one file (1001 files total) in the same folder, and the same internal error came back. It seems that it is kind of a limit that google app engine has 1000 files per folder.
I notice you don't have your app name in the app.yaml file and you also don't specify it in the upload cmd. I'd suggest making a habit in providing as much as the info as possible in the app.yaml to minimize the chances of human error. You can also specify the version in the app.yaml as well. This habit will help when you'll get to multi-modules apps, where such info is mandatory. See examples in the modules config doc.
From a different prospective, I saw several reports in which gcloud preview app deploy tripped, you can always try alternate approaches to rule out such cases, see my answer to this Q&A: Google App Engine deploy with Django module after gcloud update?
It ended up being the reportlab python library in the lib folder.
I found inserting it as a zip file rather than a normal folder worked.
import sys
sys.path.insert(0, 'reportlab.zip')
import reportlab
...
I have no idea why it wouldn't work. But I remember seeing something about a file limit when uploading projects with app-engine. Deploying 1 zip file is better than 181 files that make up reportlab.

How use AppEngine's Datastore Admin: Copy to Another App Feature

I recently enabled AppEngine's Datastore Admin. I do not understand the instructions on how to copy my data to another app.
Note: The target application must
enable remote_api and must include
this application’s ID in its
HTTP_X_APPENGINE_INBOUND_APPID list.
WARNING This application’s data is
writable. We can only guarantee a
consistent copy when the data being
copied is read-only. Note: Blobs
(binary data) will not be copied.
To enable the remote_api I included the following in the app.yaml:
builtins:
- remote_api: on
I have no idea what HTTP_X_APPENGINE_INBOUND_APPID is, and a Google search yields no results....any ideas?
The datastore copy feature is currently available only for Python applications.
If you are using GAE for Java you must do the following steps:
Notes: Assuming you are copying from app example1.appspot.com to app example2.appspot.com and your Java WEB-INF app folder is located in /Users/admin/src/main/webapp/WEB-INF
Download Python SDK
https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python
Run the Python SDK
Create a new file inside your WEB-INF folder: app.yaml
Create a new file inside your WEB-INF folder: appengine_config.py
Deploy your new version (run in terminal): appcfg.py -A example2 update **/Users/admin/src/main/webapp/WEB-INF
Go to your example1 datastore admin view and put: datastore-admin.example2.appspot.com/_ah/remote_api
app.yaml:
application: example2
version: datastore-admin
runtime: python
api_version: 1
builtins:
- remote_api: on
- datastore_admin: on
appengine_config.py:
remoteapi_CUSTOM_ENVIRONMENT_AUTHENTICATION = (
'HTTP_X_APPENGINE_INBOUND_APPID', ['example1'])
If you are using java and already tried this and its not working(i had the same problem) i added:
<servlet>
<display-name>Remote API Servlet</display-name>
<servlet-name>RemoteApiServlet</servlet-name>
<servletclass>com.google.apphosting.utils.remoteapi.RemoteApiServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RemoteApiServlet</servlet-name>
<url-pattern>/remote_api</url-pattern>
</servlet-mapping>
in web.xml and update with this command: appcfg.py -A appid update /yourappfolder/war/WEB-INF
Strange but after i did that it worked.
If you are using GAE for Java you must do the steps in this answer.
GAE now use Python 2.7. So you need to create your app.yaml as below.
application: example2
version: datastore-admin
runtime: python27
api_version: 1
threadsafe: true
builtins:
- remote_api: on
The datastore_admin tool should enable through the admin console instead of enabling the builtin in your app.yaml.

Cron file - disable access (Google App Engine)

I'm running a cron file in Google App Engine. It seems to be working fine, except I don't want anyone to be able to access the URL.
Here is my .cron file:
cron:
- description: testing cron
url: /tester
schedule: every 1 minutes
I tried adding: "login: admin" underneath "schedule", but I get:
enter code here
Error parsing yaml file:
Unexpected attribute 'login' for object of type <class 'google.appengine.api.croninfo.CronEntry'>.
So how do I prevent someone from calling the url and running a script that should be automated?
Thanks
You restrict access to URLs in app.yaml. Add a correspondent entry for your cron tester:
application: hello-cron
version: 1
runtime: python
api_version: 1
handlers:
- url: /tester
script: tester.py
login: admin

Resources