Mark
Mark

Reputation: 92440

Setting retry_parameters on cron.yaml

I am setting up a cron job related to an App Engine app (standard environment, Python 3) and want it to retry after 2 minutes on failure. No matter what value I put in retry_parameters it seems to be retrying in 1 minute. Looking at the docs, I don't see a mention of a max wait time, so I wonder if I've just messed up the cron.yaml somehow.

Everything is working perfectly, except it is retrying sooner than I would like. Here's the yams — is this a limit or have messed something up.

cron.yaml:

cron:
- description: "daily call"
  url: /twilio/start_call/
  timezone: "America/Anchorage"
  schedule: every day 17:00
  retry_parameters:
    min_backoff_seconds: 120.0
    max_backoff_seconds: 360.0
    max_doublings: 3

Edit:

Here's a sample of the Stackdriver logs generated with the cron.yaml. The function returned 503 each time until the last and cron was firing the jobs at 1-minute intervals:

2018-11-26 17:00:00.764 AKST GET 503 178 B 970 ms AppEngine-Google (+http://code.google.com/appengine) /twilio/start_call/
2018-11-26 17:01:01.939 AKST GET 503 178 B 704 ms AppEngine-Google;(+http://code.google.com/appengine) /twilio/start_call/
2018-11-26 17:02:02.747 AKST GET 503 178 B 850 ms AppEngine-Google;(+http://code.google.com/appengine) /twilio/start_call/
2018-11-26 17:03:03.702 AKST GET 503 178 B 666 ms AppEngine-Google;(+http://code.google.com/appengine) /twilio/start_call/
2018-11-26 17:04:04.477 AKST GET 200 189 B 65 ms AppEngine-Google; (+http://code.google.com/appengine) /twilio/start_call/

Here's what a particular log entry looks like expanded:

{
  httpRequest: {
    status: 503
  }
  insertId: "5bfca521000b366ac405955e"
  labels: {
    clone_id: "00c61b117cda9e441fb74ae3fd3225f528216a2a7e2fd701de97c95ac79fdc86ce3014f397"
  }
  logName: "projects/caller-app/logs/appengine.googleapis.com%2Frequest_log"
  operation: {
    first: true
    id: "5bfca52000ff0baa94727d8d2500016d7e7368656c7465722d63616c6c65720001323031383131323674313033313038000100"
    last: true
    producer: "appengine.googleapis.com/request_id"
  }
  protoPayload: {
    @type: "type.googleapis.com/google.appengine.logging.v1.RequestLog"
    appEngineRelease: "1.9.65"
    appId: "m~caller-app"
    cost: 1.9892999999999998e-8
    endTime: "2018-11-27T02:00:01.734682Z"
    finished: true
    first: true
    host: "caller-app.appspot.com"
    httpVersion: "HTTP/1.1"
    instanceId: "00c61b117cda9e441fb74ae3fd3225f528216a2a7e2fd701de97c95ac79fdc86ce3014f397"
    instanceIndex: -1
    ip: "0.1.0.1"
    latency: "0.970118s"
    megaCycles: "123"
    method: "GET"
    requestId: "5bfca52000ff0baa94727d8d2500016d7e7368656c7465722d63616c6c65720001323031383131323674313033313038000100"
    resource: "/twilio/start_call/"
    responseSize: "178"
    startTime: "2018-11-27T02:00:00.764564Z"
    status: 503
    taskName: "22a1b20373e6b0b93d21726ad7218cff"
    taskQueueName: "__cron"
    traceId: "54903137240fb57e546907087fb94ca5"
    traceSampled: true
    urlMapEntry: "auto"
    userAgent: "AppEngine-Google; (+http://code.google.com/appengine)"
    versionId: "20181126t103108"
  }
  receiveTimestamp: "2018-11-27T02:00:01.759151584Z"
  resource: {
    labels: {
      module_id: "default"
      project_id: "caller-app"
      version_id: "20181126t103108"
      zone: "us-west2-3"
    }
    type: "gae_app"
  }
  timestamp: "2018-11-27T02:00:00.764564Z"
  trace: "projects/caller-app/traces/54903137240fb57e546907087fb94ca5"
  traceSampled: true
}

Upvotes: 0

Views: 246

Answers (1)

Mark
Mark

Reputation: 92440

So this was a simple case of mis-reading the documentation. But in case anyone misreads it as well…

Responding with a 503 is a special case. The documentation explains:

By default, failed jobs are not retried unless a 503 status code is returned, in which case it is retried every minute until it succeeds or returns a 200-299 status code.

It doesn't explicitly say it, but this means that when the server responds with a 503 status the retry_parameters in cron.yaml are ignored and it still retries every minute.

Upvotes: 2

Related Questions