0

I am working on my first app. I chose to go with the Flexible Python environment interacting with DataTables. I have the app working and it is secured with Identity-Aware Proxy to limit access to our company domain.

I am now trying to deploy a cron job to periodically clean old entities to keep the data set size down. I have the cleanup task working and can run it manually. However, I continually get the following error in the logs when trying to have it run automatically:

Request failed because URL requires user login. For requests invoked within App Engine (offline requests like Task Queue, or webhooks like XMPP and Incoming Mail), the URL must require admin login (or no login).

From what I read in the documentation, the Flex environment no longer uses the handlers section of the app.yaml file and the app is supposed to handle verification of the cron service itself. But this error seems to indicate that the script is not even being run.

I have tried the following with the result being that error message above each time: 1. turning off IAP and having no restrictions on access 2. adding a handlers section to the app.yaml file for the /clean job

Has anyone run into this problem and gotten it to work?

app.yaml:

service: dashboard
env: flex
runtime: python
entrypoint: gunicorn -b :$PORT dashboard:app --timeout 300
api_version: 1
threadsafe: false
skip_files: 
- ^(.*/)?\.pyc$

runtime_config:
  python_version: 2

cron.yaml:

cron:
- description: remove old cluster heartbeats
  url: /clean?
  schedule: every 24 hours
  target: dashboard
Matthew Sachs
  • 1,545
  • 6
  • 9
  • Try adding a handler in `app.yaml` for the cron's url with `login:admin`, see for an example https://stackoverflow.com/questions/45776773/404-from-cron-job-on-google-app-engine-django-app/45778165#45778165. – Dan Cornilescu Oct 04 '17 at 06:21
  • I tried with a new handler like that. I get the same error when trying to test the cron job. I also find that I can not run it directly any more. handlers: - url: /clean script: dashboard.app login: admin – Bill Snider Oct 04 '17 at 18:43
  • In your application code, is it listening for requests at `/clean`? You might need to update your question with more of your own code. As you said, in flex, you handle the routing not GAE. – BrettJ Oct 05 '17 at 04:13

1 Answers1

0

I finally got this working. But I am not sure exactly what made it work. I did not change my app.yaml, cron.yaml or application code.

However, I did create another basic "Hello World" service in this project to see if I could get it working. Once I had it working, I went back and tried my original dashboard service and it was now working. It feels like the new service deployment fixed whatever the problem was.

  • There could be some deployment-related bug lurking, similar workaround reported here: https://stackoverflow.com/questions/45363766/cron-job-in-google-app-engine-not-working/45363938#45363938 – Dan Cornilescu Oct 05 '17 at 13:22