0
votes

I have a problem getting a cron job to correctly target a specific service on the Google App Engine Standard for a python app. I can successfully create a cron job for a python app on Google App Engine (Standard) with the app.yaml file and a cron.yaml file. The service is not defined and is the default service. the cron.yaml does not specify a target. If I set the service name in the app.yaml file to service1, the URL for the app changes from projectID.ew.r.appspot.com to service1-dot-projectID.ew.r.appspot.com.

Next, I specify the target in the cron job to service1 and redeploy the app.yaml and cron.yaml. The cron job now fails with status 400 every time it runs. From what I can see in the ProtoPayLoad logs, the host is not using the correct URL.

The cron job uses the URL service1.projectID.ew.r.appspot.com, according the protoPayLoad "host" value in the log. The cron job returns a Status 400. Why does the cron job not use the service1-dot-projectID.ew.r.appspot.com URL? What can I do to get the cron job to correctly target a specific service?

#app.yaml with working cron job
#project URL: projectID.ew.r.appspot.com
runtime: python38

handlers:
- url: /static
  static_dir: static/

- url: /.*
  script: auto
#cron.yaml with working cron job
cron:
  - description: "working cron job"
    url: /myjob/
    schedule: every 2 minutes

Here are the versions of files for the broken cron job

#app.yaml with broken cron job
#project URL: service1-dot-projectID.ew.r.appspot.com
service: service1
runtime: python38

handlers:
- url: /static
  static_dir: static/

- url: /.*
  script: auto
#cron.yaml with working cron job
cron:
  - description: "working cron job"
    url: /myjob/
    schedule: every 2 minutes
    target: service1

The error in the app engine log file has the protoPayLoad details.

host:"service1.projectID.ew.r.appspot.com"

I think it should be the following

host:"service1-dot-projectID.ew.r.appspot.com"

My project has multiple services deployed that will use cron jobs specific to each service. I cannot just use the default service name. I appreciate all the help.

1

1 Answers

1
votes

It is only after posting a question do you find the answer. This project is a Django project. The django Settings file has a list of URLs defined in the ALLOWED_HOSTS variable. service1-dot-projectID.ew.r.appspot.com was defined but service1.projectID.ew.r.appspot.com was not defined.

Once this was added, the cron job worked perfectly, targeting a service as normal.