Reputation:
I am able to successfully run my "job" by visiting "https://keel-test.appspot.com/tasks/test/". I tested the header using "http://www.webconfs.com/http-header-check.php" which returns a 200 response.
I successfully pushed the following cron.yaml to Google App Engines:
cron:
- description: "test"
url: /tasks/test
schedule: every 8 hours
I tried running the task via the GCP Console Task queues page. However, the GCP console says that the CRON job returns a 300 error. There are zero logs except that the page returns a 301 when run by CRON and 200 if the URL above is visited manually.
Here is the app.yaml:
runtime: python
env: flex
entrypoint: gunicorn config.wsgi:application
runtime_config:
python_version: 3
Upvotes: 0
Views: 758
Reputation: 742
I had the same problem with Django
URLs (urls.py):
...
url(r'^health_check/', health_check, name='health_check'),
...
My backend has the SSL Redirect enabled
SECURE_SSL_REDIRECT = True
Seeing that the app-engine crons do not follow redirects I had to disable the redirect for this one endpoint by adding the end point to the SECURE_REDIRECT_EXEMPT variable in settings.py
...
SECURE_REDIRECT_EXEMPT = [r'^health_check/']
...
Upvotes: 4
Reputation: 11370
Your cron job is hitting /tasks/test
(without trailing slash). Your url handler either doesn't exist or has the trailing slash.
Try hitting https://keel-test.appspot.com/tasks/test
(no slash). It redirects. Thus, the 301
Your URL handler:
url(r'^tasks/test/$', investment_views.test, name='test_job')
insists there be a trailing slash. Change that to:
url(r'^tasks/test', investment_views.test, name='test_job')
And both (with and without slash, along with anything that starts with test
(eg: testing123) will get to that handler.
or, use both handlers with end-of-url signaling $
sign, if you want both to work:
url(r'^tasks/test$', investment_views.test, name='test_job')
url(r'^tasks/test/$', investment_views.test, name='test_job')
or, if you want your urls to always have the trailing slash, make sure your cron job urls obey that standard:
cron:
- description: "test"
url: /tasks/test/
schedule: every 8 hours
Upvotes: 2