Hi Elliott,
I have been able to narrow down the problem. There is a mismatch
between the app URL with a defined service name and the cron job "host"
used.
I can explain it as follows:
if you have an app.yaml file such as this:
runtime: python38
handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /static
static_dir: static/
# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
script: auto
#END OF APP.YAML
-------------------------
and a cron.yaml file that looks like this:
cron:
- description: "Example cron job"
url: /myjob/
schedule: every 2 minutes
#END OF CRON.YAML
The App Engine cron job will make a request to the "resource": "/myjob/"
and "host": "projectid.ew.r.appspot.com"
as seen in the protoPayLoad in the log file for the app on the App Engine.
This works fine as the app url is "projectid.ew.r.appspot.com"
If you give the app a service name such as service1 in the app.yaml file by
adding:
service: service1
and then target that service in the cron.yaml file which looks like this:
cron:
- description: "Example cron job"
url: /myjob/
schedule: every 2 minutes
target: service1
Then, the app is deployed to service1-dot-projectid.ew.r.appspot.com
But the cron job uses a "resource":/myjob/ and "host": "
service1.projectid.ew.r.appspot.com"
There is a mismatch between the app url and the host the cron job uses. The
app has -dot- between the service and the project name
while the cron looks for service1.projectid.ew.r.appspot.com with just "."
instead of "-dot-"
What is the best way to ensure the cron job uses the right "host" URL?
Preferably "-dot-".
Regards
David
On Tue, Dec 15, 2020 at 7:38 PM 'Elliott (Cloud Platform Support)' via
Google App Engine <[email protected]> wrote:
> Hello,
>
> I understand that you have a problem with your application. Although
> Google Groups is meant for general discussions, we may still be able to
> guide you, at least a little bit.
>
> To move things forward, would you be able to share some redacted logs
> about the 400 error? I was able to find this
> <https://developer.mozilla.org/en-US/docs/Web/HTTP/Status> article with
> basic information.
>
> Client error responses:
> 400 Bad Request
> The server could not understand the request due to invalid syntax.
>
>
>
> On Tuesday, December 15, 2020 at 12:04:59 PM UTC-5 [email protected]
> wrote:
>
>> Hi have a Python 3.8 Django app deployed to GAE standard with a working
>> cron job that
>> executes an endpoint. The endpoint returns a 200 when everything goes
>> well.
>> The app.yaml file does not define the service name and is the default
>> service.
>> there is only one job in the cron.yaml and does not specify a target
>> service.
>>
>> When I specify the service name in the app.yaml and specify the cron job
>> to
>> target that same service, it executes the endpoint but returns a status
>> 400
>> and doesn't execute the code in the endpoint function.
>>
>> What is causing the status 400?
>>
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Google App Engine" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-appengine/YShxDzvhd28/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-appengine/e66be266-5356-45f6-971b-520cdca4b48an%40googlegroups.com
> <https://groups.google.com/d/msgid/google-appengine/e66be266-5356-45f6-971b-520cdca4b48an%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/CACux6Ck0f0BPtTGjE365RzATqLO1xrQfXnkqwptXwo7Zcbuc1Q%40mail.gmail.com.